Fix #4186. Support different RL insertion modes when adding occurrences of a type.

This commit is contained in:
Dion Moult
2024-01-10 18:53:05 +11:00
parent f55b7d439f
commit 7e262c5c9a
3 changed files with 20 additions and 3 deletions
@@ -189,12 +189,12 @@ class AddConstrTypeInstance(bpy.types.Operator):
collection_obj = collection.BIMCollectionProperties.obj
bpy.ops.bim.assign_class(obj=obj.name, ifc_class=instance_class)
tool.Blender.remove_data_block(mesh) # Remove "Instance" mesh
tool.Blender.remove_data_block(mesh) # Remove "Instance" mesh
mesh_data = obj.data
element = tool.Ifc.get_entity(obj)
blenderbim.core.type.assign_type(tool.Ifc, tool.Type, element=element, type=relating_type)
if obj.data != mesh_data: # remove orphaned mesh from "bim.assign_class"
if obj.data != mesh_data: # remove orphaned mesh from "bim.assign_class"
tool.Blender.remove_data_block(mesh_data)
# Update required as core.type.assign_type may change obj.data
@@ -241,7 +241,12 @@ class AddConstrTypeInstance(bpy.types.Operator):
bpy.ops.bim.add_filled_opening(voided_obj=building_obj.name, filling_obj=obj.name)
else:
if collection_obj and tool.Ifc.get_entity(collection_obj):
obj.location.z = collection_obj.location.z - tool.Blender.get_object_bounding_box(obj)["min_z"]
if props.rl_mode == "BOTTOM":
obj.location.z = collection_obj.location.z - tool.Blender.get_object_bounding_box(obj)["min_z"]
elif props.rl_mode == "CONTAINER":
obj.location.z = collection_obj.location.z
elif props.rl_mode == "CURSOR":
pass
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
for port in ifcopenshell.util.system.get_ports(relating_type):
@@ -132,6 +132,15 @@ class BIMModelProperties(PropertyGroup):
x: bpy.props.FloatProperty(name="X", default=0.5, subtype="DISTANCE", description="Size by X axis for the opening")
y: bpy.props.FloatProperty(name="Y", default=0.5, subtype="DISTANCE", description="Size by Y axis for the opening")
z: bpy.props.FloatProperty(name="Z", default=0.5, subtype="DISTANCE", description="Size by Z axis for the opening")
rl_mode: bpy.props.EnumProperty(
items=(
("BOTTOM", "Bottom", "Snaps the element's lowest geometry to the container's Z value."),
("CONTAINER", "Container", "Positions the element's placement origin at the container's Z value."),
("CURSOR", "Cursor", "Places the object placement at the 3D cursor's Z value."),
),
name="RL Mode",
default="BOTTOM",
)
# Used for things like walls, doors, flooring, skirting, etc
rl1: bpy.props.FloatProperty(name="RL", default=1, subtype="DISTANCE", description="Z offset for walls")
# Used for things like windows, other hosted furniture, and MEP
@@ -284,6 +284,9 @@ class BimToolUI:
row.prop(data=cls.props, property="rl2", text="RL")
elif cls.props.ifc_class in ("IfcSpaceType"):
add_layout_hotkey_operator(cls.layout, "Generate", "S_G", bpy.ops.bim.generate_space.__doc__)
else:
row = cls.layout.row(align=True)
row.prop(data=cls.props, property="rl_mode", text="RL")
@classmethod
def draw_edit_object_interface(cls, context):