You can now set cardinal point on creation and bulk change for profile elements

This commit is contained in:
Dion Moult
2022-09-24 16:21:20 +10:00
parent 56f4b72161
commit e024e9e622
3 changed files with 60 additions and 0 deletions
@@ -113,6 +113,7 @@ class DumbProfileGenerator:
self.depth = 3
self.rotation = 0
self.location = Vector((0, 0, 0))
self.cardinal_point = int(bpy.context.scene.BIMModelProperties.cardinal_point)
return self.derive_from_cursor()
def derive_from_cursor(self):
@@ -141,6 +142,9 @@ class DumbProfileGenerator:
context=self.body_context,
)
ifcopenshell.api.run("type.assign_type", self.file, related_object=element, relating_type=self.relating_type)
material = ifcopenshell.util.element.get_material(element)
material.CardinalPoint = self.cardinal_point
if self.relating_type.is_a() in ["IfcBeamType", "IfcMemberType"]:
obj.rotation_euler[0] = math.pi / 2
obj.rotation_euler[2] = math.pi / 2
@@ -161,6 +165,7 @@ class DumbProfileGenerator:
tool.Ifc.get(),
context=self.body_context,
profile=self.profile_set.CompositeProfile or self.profile_set.MaterialProfiles[0].Profile,
cardinal_point=self.cardinal_point,
depth=self.depth,
)
ifcopenshell.api.run(
@@ -917,3 +922,27 @@ class ChangeProfileDepth(bpy.types.Operator):
for obj in context.selected_objects:
joiner.set_depth(obj, self.depth)
return {"FINISHED"}
class ChangeCardinalPoint(bpy.types.Operator):
bl_idname = "bim.change_cardinal_point"
bl_label = "Change Cardinal Point"
bl_options = {"REGISTER", "UNDO"}
cardinal_point: bpy.props.IntProperty()
@classmethod
def poll(cls, context):
return context.selected_objects
def execute(self, context):
objs = []
for obj in context.selected_objects:
element = tool.Ifc.get_entity(obj)
if not element:
continue
material = ifcopenshell.util.element.get_material(element, should_skip_usage=False)
if material.is_a("IfcMaterialProfileSetUsage"):
material.CardinalPoint = self.cardinal_point
objs.append(obj)
DumbProfileRecalculator().recalculate(objs)
return {"FINISHED"}
@@ -121,6 +121,32 @@ class BIMModelProperties(PropertyGroup):
occurrence_name_function: bpy.props.StringProperty(name="Occurrence Name Function")
getter_enum = {"ifc_class": get_ifc_class, "relating_type": get_relating_type}
extrusion_depth: bpy.props.FloatProperty(default=42.0)
cardinal_point: bpy.props.EnumProperty(
items=(
# TODO: complain to buildingSMART
("1", "bottom left", ""),
("2", "bottom centre", ""),
("3", "bottom right", ""),
("4", "mid-depth left", ""),
("5", "mid-depth centre", ""),
("6", "mid-depth right", ""),
("7", "top left", ""),
("8", "top centre", ""),
("9", "top right", ""),
("10", "geometric centroid", ""),
("11", "bottom in line with the geometric centroid", ""),
("12", "left in line with the geometric centroid", ""),
("13", "right in line with the geometric centroid", ""),
("14", "top in line with the geometric centroid", ""),
("15", "shear centre", ""),
("16", "bottom in line with the shear centre", ""),
("17", "left in line with the shear centre", ""),
("18", "right in line with the shear centre", ""),
("19", "top in line with the shear centre", ""),
),
name="Cardinal Point",
default="5",
)
length: bpy.props.FloatProperty(default=42.0)
@@ -179,6 +179,11 @@ class BimTool(WorkSpaceTool):
row.operator("bim.hotkey", text="Split").hotkey = "S_S"
if ifc_class in ("IfcColumnType", "IfcBeamType", "IfcMemberType"):
row = layout.row(align=True)
row.prop(data=props, property="cardinal_point", text="Axis")
op = row.operator("bim.change_cardinal_point", icon="FILE_REFRESH", text="")
op.cardinal_point = int(props.cardinal_point)
row = layout.row(align=True)
label = "Height" if ifc_class == "IfcColumnType" else "Length"
row.prop(data=props, property="extrusion_depth", text=label)