mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 22:50:21 +00:00
Fix unintuitive UI where objects had to be visible for the operation to run.
This commit is contained in:
@@ -117,5 +117,5 @@ class CopyAttributeToSelection(bpy.types.Operator, Operator):
|
|||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
value = context.active_object.BIMAttributeProperties.attributes.get(self.name).get_value()
|
value = context.active_object.BIMAttributeProperties.attributes.get(self.name).get_value()
|
||||||
for obj in context.selected_objects:
|
for obj in tool.Blender.get_selected_objects():
|
||||||
core.copy_attribute_to_selection(tool.Ifc, name=self.name, value=value, obj=obj)
|
core.copy_attribute_to_selection(tool.Ifc, name=self.name, value=value, obj=obj)
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ class AssignDocument(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
document = tool.Ifc.get().by_id(self.document)
|
document = tool.Ifc.get().by_id(self.document)
|
||||||
objs = [bpy.data.objects.get(self.obj)] if self.obj else context.selected_objects
|
objs = [bpy.data.objects.get(self.obj)] if self.obj else tool.Blender.get_selected_objects()
|
||||||
for obj in objs:
|
for obj in objs:
|
||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
if element:
|
if element:
|
||||||
@@ -144,7 +144,7 @@ class UnassignDocument(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
document = tool.Ifc.get().by_id(self.document)
|
document = tool.Ifc.get().by_id(self.document)
|
||||||
objs = [bpy.data.objects.get(self.obj)] if self.obj else context.selected_objects
|
objs = [bpy.data.objects.get(self.obj)] if self.obj else tool.Blender.get_selected_objects()
|
||||||
for obj in objs:
|
for obj in objs:
|
||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
if element:
|
if element:
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ class AssignMaterial(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
material_type: bpy.props.StringProperty()
|
material_type: bpy.props.StringProperty()
|
||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
objects = [bpy.data.objects.get(self.obj)] if self.obj else context.selected_objects
|
objects = [bpy.data.objects.get(self.obj)] if self.obj else tool.Blender.get_selected_objects()
|
||||||
active_obj = context.active_object
|
active_obj = context.active_object
|
||||||
active_object_material_type = self.material_type or active_obj.BIMObjectMaterialProperties.material_type
|
active_object_material_type = self.material_type or active_obj.BIMObjectMaterialProperties.material_type
|
||||||
material = tool.Ifc.get().by_id(int(active_obj.BIMObjectMaterialProperties.material))
|
material = tool.Ifc.get().by_id(int(active_obj.BIMObjectMaterialProperties.material))
|
||||||
@@ -205,7 +205,7 @@ class UnassignMaterial(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
obj: bpy.props.StringProperty()
|
obj: bpy.props.StringProperty()
|
||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
objects = [bpy.data.objects.get(self.obj)] if self.obj else context.selected_objects
|
objects = [bpy.data.objects.get(self.obj)] if self.obj else tool.Blender.get_selected_objects()
|
||||||
for obj in objects:
|
for obj in objects:
|
||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
if element:
|
if element:
|
||||||
@@ -472,7 +472,7 @@ class EditAssignedMaterial(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
element = tool.Ifc.get_entity(active_obj)
|
element = tool.Ifc.get_entity(active_obj)
|
||||||
material = ifcopenshell.util.element.get_material(element)
|
material = ifcopenshell.util.element.get_material(element)
|
||||||
|
|
||||||
objects = context.selected_objects
|
objects = tool.Blender.get_selected_objects()
|
||||||
|
|
||||||
if props.active_material_set_item_id != 0: # We were editing a material layer set item
|
if props.active_material_set_item_id != 0: # We were editing a material layer set item
|
||||||
bpy.ops.bim.edit_material_set_item(material_set_item=props.active_material_set_item_id)
|
bpy.ops.bim.edit_material_set_item(material_set_item=props.active_material_set_item_id)
|
||||||
@@ -668,7 +668,7 @@ class CopyMaterial(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
material = ifcopenshell.util.element.get_material(
|
material = ifcopenshell.util.element.get_material(
|
||||||
self.file.by_id(context.active_object.BIMObjectProperties.ifc_definition_id)
|
self.file.by_id(context.active_object.BIMObjectProperties.ifc_definition_id)
|
||||||
)
|
)
|
||||||
for obj in context.selected_objects:
|
for obj in tool.Blender.get_selected_objects():
|
||||||
if obj == context.active_object:
|
if obj == context.active_object:
|
||||||
continue
|
continue
|
||||||
if not obj.BIMObjectProperties.ifc_definition_id:
|
if not obj.BIMObjectProperties.ifc_definition_id:
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ class RemovePset(bpy.types.Operator, Operator):
|
|||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
if self.obj_type == "Object":
|
if self.obj_type == "Object":
|
||||||
if context.selected_objects:
|
if context.selected_objects:
|
||||||
objects = [o.name for o in context.selected_objects]
|
objects = [o.name for o in tool.Blender.get_selected_objects()]
|
||||||
else:
|
else:
|
||||||
objects = [context.active_object.name]
|
objects = [context.active_object.name]
|
||||||
else:
|
else:
|
||||||
@@ -318,7 +318,7 @@ class AddPset(bpy.types.Operator, Operator):
|
|||||||
pset_name = get_pset_props(context, self.obj, self.obj_type).pset_name
|
pset_name = get_pset_props(context, self.obj, self.obj_type).pset_name
|
||||||
if self.obj_type == "Object":
|
if self.obj_type == "Object":
|
||||||
if context.selected_objects:
|
if context.selected_objects:
|
||||||
objects = [o.name for o in context.selected_objects]
|
objects = [o.name for o in tool.Blender.get_selected_objects()]
|
||||||
else:
|
else:
|
||||||
objects = [context.active_object.name]
|
objects = [context.active_object.name]
|
||||||
else:
|
else:
|
||||||
@@ -446,7 +446,7 @@ class CopyPropertyToSelection(bpy.types.Operator, Operator):
|
|||||||
is_pset = tool.Ifc.get().by_id(context.active_object.PsetProperties.active_pset_id).is_a("IfcPropertySet")
|
is_pset = tool.Ifc.get().by_id(context.active_object.PsetProperties.active_pset_id).is_a("IfcPropertySet")
|
||||||
pset_name = context.active_object.PsetProperties.active_pset_name
|
pset_name = context.active_object.PsetProperties.active_pset_name
|
||||||
prop_value = context.active_object.PsetProperties.properties.get(self.name).metadata.get_value()
|
prop_value = context.active_object.PsetProperties.properties.get(self.name).metadata.get_value()
|
||||||
for obj in context.selected_objects:
|
for obj in tool.Blender.get_selected_objects():
|
||||||
core.copy_property_to_selection(
|
core.copy_property_to_selection(
|
||||||
tool.Ifc,
|
tool.Ifc,
|
||||||
tool.Pset,
|
tool.Pset,
|
||||||
@@ -548,10 +548,9 @@ class BIM_OT_add_edit_custom_property(bpy.types.Operator):
|
|||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
selected_objects = context.selected_objects
|
|
||||||
props = context.scene.AddEditProperties
|
props = context.scene.AddEditProperties
|
||||||
|
|
||||||
for obj in selected_objects:
|
for obj in tool.Blender.get_selected_objects():
|
||||||
ifc_definition_id = obj.BIMObjectProperties.ifc_definition_id
|
ifc_definition_id = obj.BIMObjectProperties.ifc_definition_id
|
||||||
if not ifc_definition_id:
|
if not ifc_definition_id:
|
||||||
continue
|
continue
|
||||||
@@ -607,10 +606,9 @@ class BIM_OT_bulk_remove_psets(bpy.types.Operator):
|
|||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
selected_objects = context.selected_objects
|
|
||||||
props = context.scene.DeletePsets
|
props = context.scene.DeletePsets
|
||||||
|
|
||||||
for obj in selected_objects:
|
for obj in tool.Blender.get_selected_objects():
|
||||||
ifc_definition_id = obj.BIMObjectProperties.ifc_definition_id
|
ifc_definition_id = obj.BIMObjectProperties.ifc_definition_id
|
||||||
if not ifc_definition_id:
|
if not ifc_definition_id:
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ class Blender:
|
|||||||
i += 1
|
i += 1
|
||||||
return f"{name} {i}"
|
return f"{name} {i}"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_selected_objects(cls):
|
||||||
|
return set(bpy.context.selected_objects + [bpy.context.active_object])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_ifc_object(cls, ifc_class: str, name: str = None, data=None) -> bpy.types.Object:
|
def create_ifc_object(cls, ifc_class: str, name: str = None, data=None) -> bpy.types.Object:
|
||||||
name = name or "My " + ifc_class
|
name = name or "My " + ifc_class
|
||||||
|
|||||||
Reference in New Issue
Block a user