mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 09:32:37 +00:00
You can now add/remove material profiles in a profile set. Thanks Jesusbill!
This commit is contained in:
@@ -8,6 +8,8 @@ classes = (
|
|||||||
operator.UnassignMaterial,
|
operator.UnassignMaterial,
|
||||||
operator.AddConstituent,
|
operator.AddConstituent,
|
||||||
operator.RemoveConstituent,
|
operator.RemoveConstituent,
|
||||||
|
operator.AddProfile,
|
||||||
|
operator.RemoveProfile,
|
||||||
operator.AddLayer,
|
operator.AddLayer,
|
||||||
operator.RemoveLayer,
|
operator.RemoveLayer,
|
||||||
operator.ReorderMaterialSetItem,
|
operator.ReorderMaterialSetItem,
|
||||||
|
|||||||
@@ -115,6 +115,43 @@ class RemoveConstituent(bpy.types.Operator):
|
|||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class AddProfile(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.add_profile"
|
||||||
|
bl_label = "Add Profile"
|
||||||
|
obj: bpy.props.StringProperty()
|
||||||
|
profile_set: bpy.props.IntProperty()
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object
|
||||||
|
self.file = IfcStore.get_file()
|
||||||
|
ifcopenshell.api.run(
|
||||||
|
"material.add_profile",
|
||||||
|
self.file,
|
||||||
|
**{
|
||||||
|
"profile_set": self.file.by_id(self.profile_set),
|
||||||
|
"material": self.file.by_id(int(obj.BIMObjectMaterialProperties.material)),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
Data.load_profiles()
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class RemoveProfile(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.remove_profile"
|
||||||
|
bl_label = "Remove Profile"
|
||||||
|
obj: bpy.props.StringProperty()
|
||||||
|
profile: bpy.props.IntProperty()
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object
|
||||||
|
self.file = IfcStore.get_file()
|
||||||
|
ifcopenshell.api.run(
|
||||||
|
"material.remove_profile", self.file, **{"profile": self.file.by_id(self.profile)}
|
||||||
|
)
|
||||||
|
Data.load_profiles()
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class AddLayer(bpy.types.Operator):
|
class AddLayer(bpy.types.Operator):
|
||||||
bl_idname = "bim.add_layer"
|
bl_idname = "bim.add_layer"
|
||||||
bl_label = "Add Layer"
|
bl_label = "Add Layer"
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
import ifcopenshell
|
|
||||||
|
|
||||||
|
|
||||||
class Usecase:
|
class Usecase:
|
||||||
def __init__(self, file, **settings):
|
def __init__(self, file, **settings):
|
||||||
self.file = file
|
self.file = file
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
import ifcopenshell
|
|
||||||
|
|
||||||
|
|
||||||
class Usecase:
|
class Usecase:
|
||||||
def __init__(self, file, **settings):
|
def __init__(self, file, **settings):
|
||||||
self.file = file
|
self.file = file
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
class Usecase:
|
||||||
|
def __init__(self, file, **settings):
|
||||||
|
self.file = file
|
||||||
|
self.settings = {"profile_set": None, "material": None}
|
||||||
|
for key, value in settings.items():
|
||||||
|
self.settings[key] = value
|
||||||
|
|
||||||
|
def execute(self):
|
||||||
|
profiles = list(self.settings["profile_set"].MaterialProfiles or [])
|
||||||
|
profile = self.file.create_entity("IfcMaterialProfile", **{"Material": self.settings["material"]})
|
||||||
|
profiles.append(profile)
|
||||||
|
self.settings["profile_set"].MaterialProfiles = profiles
|
||||||
|
return profile
|
||||||
@@ -1,6 +1,3 @@
|
|||||||
import ifcopenshell
|
|
||||||
|
|
||||||
|
|
||||||
class Usecase:
|
class Usecase:
|
||||||
def __init__(self, file, **settings):
|
def __init__(self, file, **settings):
|
||||||
self.file = file
|
self.file = file
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
import ifcopenshell
|
|
||||||
|
|
||||||
|
|
||||||
class Usecase:
|
class Usecase:
|
||||||
def __init__(self, file, **settings):
|
def __init__(self, file, **settings):
|
||||||
self.file = file
|
self.file = file
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
class Usecase:
|
||||||
|
def __init__(self, file, **settings):
|
||||||
|
self.file = file
|
||||||
|
self.settings = {"profile": None}
|
||||||
|
for key, value in settings.items():
|
||||||
|
self.settings[key] = value
|
||||||
|
|
||||||
|
def execute(self):
|
||||||
|
self.file.remove(self.settings["profile"])
|
||||||
@@ -14,5 +14,5 @@ class Usecase:
|
|||||||
elif self.settings["type"] == "ExceptionTimes":
|
elif self.settings["type"] == "ExceptionTimes":
|
||||||
exception_times = list(self.settings["work_calendar"].ExceptionTimes or [])
|
exception_times = list(self.settings["work_calendar"].ExceptionTimes or [])
|
||||||
exception_times.append(work_time)
|
exception_times.append(work_time)
|
||||||
self.settings["work_calendar"].WorkingTimes = exception_times
|
self.settings["work_calendar"].ExceptionTimes = exception_times
|
||||||
return work_time
|
return work_time
|
||||||
|
|||||||
Reference in New Issue
Block a user