mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 18:57:17 +00:00
Editing placements and meshes now can happen in bulk. See #1222.
This commit is contained in:
@@ -18,10 +18,13 @@ class EditObjectPlacement(bpy.types.Operator):
|
|||||||
obj: bpy.props.StringProperty()
|
obj: bpy.props.StringProperty()
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object
|
objs = [bpy.data.objects.get(self.obj)] if self.obj else bpy.context.selected_objects
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
# TODO: determine how to deal with this module dependency
|
# TODO: determine how to deal with this module dependency
|
||||||
props = bpy.context.scene.BIMGeoreferenceProperties
|
props = bpy.context.scene.BIMGeoreferenceProperties
|
||||||
|
for obj in objs:
|
||||||
|
if not obj.BIMObjectProperties.ifc_definition_id:
|
||||||
|
continue
|
||||||
matrix = np.array(obj.matrix_world)
|
matrix = np.array(obj.matrix_world)
|
||||||
if props.has_blender_offset and props.blender_offset_type == "OBJECT_PLACEMENT":
|
if props.has_blender_offset and props.blender_offset_type == "OBJECT_PLACEMENT":
|
||||||
self.calculate_unit_scale()
|
self.calculate_unit_scale()
|
||||||
@@ -80,7 +83,7 @@ class AddRepresentation(bpy.types.Operator):
|
|||||||
"geometry": obj.data,
|
"geometry": obj.data,
|
||||||
"total_items": max(1, len(obj.material_slots)),
|
"total_items": max(1, len(obj.material_slots)),
|
||||||
"should_force_faceted_brep": context.scene.BIMGeometryProperties.should_force_faceted_brep,
|
"should_force_faceted_brep": context.scene.BIMGeometryProperties.should_force_faceted_brep,
|
||||||
"should_force_triangulation": context.scene.BIMGeometryProperties.should_force_triangulation
|
"should_force_triangulation": context.scene.BIMGeometryProperties.should_force_triangulation,
|
||||||
},
|
},
|
||||||
).execute()
|
).execute()
|
||||||
if not result:
|
if not result:
|
||||||
@@ -95,7 +98,7 @@ class AddRepresentation(bpy.types.Operator):
|
|||||||
for s in obj.material_slots
|
for s in obj.material_slots
|
||||||
if s.material
|
if s.material
|
||||||
],
|
],
|
||||||
"should_use_presentation_style_assignment": context.scene.BIMGeometryProperties.should_use_presentation_style_assignment
|
"should_use_presentation_style_assignment": context.scene.BIMGeometryProperties.should_use_presentation_style_assignment,
|
||||||
},
|
},
|
||||||
).execute()
|
).execute()
|
||||||
assign_representation.Usecase(
|
assign_representation.Usecase(
|
||||||
@@ -177,9 +180,10 @@ class UpdateMeshRepresentation(bpy.types.Operator):
|
|||||||
obj: bpy.props.StringProperty()
|
obj: bpy.props.StringProperty()
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object
|
objs = [bpy.data.objects.get(self.obj)] if self.obj else bpy.context.selected_objects
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
|
|
||||||
|
for obj in objs:
|
||||||
bpy.ops.bim.edit_object_placement(obj=obj.name)
|
bpy.ops.bim.edit_object_placement(obj=obj.name)
|
||||||
|
|
||||||
old_representation = self.file.by_id(obj.data.BIMMeshProperties.ifc_definition_id)
|
old_representation = self.file.by_id(obj.data.BIMMeshProperties.ifc_definition_id)
|
||||||
@@ -191,7 +195,7 @@ class UpdateMeshRepresentation(bpy.types.Operator):
|
|||||||
"geometry": obj.data,
|
"geometry": obj.data,
|
||||||
"total_items": max(1, len(obj.material_slots)),
|
"total_items": max(1, len(obj.material_slots)),
|
||||||
"should_force_faceted_brep": context.scene.BIMGeometryProperties.should_force_faceted_brep,
|
"should_force_faceted_brep": context.scene.BIMGeometryProperties.should_force_faceted_brep,
|
||||||
"should_force_triangulation": context.scene.BIMGeometryProperties.should_force_triangulation
|
"should_force_triangulation": context.scene.BIMGeometryProperties.should_force_triangulation,
|
||||||
},
|
},
|
||||||
).execute()
|
).execute()
|
||||||
if not new_representation:
|
if not new_representation:
|
||||||
@@ -207,7 +211,7 @@ class UpdateMeshRepresentation(bpy.types.Operator):
|
|||||||
for s in obj.material_slots
|
for s in obj.material_slots
|
||||||
if s.material
|
if s.material
|
||||||
],
|
],
|
||||||
"should_use_presentation_style_assignment": context.scene.BIMGeometryProperties.should_use_presentation_style_assignment
|
"should_use_presentation_style_assignment": context.scene.BIMGeometryProperties.should_use_presentation_style_assignment,
|
||||||
},
|
},
|
||||||
).execute()
|
).execute()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user