mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Fix #5701. Spaces are now invisible by default and use viewport hiding.
This commit is contained in:
@@ -1009,6 +1009,7 @@ class IfcImporter:
|
|||||||
)
|
)
|
||||||
obj = self.create_product(self.project["ifc"])
|
obj = self.create_product(self.project["ifc"])
|
||||||
obj.hide_select = True
|
obj.hide_select = True
|
||||||
|
obj.hide_viewport = True
|
||||||
self.project["blender"].objects.link(obj)
|
self.project["blender"].objects.link(obj)
|
||||||
self.project["blender"].BIMCollectionProperties.obj = obj
|
self.project["blender"].BIMCollectionProperties.obj = obj
|
||||||
props = tool.Blender.get_object_bim_props(obj)
|
props = tool.Blender.get_object_bim_props(obj)
|
||||||
|
|||||||
@@ -550,9 +550,7 @@ class ToggleGrids(bpy.types.Operator):
|
|||||||
is_visible: bpy.props.BoolProperty(name="Is Visible", default=False, options={"SKIP_SAVE"})
|
is_visible: bpy.props.BoolProperty(name="Is Visible", default=False, options={"SKIP_SAVE"})
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
for element in tool.Ifc.get().by_type("IfcGrid") + tool.Ifc.get().by_type("IfcGridAxis"):
|
tool.Spatial.set_grid_visibility(self.is_visible)
|
||||||
if obj := tool.Ifc.get_object(element):
|
|
||||||
obj.hide_set(not self.is_visible)
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
@@ -564,11 +562,5 @@ class ToggleSpatialElements(bpy.types.Operator):
|
|||||||
is_visible: bpy.props.BoolProperty(name="Is Visible", default=False, options={"SKIP_SAVE"})
|
is_visible: bpy.props.BoolProperty(name="Is Visible", default=False, options={"SKIP_SAVE"})
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
if tool.Ifc.get().schema == "IFC2X3":
|
tool.Spatial.set_space_visibility(self.is_visible)
|
||||||
elements = tool.Ifc.get().by_type("IfcSpatialStructureElement")
|
|
||||||
else:
|
|
||||||
elements = tool.Ifc.get().by_type("IfcSpatialElement")
|
|
||||||
for element in elements:
|
|
||||||
if obj := tool.Ifc.get_object(element):
|
|
||||||
obj.hide_set(not self.is_visible)
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ class BIMSpatialDecompositionProperties(PropertyGroup):
|
|||||||
is_visible: BoolProperty(
|
is_visible: BoolProperty(
|
||||||
name="Is Visible",
|
name="Is Visible",
|
||||||
description="Show or hide spatial elements, such as buildings, sites, etc",
|
description="Show or hide spatial elements, such as buildings, sites, etc",
|
||||||
default=True,
|
default=False,
|
||||||
update=update_spatial_is_visible,
|
update=update_spatial_is_visible,
|
||||||
)
|
)
|
||||||
container_filter: StringProperty(name="Container Filter", default="", options={"TEXTEDIT_UPDATE"})
|
container_filter: StringProperty(name="Container Filter", default="", options={"TEXTEDIT_UPDATE"})
|
||||||
|
|||||||
@@ -65,8 +65,11 @@ class Collector(bonsai.core.tool.Collector):
|
|||||||
collection = cls._create_project_child_collection("IfcTypeProduct")
|
collection = cls._create_project_child_collection("IfcTypeProduct")
|
||||||
cls.link_collection_object_safe(collection, obj)
|
cls.link_collection_object_safe(collection, obj)
|
||||||
elif element.is_a("IfcSpace"):
|
elif element.is_a("IfcSpace"):
|
||||||
|
if tool.Geometry.is_locked(element):
|
||||||
|
tool.Geometry.lock_object(obj)
|
||||||
collection = cls._create_project_child_collection("IfcSpace")
|
collection = cls._create_project_child_collection("IfcSpace")
|
||||||
cls.link_collection_object_safe(collection, obj)
|
cls.link_collection_object_safe(collection, obj)
|
||||||
|
obj.hide_viewport = True
|
||||||
elif element.is_a("IfcStructuralItem"):
|
elif element.is_a("IfcStructuralItem"):
|
||||||
collection = cls._create_project_child_collection("IfcStructuralItem")
|
collection = cls._create_project_child_collection("IfcStructuralItem")
|
||||||
cls.link_collection_object_safe(collection, obj)
|
cls.link_collection_object_safe(collection, obj)
|
||||||
@@ -90,6 +93,7 @@ class Collector(bonsai.core.tool.Collector):
|
|||||||
cls.link_collection_object_safe(collection, obj)
|
cls.link_collection_object_safe(collection, obj)
|
||||||
project_obj = tool.Ifc.get_object(tool.Ifc.get().by_type("IfcProject")[0])
|
project_obj = tool.Ifc.get_object(tool.Ifc.get().by_type("IfcProject")[0])
|
||||||
cls.link_collection_child_safe(tool.Blender.get_object_bim_props(project_obj).collection, collection)
|
cls.link_collection_child_safe(tool.Blender.get_object_bim_props(project_obj).collection, collection)
|
||||||
|
obj.hide_viewport = True
|
||||||
elif (
|
elif (
|
||||||
tool.Ifc.get_schema() != "IFC2X3"
|
tool.Ifc.get_schema() != "IFC2X3"
|
||||||
and element.is_a("IfcSpatialElement")
|
and element.is_a("IfcSpatialElement")
|
||||||
@@ -101,6 +105,7 @@ class Collector(bonsai.core.tool.Collector):
|
|||||||
cls.link_collection_object_safe(collection, obj)
|
cls.link_collection_object_safe(collection, obj)
|
||||||
project_obj = tool.Ifc.get_object(tool.Ifc.get().by_type("IfcProject")[0])
|
project_obj = tool.Ifc.get_object(tool.Ifc.get().by_type("IfcProject")[0])
|
||||||
cls.link_collection_child_safe(tool.Blender.get_object_bim_props(project_obj).collection, collection)
|
cls.link_collection_child_safe(tool.Blender.get_object_bim_props(project_obj).collection, collection)
|
||||||
|
obj.hide_viewport = True
|
||||||
elif element.is_a("IfcAnnotation") and element.ObjectType == "DRAWING":
|
elif element.is_a("IfcAnnotation") and element.ObjectType == "DRAWING":
|
||||||
if collection := cls._create_own_collection(obj):
|
if collection := cls._create_own_collection(obj):
|
||||||
cls.link_collection_object_safe(collection, obj)
|
cls.link_collection_object_safe(collection, obj)
|
||||||
|
|||||||
@@ -1203,6 +1203,28 @@ class Spatial(bonsai.core.tool.Spatial):
|
|||||||
should_sync_changes_first=False,
|
should_sync_changes_first=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def set_space_visibility(cls, is_visible: bool) -> None:
|
||||||
|
if tool.Ifc.get().schema == "IFC2X3":
|
||||||
|
elements = tool.Ifc.get().by_type("IfcSpatialStructureElement")
|
||||||
|
else:
|
||||||
|
elements = tool.Ifc.get().by_type("IfcSpatialElement")
|
||||||
|
for element in elements:
|
||||||
|
if obj := tool.Ifc.get_object(element):
|
||||||
|
if obj.hide_viewport is True and is_visible:
|
||||||
|
obj.hide_viewport = False
|
||||||
|
elif obj.hide_viewport is False and not is_visible:
|
||||||
|
obj.hide_viewport = True
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def set_grid_visibility(cls, is_visible: bool) -> None:
|
||||||
|
for element in tool.Ifc.get().by_type("IfcGrid") + tool.Ifc.get().by_type("IfcGridAxis"):
|
||||||
|
if obj := tool.Ifc.get_object(element):
|
||||||
|
if obj.hide_viewport is True and is_visible:
|
||||||
|
obj.hide_viewport = False
|
||||||
|
elif obj.hide_viewport is False and not is_visible:
|
||||||
|
obj.hide_viewport = True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def toggle_spaces_visibility_wired_and_textured(cls, spaces: list[ifcopenshell.entity_instance]) -> None:
|
def toggle_spaces_visibility_wired_and_textured(cls, spaces: list[ifcopenshell.entity_instance]) -> None:
|
||||||
first_obj = tool.Ifc.get_object(spaces[0])
|
first_obj = tool.Ifc.get_object(spaces[0])
|
||||||
|
|||||||
Reference in New Issue
Block a user