mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 06:58:56 +00:00
Column profiles now update when switching type
This commit is contained in:
@@ -152,9 +152,17 @@ class DumbColumnRegenerator:
|
|||||||
for element in rel.RelatedObjects:
|
for element in rel.RelatedObjects:
|
||||||
self.change_profile(element)
|
self.change_profile(element)
|
||||||
|
|
||||||
|
def regenerate_from_type(self, usecase_path, ifc_file, settings):
|
||||||
|
self.unit_scale = ifcopenshell.util.unit.calculate_unit_scale(ifc_file)
|
||||||
|
new_material = ifcopenshell.util.element.get_material(settings["relating_type"])
|
||||||
|
if not new_material or not new_material.is_a("IfcMaterialProfileSet"):
|
||||||
|
return
|
||||||
|
self.change_profile(settings["related_object"])
|
||||||
|
|
||||||
def change_profile(self, element):
|
def change_profile(self, element):
|
||||||
obj = IfcStore.get_element(element.id())
|
obj = IfcStore.get_element(element.id())
|
||||||
if not obj:
|
if not obj:
|
||||||
return
|
return
|
||||||
representation = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
|
representation = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
|
||||||
bpy.ops.bim.switch_representation(obj=obj.name, ifc_definition_id=representation.id(), should_reload=True)
|
if representation:
|
||||||
|
bpy.ops.bim.switch_representation(obj=obj.name, ifc_definition_id=representation.id(), should_reload=True)
|
||||||
|
|||||||
@@ -55,3 +55,8 @@ def load_post(*args):
|
|||||||
"BlenderBIM.DumbColumn.RegenerateFromProfile",
|
"BlenderBIM.DumbColumn.RegenerateFromProfile",
|
||||||
column.DumbColumnRegenerator().regenerate_from_profile,
|
column.DumbColumnRegenerator().regenerate_from_profile,
|
||||||
)
|
)
|
||||||
|
ifcopenshell.api.add_post_listener(
|
||||||
|
"type.assign_type",
|
||||||
|
"BlenderBIM.DumbColumn.RegenerateFromType",
|
||||||
|
column.DumbColumnRegenerator().regenerate_from_type,
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
import ifcopenshell.util.element
|
import ifcopenshell.util.element
|
||||||
|
import ifcopenshell.util.representation
|
||||||
|
|
||||||
|
|
||||||
class Usecase:
|
class Usecase:
|
||||||
@@ -47,6 +48,8 @@ class Usecase:
|
|||||||
material_set = self.file.create_entity("IfcMaterialProfileSet")
|
material_set = self.file.create_entity("IfcMaterialProfileSet")
|
||||||
else:
|
else:
|
||||||
material_set = self.file.create_entity("IfcMaterialProfileSet")
|
material_set = self.file.create_entity("IfcMaterialProfileSet")
|
||||||
|
|
||||||
|
self.update_representation_profile(material_set)
|
||||||
material_set_usage = self.create_profile_set_usage(material_set)
|
material_set_usage = self.create_profile_set_usage(material_set)
|
||||||
self.create_material_association(material_set_usage)
|
self.create_material_association(material_set_usage)
|
||||||
elif self.settings["type"] == "IfcMaterialList":
|
elif self.settings["type"] == "IfcMaterialList":
|
||||||
@@ -54,6 +57,21 @@ class Usecase:
|
|||||||
material_set.Materials = [self.settings["material"]]
|
material_set.Materials = [self.settings["material"]]
|
||||||
self.create_material_association(material_set)
|
self.create_material_association(material_set)
|
||||||
|
|
||||||
|
def update_representation_profile(self, material_set):
|
||||||
|
profile = material_set.CompositeProfile
|
||||||
|
if not profile and material_set.MaterialProfiles:
|
||||||
|
profile = material_set.MaterialProfiles[0].Profile
|
||||||
|
if not profile:
|
||||||
|
return
|
||||||
|
representation = ifcopenshell.util.representation.get_representation(
|
||||||
|
self.settings["product"], "Model", "Body", "MODEL_VIEW"
|
||||||
|
)
|
||||||
|
if not representation:
|
||||||
|
return
|
||||||
|
for subelement in self.file.traverse(representation):
|
||||||
|
if subelement.is_a("IfcSweptAreaSolid"):
|
||||||
|
subelement.SweptArea = profile
|
||||||
|
|
||||||
def create_layer_set_usage(self, material_set):
|
def create_layer_set_usage(self, material_set):
|
||||||
return self.file.create_entity(
|
return self.file.create_entity(
|
||||||
"IfcMaterialLayerSetUsage",
|
"IfcMaterialLayerSetUsage",
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class Usecase:
|
|||||||
self.settings[key] = value
|
self.settings[key] = value
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
|
# TODO: handle composite profiles
|
||||||
old_profile = self.settings["material_profile"].Profile
|
old_profile = self.settings["material_profile"].Profile
|
||||||
self.settings["material_profile"].Profile = self.settings["profile"]
|
self.settings["material_profile"].Profile = self.settings["profile"]
|
||||||
for profile_set in self.settings["material_profile"].ToMaterialProfileSet:
|
for profile_set in self.settings["material_profile"].ToMaterialProfileSet:
|
||||||
@@ -31,6 +32,8 @@ class Usecase:
|
|||||||
|
|
||||||
def change_profile(self, element):
|
def change_profile(self, element):
|
||||||
representation = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
|
representation = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
|
||||||
|
if not representation:
|
||||||
|
return
|
||||||
for subelement in self.file.traverse(representation):
|
for subelement in self.file.traverse(representation):
|
||||||
if subelement.is_a("IfcSweptAreaSolid"):
|
if subelement.is_a("IfcSweptAreaSolid"):
|
||||||
subelement.SweptArea = self.settings["profile"]
|
subelement.SweptArea = self.settings["profile"]
|
||||||
|
|||||||
Reference in New Issue
Block a user