mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
support adding parametric roof to object without representations
This commit is contained in:
@@ -428,12 +428,12 @@ def update_bbim_roof_pset(element: ifcopenshell.entity_instance, roof_data: dict
|
|||||||
ifcopenshell.api.run("pset.edit_pset", tool.Ifc.get(), pset=pset, properties={"Data": roof_data})
|
ifcopenshell.api.run("pset.edit_pset", tool.Ifc.get(), pset=pset, properties={"Data": roof_data})
|
||||||
|
|
||||||
|
|
||||||
def update_roof_modifier_bmesh(context: bpy.types.Context) -> None:
|
def update_roof_modifier_bmesh(obj: bpy.types.Object) -> None:
|
||||||
"""before using should make sure that Data contains up-to-date information.
|
"""before using should make sure that Data contains up-to-date information.
|
||||||
If BBIM Pset just changed should call refresh() before updating bmesh
|
If BBIM Pset just changed should call refresh() before updating bmesh
|
||||||
"""
|
"""
|
||||||
obj = context.active_object
|
|
||||||
props = obj.BIMRoofProperties
|
props = obj.BIMRoofProperties
|
||||||
|
assert isinstance(obj.data, bpy.types.Mesh)
|
||||||
|
|
||||||
# NOTE: using Data since bmesh update will hapen very often
|
# NOTE: using Data since bmesh update will hapen very often
|
||||||
if not RoofData.is_loaded:
|
if not RoofData.is_loaded:
|
||||||
@@ -555,6 +555,7 @@ class AddRoof(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
obj = context.active_object
|
obj = context.active_object
|
||||||
|
assert obj
|
||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
props = obj.BIMRoofProperties
|
props = obj.BIMRoofProperties
|
||||||
si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||||
@@ -587,7 +588,12 @@ class AddRoof(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
|
|
||||||
update_bbim_roof_pset(element, roof_data)
|
update_bbim_roof_pset(element, roof_data)
|
||||||
refresh()
|
refresh()
|
||||||
update_roof_modifier_bmesh(context)
|
|
||||||
|
if obj.type == "EMPTY":
|
||||||
|
obj = tool.Geometry.recreate_object_with_data(obj, data=bpy.data.meshes.new("temp"), is_global=True)
|
||||||
|
tool.Blender.set_active_object(obj)
|
||||||
|
|
||||||
|
update_roof_modifier_bmesh(obj)
|
||||||
update_roof_modifier_ifc_data(context)
|
update_roof_modifier_ifc_data(context)
|
||||||
tool.Model.add_body_representation(obj)
|
tool.Model.add_body_representation(obj)
|
||||||
|
|
||||||
@@ -614,12 +620,13 @@ class CancelEditingRoof(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
obj = context.active_object
|
obj = context.active_object
|
||||||
|
assert obj
|
||||||
data = tool.Model.get_modeling_bbim_pset_data(obj, "BBIM_Roof")["data_dict"]
|
data = tool.Model.get_modeling_bbim_pset_data(obj, "BBIM_Roof")["data_dict"]
|
||||||
props = obj.BIMRoofProperties
|
props = obj.BIMRoofProperties
|
||||||
|
|
||||||
# restore previous settings since editing was canceled
|
# restore previous settings since editing was canceled
|
||||||
props.set_props_kwargs_from_ifc_data(data)
|
props.set_props_kwargs_from_ifc_data(data)
|
||||||
update_roof_modifier_bmesh(context)
|
update_roof_modifier_bmesh(obj)
|
||||||
|
|
||||||
props.is_editing = False
|
props.is_editing = False
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
@@ -655,6 +662,7 @@ class EnableEditingRoofPath(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
obj = context.active_object
|
obj = context.active_object
|
||||||
|
assert obj
|
||||||
[o.select_set(False) for o in context.selected_objects if o != obj]
|
[o.select_set(False) for o in context.selected_objects if o != obj]
|
||||||
props = obj.BIMRoofProperties
|
props = obj.BIMRoofProperties
|
||||||
data = tool.Model.get_modeling_bbim_pset_data(obj, "BBIM_Roof")["data_dict"]
|
data = tool.Model.get_modeling_bbim_pset_data(obj, "BBIM_Roof")["data_dict"]
|
||||||
@@ -662,7 +670,7 @@ class EnableEditingRoofPath(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
props.set_props_kwargs_from_ifc_data(data)
|
props.set_props_kwargs_from_ifc_data(data)
|
||||||
|
|
||||||
props.is_editing_path = True
|
props.is_editing_path = True
|
||||||
update_roof_modifier_bmesh(context)
|
update_roof_modifier_bmesh(obj)
|
||||||
|
|
||||||
if bpy.context.active_object.mode != "EDIT":
|
if bpy.context.active_object.mode != "EDIT":
|
||||||
bpy.ops.object.mode_set(mode="EDIT")
|
bpy.ops.object.mode_set(mode="EDIT")
|
||||||
@@ -710,13 +718,14 @@ class EnableEditingRoofPath(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
|
|
||||||
def cancel_editing_roof_path(context: bpy.types.Context) -> set[str]:
|
def cancel_editing_roof_path(context: bpy.types.Context) -> set[str]:
|
||||||
obj = context.active_object
|
obj = context.active_object
|
||||||
|
assert obj
|
||||||
props = obj.BIMRoofProperties
|
props = obj.BIMRoofProperties
|
||||||
|
|
||||||
ProfileDecorator.uninstall()
|
ProfileDecorator.uninstall()
|
||||||
props.is_editing_path = False
|
props.is_editing_path = False
|
||||||
|
|
||||||
update_roof_modifier_bmesh(context)
|
update_roof_modifier_bmesh(obj)
|
||||||
if bpy.context.active_object.mode == "EDIT":
|
if obj.mode == "EDIT":
|
||||||
bpy.ops.object.mode_set(mode="OBJECT")
|
bpy.ops.object.mode_set(mode="OBJECT")
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|||||||
@@ -630,7 +630,9 @@ class BIM_PT_roof(bpy.types.Panel):
|
|||||||
if not RoofData.is_loaded:
|
if not RoofData.is_loaded:
|
||||||
RoofData.load()
|
RoofData.load()
|
||||||
|
|
||||||
props = context.active_object.BIMRoofProperties
|
obj = context.active_object
|
||||||
|
assert obj
|
||||||
|
props = obj.BIMRoofProperties
|
||||||
|
|
||||||
if RoofData.data["pset_data"]:
|
if RoofData.data["pset_data"]:
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
@@ -645,7 +647,7 @@ class BIM_PT_roof(bpy.types.Panel):
|
|||||||
for prop in general_props:
|
for prop in general_props:
|
||||||
self.layout.prop(props, prop)
|
self.layout.prop(props, prop)
|
||||||
|
|
||||||
update_roof_modifier_bmesh(context)
|
update_roof_modifier_bmesh(obj)
|
||||||
|
|
||||||
elif props.is_editing_path:
|
elif props.is_editing_path:
|
||||||
row.operator("bim.finish_editing_roof_path", icon="CHECKMARK", text="")
|
row.operator("bim.finish_editing_roof_path", icon="CHECKMARK", text="")
|
||||||
|
|||||||
Reference in New Issue
Block a user