New toggle space visibility button

This commit is contained in:
Massimo Fabbro
2023-06-03 23:23:41 +02:00
parent bc76c8497e
commit 98ba75ef52
3 changed files with 35 additions and 0 deletions
@@ -97,6 +97,7 @@ classes = (
slab.SetArcIndex,
space.GenerateSpace,
space.GenerateSpacesFromWalls,
space.ToggleSpaceVisibility,
prop.BIMModelProperties,
prop.BIMArrayProperties,
prop.BIMStairProperties,
@@ -341,3 +341,35 @@ class GenerateSpacesFromWalls(bpy.types.Operator, tool.Ifc.Operator):
aux_vector = aux_vector - diff
vert.co = inverted @ aux_vector
obj.location = newLoc
class ToggleSpaceVisibility(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.toggle_space_visibility"
bl_label = "Toggle Space Visibility"
bl_options = {"REGISTER"}
bl_description = "Change the space visibility"
def execute(cls, context):
model = tool.Ifc.get()
spaces = model.by_type('IfcSpace')
if not spaces:
print(spaces)
return {"FINISHED"}
first_obj = tool.Ifc.get_object(spaces[0])
if bpy.data.objects[first_obj.name].display_type == 'TEXTURED':
for space in spaces:
obj = tool.Ifc.get_object(space)
bpy.data.objects[obj.name].show_wire = True
bpy.data.objects[obj.name].display_type = 'WIRE'
return {"FINISHED"}
elif bpy.data.objects[first_obj.name].display_type == 'WIRE':
for space in spaces:
obj = tool.Ifc.get_object(space)
bpy.data.objects[obj.name].show_wire = False
bpy.data.objects[obj.name].display_type = 'TEXTURED'
return {"FINISHED"}
@@ -135,6 +135,8 @@ class BIM_PT_authoring(Panel):
row.operator("bim.generate_space")
row = self.layout.row(align=True)
row.operator("bim.generate_spaces_from_walls")
row = self.layout.row(align=True)
row.operator("bim.toggle_space_visibility")
class BIM_PT_GridsSpatialManager(Panel):