Skip to content

Commit

Permalink
add feature to toggle wireframe visibility for linked models - no tes…
Browse files Browse the repository at this point in the history
…tcases
  • Loading branch information
Jesusbill committed Apr 13, 2022
1 parent c099a6c commit 4aa91cf
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/blenderbim/blenderbim/bim/module/project/__init__.py
Expand Up @@ -28,6 +28,7 @@
operator.UnlinkIfc,
operator.UnloadLink,
operator.LoadLink,
operator.ToggleLinkVisibility,
operator.SelectLibraryFile,
operator.ChangeLibraryElement,
operator.RefreshLibrary,
Expand Down
21 changes: 21 additions & 0 deletions src/blenderbim/blenderbim/bim/module/project/operator.py
Expand Up @@ -685,10 +685,31 @@ def execute(self, context):
continue
bpy.data.scenes[0].collection.children.link(child)
link = context.scene.BIMProjectProperties.links.get(filepath)
link.collection_name = child.name
link.is_loaded = True
return {"FINISHED"}


class ToggleLinkVisibility(bpy.types.Operator):
bl_idname = "bim.toggle_link_visibility"
bl_label = "Toggle Link Visibility"
bl_options = {"REGISTER", "UNDO"}
bl_description = "Toggle visibility between SOLID and WIREFRAME"
collection_name: bpy.props.StringProperty()

def execute(self, context):
collection_name = self.collection_name
objs = filter(lambda obj: "IfcOpeningElement" not in obj.name, bpy.data.collections[collection_name].all_objects)
for i,obj in enumerate(objs):
if i == 0:
if obj.display_type == "WIRE":
display_type = "TEXTURED"
else:
display_type = "WIRE"
obj.display_type = display_type
return {"FINISHED"}


class ExportIFC(bpy.types.Operator):
bl_idname = "export_ifc.bim"
bl_label = "Export IFC"
Expand Down
1 change: 1 addition & 0 deletions src/blenderbim/blenderbim/bim/module/project/prop.py
Expand Up @@ -85,6 +85,7 @@ class FilterCategory(PropertyGroup):

class Link(PropertyGroup):
name: StringProperty(name="Name")
collection_name: StringProperty(name="Collection Name")
is_loaded: BoolProperty(name="Is Loaded", default=False)


Expand Down
2 changes: 2 additions & 0 deletions src/blenderbim/blenderbim/bim/module/project/ui.py
Expand Up @@ -286,6 +286,8 @@ def draw_item(self, context, layout, data, item, icon, active_data, active_propn
row = layout.row(align=True)
if item.is_loaded:
row.label(text=item.name)
op = row.operator("bim.toggle_link_visibility", text="", icon="HIDE_OFF")
op.collection_name = item.collection_name
op = row.operator("bim.unload_link", text="", icon="UNLINKED")
op.filepath = item.name
else:
Expand Down

0 comments on commit 4aa91cf

Please sign in to comment.