mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +00:00
Fixing railing/roof bug #3416
Issue occured when you imported .ifc and then would try to edit roof/railing path and then cancel/finish editing. Added safe check to avoid using `change_object_data` in edit mode - https://projects.blender.org/blender/blender/issues/110232
This commit is contained in:
@@ -348,8 +348,7 @@ class EnableEditingRailing(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
obj = context.active_object
|
obj = context.active_object
|
||||||
props = obj.BIMRailingProperties
|
props = obj.BIMRailingProperties
|
||||||
element = tool.Ifc.get_entity(obj)
|
data = tool.Model.get_modeling_bbim_pset_data(obj, "BBIM_Railing")["data_dict"]
|
||||||
data = json.loads(ifcopenshell.util.element.get_pset(element, "BBIM_Railing", "Data"))
|
|
||||||
data["path_data"] = json.dumps(data["path_data"])
|
data["path_data"] = json.dumps(data["path_data"])
|
||||||
|
|
||||||
# required since we could load pset from .ifc and BIMRailingProperties won't be set
|
# required since we could load pset from .ifc and BIMRailingProperties won't be set
|
||||||
@@ -366,8 +365,7 @@ class CancelEditingRailing(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
obj = context.active_object
|
obj = context.active_object
|
||||||
element = tool.Ifc.get_entity(obj)
|
data = tool.Model.get_modeling_bbim_pset_data(obj, "BBIM_Railing")["data_dict"]
|
||||||
data = json.loads(ifcopenshell.util.element.get_pset(element, "BBIM_Railing", "Data"))
|
|
||||||
props = obj.BIMRailingProperties
|
props = obj.BIMRailingProperties
|
||||||
|
|
||||||
# restore previous settings since editing was canceled
|
# restore previous settings since editing was canceled
|
||||||
@@ -438,6 +436,9 @@ class EnableEditingRailingPath(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
obj = context.active_object
|
obj = context.active_object
|
||||||
props = obj.BIMRailingProperties
|
props = obj.BIMRailingProperties
|
||||||
|
data = tool.Model.get_modeling_bbim_pset_data(obj, "BBIM_Railing")["data_dict"]
|
||||||
|
# required since we could load pset from .ifc and BIMRoofProperties won't be set
|
||||||
|
props.set_props_kwargs_from_ifc_data(data)
|
||||||
|
|
||||||
props.is_editing_path = True
|
props.is_editing_path = True
|
||||||
update_railing_modifier_bmesh(context)
|
update_railing_modifier_bmesh(context)
|
||||||
@@ -456,9 +457,24 @@ def cancel_editing_railing_path(context):
|
|||||||
ProfileDecorator.uninstall()
|
ProfileDecorator.uninstall()
|
||||||
props.is_editing_path = False
|
props.is_editing_path = False
|
||||||
|
|
||||||
update_railing_modifier_bmesh(context)
|
|
||||||
if bpy.context.active_object.mode == "EDIT":
|
if bpy.context.active_object.mode == "EDIT":
|
||||||
bpy.ops.object.mode_set(mode="OBJECT")
|
bpy.ops.object.mode_set(mode="OBJECT")
|
||||||
|
|
||||||
|
if props.railing_type == "FRAMELESS_PANEL":
|
||||||
|
update_railing_modifier_bmesh(context)
|
||||||
|
else:
|
||||||
|
element = tool.Ifc.get_entity(obj)
|
||||||
|
body = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
|
||||||
|
blenderbim.core.geometry.switch_representation(
|
||||||
|
tool.Ifc,
|
||||||
|
tool.Geometry,
|
||||||
|
obj=obj,
|
||||||
|
representation=body,
|
||||||
|
should_reload=True,
|
||||||
|
is_global=True,
|
||||||
|
should_sync_changes_first=False,
|
||||||
|
)
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -593,8 +593,7 @@ class EnableEditingRoof(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
obj = context.active_object
|
obj = context.active_object
|
||||||
props = obj.BIMRoofProperties
|
props = obj.BIMRoofProperties
|
||||||
element = tool.Ifc.get_entity(obj)
|
data = tool.Model.get_modeling_bbim_pset_data(obj, "BBIM_Roof")["data_dict"]
|
||||||
data = json.loads(ifcopenshell.util.element.get_pset(element, "BBIM_Roof", "Data"))
|
|
||||||
# required since we could load pset from .ifc and BIMRoofProperties won't be set
|
# required since we could load pset from .ifc and BIMRoofProperties won't be set
|
||||||
props.set_props_kwargs_from_ifc_data(data)
|
props.set_props_kwargs_from_ifc_data(data)
|
||||||
props.is_editing = True
|
props.is_editing = True
|
||||||
@@ -608,8 +607,7 @@ class CancelEditingRoof(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
obj = context.active_object
|
obj = context.active_object
|
||||||
element = tool.Ifc.get_entity(obj)
|
data = tool.Model.get_modeling_bbim_pset_data(obj, "BBIM_Roof")["data_dict"]
|
||||||
data = json.loads(ifcopenshell.util.element.get_pset(element, "BBIM_Roof", "Data"))
|
|
||||||
props = obj.BIMRoofProperties
|
props = obj.BIMRoofProperties
|
||||||
|
|
||||||
# restore previous settings since editing was canceled
|
# restore previous settings since editing was canceled
|
||||||
@@ -650,6 +648,9 @@ class EnableEditingRoofPath(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
obj = context.active_object
|
obj = context.active_object
|
||||||
props = obj.BIMRoofProperties
|
props = obj.BIMRoofProperties
|
||||||
|
data = tool.Model.get_modeling_bbim_pset_data(obj, "BBIM_Roof")["data_dict"]
|
||||||
|
# required since we could load pset from .ifc and BIMRoofProperties won't be set
|
||||||
|
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(context)
|
||||||
|
|||||||
@@ -88,7 +88,15 @@ def switch_representation(
|
|||||||
should_sync_changes_first=False,
|
should_sync_changes_first=False,
|
||||||
apply_openings=True,
|
apply_openings=True,
|
||||||
):
|
):
|
||||||
"""Function can switch to representation that wasn't yet assigned to that object. See #2766."""
|
"""Function can switch to representation that wasn't yet assigned to that object. See #2766.
|
||||||
|
|
||||||
|
`should_sync_changes_first` - sync ifc representation with current state of `obj.data`;
|
||||||
|
|
||||||
|
`should_reload` - reload `obj.data` from ifc representation;
|
||||||
|
|
||||||
|
`is_global` - replace mesh data for all users of `obj.data`, not just `obj`;
|
||||||
|
|
||||||
|
"""
|
||||||
if should_sync_changes_first and geometry.is_edited(obj) and not geometry.is_box_representation(representation):
|
if should_sync_changes_first and geometry.is_edited(obj) and not geometry.is_box_representation(representation):
|
||||||
representation_id = geometry.get_representation_id(representation)
|
representation_id = geometry.get_representation_id(representation)
|
||||||
geometry.run_geometry_update_representation(obj=obj)
|
geometry.run_geometry_update_representation(obj=obj)
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ class Geometry(blenderbim.core.tool.Geometry):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def change_object_data(cls, obj, data, is_global=False):
|
def change_object_data(cls, obj, data, is_global=False):
|
||||||
if is_global:
|
if is_global:
|
||||||
|
if obj.mode == "EDIT":
|
||||||
|
raise Exception("user_remap is not supported in EDIT mode")
|
||||||
obj.data.user_remap(data)
|
obj.data.user_remap(data)
|
||||||
else:
|
else:
|
||||||
obj.data = data
|
obj.data = data
|
||||||
|
|||||||
Reference in New Issue
Block a user