mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-10-03 13:28:19 +00:00
AddRepresentation executes on all selected objects
This commit is contained in:
@@ -88,20 +88,20 @@ class AddRepresentation(bpy.types.Operator):
|
|||||||
return IfcStore.execute_ifc_operator(self, context)
|
return IfcStore.execute_ifc_operator(self, context)
|
||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object
|
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
|
gprop = context.scene.BIMGeoreferenceProperties
|
||||||
|
objs = [bpy.data.objects.get(self.obj)] if self.obj else context.selected_objects
|
||||||
|
for obj in objs:
|
||||||
|
if not obj.BIMObjectProperties.ifc_definition_id:
|
||||||
|
continue
|
||||||
bpy.ops.bim.edit_object_placement(obj=obj.name)
|
bpy.ops.bim.edit_object_placement(obj=obj.name)
|
||||||
|
|
||||||
if not obj.data:
|
if not obj.data:
|
||||||
return {"FINISHED"}
|
continue
|
||||||
|
|
||||||
product = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
|
product = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
|
||||||
|
|
||||||
context_id = self.context_id or int(context.scene.BIMProperties.contexts)
|
context_id = self.context_id or int(context.scene.BIMProperties.contexts)
|
||||||
context_of_items = self.file.by_id(context_id)
|
context_of_items = self.file.by_id(context_id)
|
||||||
|
|
||||||
gprop = context.scene.BIMGeoreferenceProperties
|
|
||||||
coordinate_offset = None
|
coordinate_offset = None
|
||||||
if gprop.has_blender_offset and obj.BIMObjectProperties.blender_offset_type == "CARTESIAN_POINT":
|
if gprop.has_blender_offset and obj.BIMObjectProperties.blender_offset_type == "CARTESIAN_POINT":
|
||||||
coordinate_offset = Vector(
|
coordinate_offset = Vector(
|
||||||
@@ -128,7 +128,7 @@ class AddRepresentation(bpy.types.Operator):
|
|||||||
|
|
||||||
if not result:
|
if not result:
|
||||||
print("Failed to write shape representation")
|
print("Failed to write shape representation")
|
||||||
return {"FINISHED"}
|
continue
|
||||||
|
|
||||||
[
|
[
|
||||||
bpy.ops.bim.add_style(material=s.material.name)
|
bpy.ops.bim.add_style(material=s.material.name)
|
||||||
@@ -136,7 +136,7 @@ class AddRepresentation(bpy.types.Operator):
|
|||||||
if s.material and not s.material.BIMMaterialProperties.ifc_style_id
|
if s.material and not s.material.BIMMaterialProperties.ifc_style_id
|
||||||
]
|
]
|
||||||
|
|
||||||
if isinstance(obj.data, bpy.types.Mesh) and len(obj.data.polygons):
|
if obj.type == "MESH" and len(obj.data.polygons):
|
||||||
ifcopenshell.api.run(
|
ifcopenshell.api.run(
|
||||||
"style.assign_representation_styles",
|
"style.assign_representation_styles",
|
||||||
self.file,
|
self.file,
|
||||||
@@ -154,7 +154,6 @@ class AddRepresentation(bpy.types.Operator):
|
|||||||
"geometry.assign_representation", self.file, **{"product": product, "representation": result}
|
"geometry.assign_representation", self.file, **{"product": product, "representation": result}
|
||||||
)
|
)
|
||||||
|
|
||||||
existing_mesh = obj.data
|
|
||||||
mesh = obj.data.copy()
|
mesh = obj.data.copy()
|
||||||
mesh.name = "{}/{}".format(context_id, result.id())
|
mesh.name = "{}/{}".format(context_id, result.id())
|
||||||
mesh.BIMMeshProperties.ifc_definition_id = int(result.id())
|
mesh.BIMMeshProperties.ifc_definition_id = int(result.id())
|
||||||
|
|||||||
Reference in New Issue
Block a user