mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
Positional elements, project, and spatial elements are now locked. Remove user option to change behaviour.
This commit is contained in:
@@ -539,9 +539,6 @@ class IfcImporter:
|
||||
shape = tool.Loader.create_generic_shape(grid)
|
||||
grid_obj = self.create_product(grid, shape)
|
||||
grid_placement = self.get_element_matrix(grid)
|
||||
if tool.Blender.get_addon_preferences().lock_grids_on_import:
|
||||
grid_obj.lock_location = (True, True, True)
|
||||
grid_obj.lock_rotation = (True, True, True)
|
||||
self.create_grid_axes(grid.UAxes, grid_obj, grid_placement)
|
||||
self.create_grid_axes(grid.VAxes, grid_obj, grid_placement)
|
||||
if grid.WAxes:
|
||||
@@ -552,9 +549,6 @@ class IfcImporter:
|
||||
shape = tool.Loader.create_generic_shape(axis.AxisCurve)
|
||||
mesh = self.create_mesh(axis, shape)
|
||||
obj = bpy.data.objects.new(tool.Loader.get_name(axis), mesh)
|
||||
if tool.Blender.get_addon_preferences().lock_grids_on_import:
|
||||
obj.lock_location = (True, True, True)
|
||||
obj.lock_rotation = (True, True, True)
|
||||
self.link_element(axis, obj)
|
||||
self.set_matrix_world(obj, tool.Loader.apply_blender_offset_to_matrix_world(obj, grid_placement.copy()))
|
||||
|
||||
|
||||
@@ -627,7 +627,7 @@ class OverrideDelete(bpy.types.Operator):
|
||||
for obj in context.selected_objects:
|
||||
element = tool.Ifc.get_entity(obj)
|
||||
if element:
|
||||
if not tool.Geometry.is_deletable(element):
|
||||
if tool.Geometry.is_lockable(element):
|
||||
continue
|
||||
if ifcopenshell.util.element.get_pset(element, "BBIM_Array"):
|
||||
self.report({"INFO"}, "Elements that are part of an array cannot be deleted.")
|
||||
@@ -757,7 +757,7 @@ class OverrideOutlinerDelete(bpy.types.Operator):
|
||||
objects_to_delete.add(bpy.data.objects.get(item.name))
|
||||
for obj in objects_to_delete:
|
||||
if element := tool.Ifc.get_entity(obj):
|
||||
if not tool.Geometry.is_deletable(element):
|
||||
if tool.Geometry.is_lockable(element):
|
||||
if collection := obj.BIMObjectProperties.collection:
|
||||
collections_to_delete.discard(collection)
|
||||
continue
|
||||
|
||||
@@ -209,7 +209,6 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
|
||||
description="If disabled, the toolbar will only load when an IFC model is active",
|
||||
)
|
||||
should_play_chaching_sound: BoolProperty(name="Play A Cha-Ching Sound When Project Costs Updates", default=False)
|
||||
lock_grids_on_import: BoolProperty(name="Lock Grids By Default", default=True)
|
||||
spatial_elements_unselectable: BoolProperty(name="Make Spatial Elements Unselectable By Default", default=True)
|
||||
decorations_colour: bpy.props.FloatVectorProperty(
|
||||
name="Decorations Colour", subtype="COLOR", default=(1, 1, 1, 1), min=0.0, max=1.0, size=4
|
||||
@@ -295,8 +294,6 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
|
||||
row = layout.row()
|
||||
row.prop(self, "should_play_chaching_sound")
|
||||
row = layout.row()
|
||||
row.prop(self, "lock_grids_on_import")
|
||||
row = layout.row()
|
||||
row.prop(self, "spatial_elements_unselectable")
|
||||
|
||||
row = layout.row()
|
||||
|
||||
@@ -41,6 +41,9 @@ class Collector(bonsai.core.tool.Collector):
|
||||
element = tool.Ifc.get_entity(obj)
|
||||
assert element
|
||||
|
||||
if tool.Geometry.is_lockable(element):
|
||||
tool.Geometry.lock_object(obj)
|
||||
|
||||
if element.is_a("IfcGridAxis"):
|
||||
element = (element.PartOfU or element.PartOfV or element.PartOfW)[0]
|
||||
|
||||
|
||||
@@ -92,10 +92,21 @@ class Geometry(bonsai.core.tool.Geometry):
|
||||
bpy.data.meshes.remove(data)
|
||||
|
||||
@classmethod
|
||||
def is_deletable(cls, element: ifcopenshell.entity_instance) -> bool:
|
||||
if element.is_a("IfcProject") or tool.Root.is_spatial_element(element):
|
||||
return False
|
||||
return True
|
||||
def is_lockable(cls, element: ifcopenshell.entity_instance) -> bool:
|
||||
if (
|
||||
element.is_a("IfcProject")
|
||||
or tool.Root.is_spatial_element(element)
|
||||
or element.is_a("IfcPositioningElement")
|
||||
or element.is_a("IfcGrid")
|
||||
or element.is_a("IfcGridAxis")
|
||||
):
|
||||
return True
|
||||
return False
|
||||
|
||||
@classmethod
|
||||
def lock_object(cls, obj: bpy.types.Object) -> None:
|
||||
obj.lock_location = (True, True, True)
|
||||
obj.lock_rotation = (True, True, True)
|
||||
|
||||
@classmethod
|
||||
def delete_ifc_object(cls, obj: bpy.types.Object) -> None:
|
||||
|
||||
Reference in New Issue
Block a user