mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 18:21:59 +00:00
Errors adding roof, stair, railing types #5261
It wasn't considering that type object can be hidden and can't be active. Removed obj property since it can be covered with just temp_override.
This commit is contained in:
@@ -40,7 +40,8 @@ import json
|
|||||||
import collections
|
import collections
|
||||||
|
|
||||||
|
|
||||||
def update_door_modifier_representation(context: bpy.types.Context, obj: bpy.types.Object) -> None:
|
def update_door_modifier_representation(context: bpy.types.Context) -> None:
|
||||||
|
obj = context.active_object
|
||||||
props = obj.BIMDoorProperties
|
props = obj.BIMDoorProperties
|
||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
ifc_file = tool.Ifc.get()
|
ifc_file = tool.Ifc.get()
|
||||||
@@ -534,10 +535,9 @@ class AddDoor(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
bl_idname = "bim.add_door"
|
bl_idname = "bim.add_door"
|
||||||
bl_label = "Add Door"
|
bl_label = "Add Door"
|
||||||
bl_options = {"REGISTER"}
|
bl_options = {"REGISTER"}
|
||||||
obj: bpy.props.StringProperty()
|
|
||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object
|
obj = context.active_object
|
||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
props = obj.BIMDoorProperties
|
props = obj.BIMDoorProperties
|
||||||
|
|
||||||
@@ -558,7 +558,7 @@ class AddDoor(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
pset=pset,
|
pset=pset,
|
||||||
properties={"Data": tool.Ifc.get().createIfcText(json.dumps(door_data, default=list))},
|
properties={"Data": tool.Ifc.get().createIfcText(json.dumps(door_data, default=list))},
|
||||||
)
|
)
|
||||||
update_door_modifier_representation(context, obj)
|
update_door_modifier_representation(context)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
@@ -612,7 +612,7 @@ class FinishEditingDoor(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
|
|
||||||
props.is_editing = False
|
props.is_editing = False
|
||||||
|
|
||||||
update_door_modifier_representation(context, obj)
|
update_door_modifier_representation(context)
|
||||||
|
|
||||||
pset = tool.Pset.get_element_pset(element, "BBIM_Door")
|
pset = tool.Pset.get_element_pset(element, "BBIM_Door")
|
||||||
door_data = tool.Ifc.get().createIfcText(json.dumps(door_data, default=list))
|
door_data = tool.Ifc.get().createIfcText(json.dumps(door_data, default=list))
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ from bmesh.types import BMVert
|
|||||||
from mathutils import Vector
|
from mathutils import Vector
|
||||||
|
|
||||||
|
|
||||||
def update_window_modifier_representation(context, obj):
|
def update_window_modifier_representation(context):
|
||||||
|
obj = context.active_object
|
||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
props = obj.BIMWindowProperties
|
props = obj.BIMWindowProperties
|
||||||
ifc_file = tool.Ifc.get()
|
ifc_file = tool.Ifc.get()
|
||||||
@@ -427,10 +428,9 @@ class AddWindow(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
bl_idname = "bim.add_window"
|
bl_idname = "bim.add_window"
|
||||||
bl_label = "Add Window"
|
bl_label = "Add Window"
|
||||||
bl_options = {"REGISTER"}
|
bl_options = {"REGISTER"}
|
||||||
obj: bpy.props.StringProperty()
|
|
||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object
|
obj = context.active_object
|
||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
props = obj.BIMWindowProperties
|
props = obj.BIMWindowProperties
|
||||||
|
|
||||||
@@ -450,7 +450,7 @@ class AddWindow(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
pset=pset,
|
pset=pset,
|
||||||
properties={"Data": tool.Ifc.get().createIfcText(json.dumps(window_data, default=list))},
|
properties={"Data": tool.Ifc.get().createIfcText(json.dumps(window_data, default=list))},
|
||||||
)
|
)
|
||||||
update_window_modifier_representation(context, obj)
|
update_window_modifier_representation(context)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
@@ -502,7 +502,7 @@ class FinishEditingWindow(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
|
|
||||||
props.is_editing = False
|
props.is_editing = False
|
||||||
|
|
||||||
update_window_modifier_representation(context, obj)
|
update_window_modifier_representation(context)
|
||||||
|
|
||||||
pset = tool.Pset.get_element_pset(element, "BBIM_Window")
|
pset = tool.Pset.get_element_pset(element, "BBIM_Window")
|
||||||
window_data = tool.Ifc.get().createIfcText(json.dumps(window_data, default=list))
|
window_data = tool.Ifc.get().createIfcText(json.dumps(window_data, default=list))
|
||||||
|
|||||||
@@ -414,8 +414,8 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
ifc_class="IfcWindowType" if tool.Ifc.get_schema() != "IFC2X3" else "IfcWindowStyle",
|
ifc_class="IfcWindowType" if tool.Ifc.get_schema() != "IFC2X3" else "IfcWindowStyle",
|
||||||
should_add_representation=False,
|
should_add_representation=False,
|
||||||
)
|
)
|
||||||
tool.Blender.select_and_activate_single_object(context, obj)
|
with context.temp_override(active_object=obj):
|
||||||
bpy.ops.bim.add_window(obj=obj.name)
|
bpy.ops.bim.add_window()
|
||||||
|
|
||||||
elif template == "DOOR":
|
elif template == "DOOR":
|
||||||
mesh = bpy.data.meshes.new(name)
|
mesh = bpy.data.meshes.new(name)
|
||||||
@@ -429,8 +429,8 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
ifc_class="IfcDoorType" if tool.Ifc.get_schema() != "IFC2X3" else "IfcDoorStyle",
|
ifc_class="IfcDoorType" if tool.Ifc.get_schema() != "IFC2X3" else "IfcDoorStyle",
|
||||||
should_add_representation=False,
|
should_add_representation=False,
|
||||||
)
|
)
|
||||||
tool.Blender.select_and_activate_single_object(context, obj)
|
with context.temp_override(active_object=obj):
|
||||||
bpy.ops.bim.add_door(obj=obj.name)
|
bpy.ops.bim.add_door()
|
||||||
|
|
||||||
elif template == "STAIR":
|
elif template == "STAIR":
|
||||||
mesh = bpy.data.meshes.new(name)
|
mesh = bpy.data.meshes.new(name)
|
||||||
@@ -444,8 +444,8 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
ifc_class=ifc_class,
|
ifc_class=ifc_class,
|
||||||
should_add_representation=False,
|
should_add_representation=False,
|
||||||
)
|
)
|
||||||
tool.Blender.select_and_activate_single_object(context, obj)
|
with context.temp_override(active_object=obj):
|
||||||
bpy.ops.bim.add_stair()
|
bpy.ops.bim.add_stair()
|
||||||
|
|
||||||
elif template == "RAILING":
|
elif template == "RAILING":
|
||||||
mesh = bpy.data.meshes.new(name)
|
mesh = bpy.data.meshes.new(name)
|
||||||
@@ -460,8 +460,8 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
should_add_representation=True,
|
should_add_representation=True,
|
||||||
context=body,
|
context=body,
|
||||||
)
|
)
|
||||||
tool.Blender.select_and_activate_single_object(context, obj)
|
with context.temp_override(active_object=obj):
|
||||||
bpy.ops.bim.add_railing()
|
bpy.ops.bim.add_railing()
|
||||||
|
|
||||||
elif template == "ROOF":
|
elif template == "ROOF":
|
||||||
mesh = bpy.data.meshes.new(name)
|
mesh = bpy.data.meshes.new(name)
|
||||||
@@ -476,8 +476,8 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
should_add_representation=True,
|
should_add_representation=True,
|
||||||
context=body,
|
context=body,
|
||||||
)
|
)
|
||||||
tool.Blender.select_and_activate_single_object(context, obj)
|
with context.temp_override(active_object=obj):
|
||||||
bpy.ops.bim.add_roof()
|
bpy.ops.bim.add_roof()
|
||||||
|
|
||||||
bpy.ops.bim.load_type_thumbnails(ifc_class=ifc_class)
|
bpy.ops.bim.load_type_thumbnails(ifc_class=ifc_class)
|
||||||
props.type_class = props.type_class
|
props.type_class = props.type_class
|
||||||
|
|||||||
Reference in New Issue
Block a user