mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-24 18:20:06 +00:00
You can now toggle visibility and wireframe modes of linked models and fix bug where links with the same name were not unique
This commit is contained in:
@@ -708,7 +708,7 @@ class LoadLink(bpy.types.Operator):
|
|||||||
continue
|
continue
|
||||||
bpy.data.scenes[0].collection.children.link(child)
|
bpy.data.scenes[0].collection.children.link(child)
|
||||||
link = context.scene.BIMProjectProperties.links.get(filepath)
|
link = context.scene.BIMProjectProperties.links.get(filepath)
|
||||||
link.collection_name = child.name
|
link.collection = child
|
||||||
link.is_loaded = True
|
link.is_loaded = True
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
@@ -718,11 +718,20 @@ class ToggleLinkVisibility(bpy.types.Operator):
|
|||||||
bl_label = "Toggle Link Visibility"
|
bl_label = "Toggle Link Visibility"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
bl_description = "Toggle visibility between SOLID and WIREFRAME"
|
bl_description = "Toggle visibility between SOLID and WIREFRAME"
|
||||||
collection_name: bpy.props.StringProperty()
|
link: bpy.props.StringProperty()
|
||||||
|
mode: bpy.props.StringProperty()
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
collection_name = self.collection_name
|
props = context.scene.BIMProjectProperties
|
||||||
objs = filter(lambda obj: "IfcOpeningElement" not in obj.name, bpy.data.collections[collection_name].all_objects)
|
link = props.links.get(self.link)
|
||||||
|
if self.mode == "WIREFRAME":
|
||||||
|
self.toggle_wireframe(link)
|
||||||
|
elif self.mode == "VISIBLE":
|
||||||
|
self.toggle_visibility(link)
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
def toggle_wireframe(self, link):
|
||||||
|
objs = filter(lambda obj: "IfcOpeningElement" not in obj.name, link.collection.all_objects)
|
||||||
for i,obj in enumerate(objs):
|
for i,obj in enumerate(objs):
|
||||||
if i == 0:
|
if i == 0:
|
||||||
if obj.display_type == "WIRE":
|
if obj.display_type == "WIRE":
|
||||||
@@ -730,7 +739,22 @@ class ToggleLinkVisibility(bpy.types.Operator):
|
|||||||
else:
|
else:
|
||||||
display_type = "WIRE"
|
display_type = "WIRE"
|
||||||
obj.display_type = display_type
|
obj.display_type = display_type
|
||||||
return {"FINISHED"}
|
link.is_wireframe = display_type == "WIRE"
|
||||||
|
|
||||||
|
def toggle_visibility(self, link):
|
||||||
|
queue = [bpy.context.view_layer.layer_collection]
|
||||||
|
layer_collection = None
|
||||||
|
|
||||||
|
while queue:
|
||||||
|
layer = queue.pop()
|
||||||
|
if layer.collection == link.collection:
|
||||||
|
layer_collection = layer
|
||||||
|
break
|
||||||
|
queue.extend(list(layer.children))
|
||||||
|
|
||||||
|
if layer_collection:
|
||||||
|
layer_collection.exclude = not layer_collection.exclude
|
||||||
|
link.is_hidden = layer_collection.exclude
|
||||||
|
|
||||||
|
|
||||||
class ExportIFC(bpy.types.Operator):
|
class ExportIFC(bpy.types.Operator):
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ from blenderbim.bim.ifc import IfcStore
|
|||||||
from blenderbim.bim.prop import StrProperty
|
from blenderbim.bim.prop import StrProperty
|
||||||
from bpy.types import PropertyGroup
|
from bpy.types import PropertyGroup
|
||||||
from bpy.props import (
|
from bpy.props import (
|
||||||
|
PointerProperty,
|
||||||
BoolProperty,
|
BoolProperty,
|
||||||
CollectionProperty,
|
CollectionProperty,
|
||||||
EnumProperty,
|
EnumProperty,
|
||||||
@@ -91,8 +92,10 @@ class FilterCategory(PropertyGroup):
|
|||||||
|
|
||||||
class Link(PropertyGroup):
|
class Link(PropertyGroup):
|
||||||
name: StringProperty(name="Name")
|
name: StringProperty(name="Name")
|
||||||
collection_name: StringProperty(name="Collection Name")
|
collection: PointerProperty(name="Collection", type=bpy.types.Collection)
|
||||||
is_loaded: BoolProperty(name="Is Loaded", default=False)
|
is_loaded: BoolProperty(name="Is Loaded", default=False)
|
||||||
|
is_wireframe: BoolProperty(name="Is Wireframe", default=False)
|
||||||
|
is_hidden: BoolProperty(name="Is Hidden", default=False)
|
||||||
|
|
||||||
|
|
||||||
class BIMProjectProperties(PropertyGroup):
|
class BIMProjectProperties(PropertyGroup):
|
||||||
|
|||||||
@@ -302,8 +302,22 @@ class BIM_UL_links(UIList):
|
|||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
if item.is_loaded:
|
if item.is_loaded:
|
||||||
row.label(text=item.name)
|
row.label(text=item.name)
|
||||||
op = row.operator("bim.toggle_link_visibility", text="", icon="HIDE_OFF")
|
op = row.operator(
|
||||||
op.collection_name = item.collection_name
|
"bim.toggle_link_visibility",
|
||||||
|
text="",
|
||||||
|
icon="CUBE" if item.is_wireframe else "MESH_CUBE",
|
||||||
|
emboss=False,
|
||||||
|
)
|
||||||
|
op.link = item.name
|
||||||
|
op.mode = "WIREFRAME"
|
||||||
|
op = row.operator(
|
||||||
|
"bim.toggle_link_visibility",
|
||||||
|
text="",
|
||||||
|
icon="HIDE_ON" if item.is_hidden else "HIDE_OFF",
|
||||||
|
emboss=False,
|
||||||
|
)
|
||||||
|
op.link = item.name
|
||||||
|
op.mode = "VISIBLE"
|
||||||
op = row.operator("bim.unload_link", text="", icon="UNLINKED")
|
op = row.operator("bim.unload_link", text="", icon="UNLINKED")
|
||||||
op.filepath = item.name
|
op.filepath = item.name
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ class Project(blenderbim.core.tool.Project):
|
|||||||
|
|
||||||
while queue:
|
while queue:
|
||||||
layer = queue.pop()
|
layer = queue.pop()
|
||||||
if layer.name == collection.name:
|
if layer.collection == collection:
|
||||||
layer_collection = layer
|
layer_collection = layer
|
||||||
break
|
break
|
||||||
queue.extend(list(layer.children))
|
queue.extend(list(layer.children))
|
||||||
|
|||||||
Reference in New Issue
Block a user