mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 02:31:09 +00:00
You can now set cardinal point on creation and bulk change for profile elements
This commit is contained in:
@@ -113,6 +113,7 @@ class DumbProfileGenerator:
|
|||||||
self.depth = 3
|
self.depth = 3
|
||||||
self.rotation = 0
|
self.rotation = 0
|
||||||
self.location = Vector((0, 0, 0))
|
self.location = Vector((0, 0, 0))
|
||||||
|
self.cardinal_point = int(bpy.context.scene.BIMModelProperties.cardinal_point)
|
||||||
return self.derive_from_cursor()
|
return self.derive_from_cursor()
|
||||||
|
|
||||||
def derive_from_cursor(self):
|
def derive_from_cursor(self):
|
||||||
@@ -141,6 +142,9 @@ class DumbProfileGenerator:
|
|||||||
context=self.body_context,
|
context=self.body_context,
|
||||||
)
|
)
|
||||||
ifcopenshell.api.run("type.assign_type", self.file, related_object=element, relating_type=self.relating_type)
|
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"]:
|
if self.relating_type.is_a() in ["IfcBeamType", "IfcMemberType"]:
|
||||||
obj.rotation_euler[0] = math.pi / 2
|
obj.rotation_euler[0] = math.pi / 2
|
||||||
obj.rotation_euler[2] = math.pi / 2
|
obj.rotation_euler[2] = math.pi / 2
|
||||||
@@ -161,6 +165,7 @@ class DumbProfileGenerator:
|
|||||||
tool.Ifc.get(),
|
tool.Ifc.get(),
|
||||||
context=self.body_context,
|
context=self.body_context,
|
||||||
profile=self.profile_set.CompositeProfile or self.profile_set.MaterialProfiles[0].Profile,
|
profile=self.profile_set.CompositeProfile or self.profile_set.MaterialProfiles[0].Profile,
|
||||||
|
cardinal_point=self.cardinal_point,
|
||||||
depth=self.depth,
|
depth=self.depth,
|
||||||
)
|
)
|
||||||
ifcopenshell.api.run(
|
ifcopenshell.api.run(
|
||||||
@@ -917,3 +922,27 @@ class ChangeProfileDepth(bpy.types.Operator):
|
|||||||
for obj in context.selected_objects:
|
for obj in context.selected_objects:
|
||||||
joiner.set_depth(obj, self.depth)
|
joiner.set_depth(obj, self.depth)
|
||||||
return {"FINISHED"}
|
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")
|
occurrence_name_function: bpy.props.StringProperty(name="Occurrence Name Function")
|
||||||
getter_enum = {"ifc_class": get_ifc_class, "relating_type": get_relating_type}
|
getter_enum = {"ifc_class": get_ifc_class, "relating_type": get_relating_type}
|
||||||
extrusion_depth: bpy.props.FloatProperty(default=42.0)
|
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)
|
length: bpy.props.FloatProperty(default=42.0)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -179,6 +179,11 @@ class BimTool(WorkSpaceTool):
|
|||||||
row.operator("bim.hotkey", text="Split").hotkey = "S_S"
|
row.operator("bim.hotkey", text="Split").hotkey = "S_S"
|
||||||
|
|
||||||
if ifc_class in ("IfcColumnType", "IfcBeamType", "IfcMemberType"):
|
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)
|
row = layout.row(align=True)
|
||||||
label = "Height" if ifc_class == "IfcColumnType" else "Length"
|
label = "Height" if ifc_class == "IfcColumnType" else "Length"
|
||||||
row.prop(data=props, property="extrusion_depth", text=label)
|
row.prop(data=props, property="extrusion_depth", text=label)
|
||||||
|
|||||||
Reference in New Issue
Block a user