Skip to content
This repository was archived by the owner on Nov 24, 2024. It is now read-only.

Commit b821e62

Browse files
committed
You can now add/remove material profiles in a profile set. Thanks Jesusbill!
1 parent 41141b8 commit b821e62

9 files changed

Lines changed: 62 additions & 13 deletions

File tree

src/blenderbim/blenderbim/bim/module/material/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
operator.UnassignMaterial,
99
operator.AddConstituent,
1010
operator.RemoveConstituent,
11+
operator.AddProfile,
12+
operator.RemoveProfile,
1113
operator.AddLayer,
1214
operator.RemoveLayer,
1315
operator.ReorderMaterialSetItem,

src/blenderbim/blenderbim/bim/module/material/operator.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,43 @@ def execute(self, context):
115115
return {"FINISHED"}
116116

117117

118+
class AddProfile(bpy.types.Operator):
119+
bl_idname = "bim.add_profile"
120+
bl_label = "Add Profile"
121+
obj: bpy.props.StringProperty()
122+
profile_set: bpy.props.IntProperty()
123+
124+
def execute(self, context):
125+
obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object
126+
self.file = IfcStore.get_file()
127+
ifcopenshell.api.run(
128+
"material.add_profile",
129+
self.file,
130+
**{
131+
"profile_set": self.file.by_id(self.profile_set),
132+
"material": self.file.by_id(int(obj.BIMObjectMaterialProperties.material)),
133+
},
134+
)
135+
Data.load_profiles()
136+
return {"FINISHED"}
137+
138+
139+
class RemoveProfile(bpy.types.Operator):
140+
bl_idname = "bim.remove_profile"
141+
bl_label = "Remove Profile"
142+
obj: bpy.props.StringProperty()
143+
profile: bpy.props.IntProperty()
144+
145+
def execute(self, context):
146+
obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object
147+
self.file = IfcStore.get_file()
148+
ifcopenshell.api.run(
149+
"material.remove_profile", self.file, **{"profile": self.file.by_id(self.profile)}
150+
)
151+
Data.load_profiles()
152+
return {"FINISHED"}
153+
154+
118155
class AddLayer(bpy.types.Operator):
119156
bl_idname = "bim.add_layer"
120157
bl_label = "Add Layer"

src/ifcopenshell-python/ifcopenshell/api/material/add_constituent.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import ifcopenshell
2-
3-
41
class Usecase:
52
def __init__(self, file, **settings):
63
self.file = file

src/ifcopenshell-python/ifcopenshell/api/material/add_layer.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import ifcopenshell
2-
3-
41
class Usecase:
52
def __init__(self, file, **settings):
63
self.file = file
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Usecase:
2+
def __init__(self, file, **settings):
3+
self.file = file
4+
self.settings = {"profile_set": None, "material": None}
5+
for key, value in settings.items():
6+
self.settings[key] = value
7+
8+
def execute(self):
9+
profiles = list(self.settings["profile_set"].MaterialProfiles or [])
10+
profile = self.file.create_entity("IfcMaterialProfile", **{"Material": self.settings["material"]})
11+
profiles.append(profile)
12+
self.settings["profile_set"].MaterialProfiles = profiles
13+
return profile

src/ifcopenshell-python/ifcopenshell/api/material/remove_constituent.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import ifcopenshell
2-
3-
41
class Usecase:
52
def __init__(self, file, **settings):
63
self.file = file

src/ifcopenshell-python/ifcopenshell/api/material/remove_layer.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import ifcopenshell
2-
3-
41
class Usecase:
52
def __init__(self, file, **settings):
63
self.file = file
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Usecase:
2+
def __init__(self, file, **settings):
3+
self.file = file
4+
self.settings = {"profile": None}
5+
for key, value in settings.items():
6+
self.settings[key] = value
7+
8+
def execute(self):
9+
self.file.remove(self.settings["profile"])

src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_time.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ def execute(self):
1414
elif self.settings["type"] == "ExceptionTimes":
1515
exception_times = list(self.settings["work_calendar"].ExceptionTimes or [])
1616
exception_times.append(work_time)
17-
self.settings["work_calendar"].WorkingTimes = exception_times
17+
self.settings["work_calendar"].ExceptionTimes = exception_times
1818
return work_time

0 commit comments

Comments
 (0)