Copying parametric geometry from any source now attempts to preserve parametric geometry when possible.

This commit is contained in:
Dion Moult
2021-10-22 18:07:34 +11:00
parent c551275db2
commit 6d817703aa
13 changed files with 326 additions and 103 deletions
+44 -18
View File
@@ -61,24 +61,6 @@ class Geometry(blenderbim.core.tool.Geometry):
obj.data = obj.data.copy()
return obj.data
@classmethod
def get_object_data(cls, obj):
return obj.data
@classmethod
def get_object_materials_without_styles(cls, obj):
return [
s.material for s in obj.material_slots if s.material and not s.material.BIMMaterialProperties.ifc_style_id
]
@classmethod
def get_representation_data(cls, representation):
return bpy.data.meshes.get(cls.get_representation_name(representation))
@classmethod
def get_representation_name(cls, representation):
return f"{representation.ContextOfItems.id()}/{representation.id()}"
@classmethod
def get_cartesian_point_coordinate_offset(cls, obj):
props = bpy.context.scene.BIMGeoreferenceProperties
@@ -91,6 +73,50 @@ class Geometry(blenderbim.core.tool.Geometry):
)
)
@classmethod
def get_ifc_representation_class(cls, element, representation):
material = ifcopenshell.util.element.get_material(element)
if material and material.is_a("IfcMaterialProfileSetUsage"):
return "IfcExtrudedAreaSolid/IfcMaterialProfileSetUsage"
extruded_areas = [e for e in tool.Ifc.get().traverse(representation) if e.is_a() == "IfcExtrudedAreaSolid"]
if len(extruded_areas) != 1:
return # It's too complex for us to derive topologically right now
profile_def = extruded_areas[0].SweptArea
if profile_def.is_a() == "IfcRectangleProfileDef":
return "IfcExtrudedAreaSolid/IfcRectangleProfileDef"
elif profile_def.is_a() == "IfcCircleProfileDef":
return "IfcExtrudedAreaSolid/IfcCircleProfileDef"
return "IfcExtrudedAreaSolid/IfcArbitraryProfileDefWithVoids"
@classmethod
def get_object_data(cls, obj):
return obj.data
@classmethod
def get_object_materials_without_styles(cls, obj):
return [
s.material for s in obj.material_slots if s.material and not s.material.BIMMaterialProperties.ifc_style_id
]
@classmethod
def get_profile_set_usage(cls, element):
material = ifcopenshell.util.element.get_material(element)
if material:
if material.is_a("IfcMaterialProfileSetUsage"):
return material
@classmethod
def get_representation_data(cls, representation):
return bpy.data.meshes.get(cls.get_representation_name(representation))
@classmethod
def get_representation_name(cls, representation):
return f"{representation.ContextOfItems.id()}/{representation.id()}"
@classmethod
def get_total_representation_items(cls, obj):
return max(1, len(obj.material_slots))
+17 -4
View File
@@ -49,16 +49,29 @@ class Root(blenderbim.core.tool.Root):
return ifcopenshell.util.element.get_type(element)
@classmethod
def get_object_context(cls, obj):
def get_object_representation(cls, obj):
if obj.data and obj.data.BIMMeshProperties.ifc_definition_id:
return tool.Ifc.get().by_id(obj.data.BIMMeshProperties.ifc_definition_id).ContextOfItems
return tool.Ifc.get().by_id(obj.data.BIMMeshProperties.ifc_definition_id)
@classmethod
def get_representation_context(cls, representation):
return representation.ContextOfItems
@classmethod
def is_opening_element(cls, element):
return element.is_a("IfcOpeningElement")
@classmethod
def run_geometry_add_representation(cls, obj=None, context=None):
def run_geometry_add_representation(
cls, obj=None, context=None, ifc_representation_class=None, profile_set_usage=None
):
return blenderbim.core.geometry.add_representation(
tool.Ifc, tool.Geometry, tool.Style, tool.Surveyor, obj=obj, context=context
tool.Ifc,
tool.Geometry,
tool.Style,
tool.Surveyor,
obj=obj,
context=context,
ifc_representation_class=ifc_representation_class,
profile_set_usage=profile_set_usage,
)
+1 -1
View File
@@ -93,7 +93,7 @@ class Spatial(blenderbim.core.tool.Spatial):
@classmethod
def run_root_copy_class(cls, obj=None):
return blenderbim.core.root.copy_class(tool.Ifc, tool.Collector, tool.Root, obj=obj)
return blenderbim.core.root.copy_class(tool.Ifc, tool.Collector, tool.Geometry, tool.Root, obj=obj)
@classmethod
def run_spatial_assign_container(cls, structure_obj=None, element_obj=None):