Merge branch 'v0.8.0' into ifcmax/initial-refresh

This commit is contained in:
Josef Wienerroither
2025-12-26 11:47:45 +01:00
8 changed files with 58 additions and 10 deletions
+1
View File
@@ -242,6 +242,7 @@ if(WITH_ROCKSDB)
# find it's zstd dependency on Windows.
# Only do it on Windows, otherwise it might create problems as
# findzstd and zstd-config target names do not match.
# https://github.com/facebook/rocksdb/pull/13975
if(WIN32)
set(TEMP CMAKE_FIND_PACKAGE_PREFER_CONFIG)
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)
+13
View File
@@ -19,7 +19,20 @@ find_dependency(Eigen3 CONFIG)
if(IFCOPENSHELL_WITH_ROCKSDB)
find_dependency(zstd CONFIG)
# Temporaily mess with CMAKE_FIND_PACKAGE_PREFER_CONFIG to help RocksDB
# find it's zstd dependency on Windows.
# Only do it on Windows, otherwise it might create problems as
# findzstd and zstd-config target names do not match.
# https://github.com/facebook/rocksdb/pull/13975
if(WIN32)
set(TEMP CMAKE_FIND_PACKAGE_PREFER_CONFIG)
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)
endif()
find_dependency(RocksDB CONFIG)
if(WIN32)
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ${TEMP})
endif()
endif()
if(IFCOPENSHELL_IFCXML)
+8
View File
@@ -290,6 +290,7 @@ class IfcImporter:
self.profile_code("Load linked models")
self.add_project_to_scene()
self.profile_code("Add project to scene")
self.hide_ifc_spaces()
if self.ifc_import_settings.should_clean_mesh and len(self.file.by_type("IfcElement")) < 1000:
self.clean_mesh()
self.profile_code("Mesh cleaning")
@@ -1286,6 +1287,13 @@ class IfcImporter:
properties={"Aggregate_Index": aggregate_index, "Name": name},
)
def hide_ifc_spaces(self):
"""Hide IfcSpace objects after they've been added to the scene."""
for ifc_definition_id, obj in self.added_data.items():
if isinstance(obj, bpy.types.Object):
element = self.file.by_id(ifc_definition_id)
if element.is_a("IfcSpace"):
obj.hide_set(True)
class IfcImportSettings:
"""
@@ -507,7 +507,7 @@ def ortho_view_frame(
def almost_zero(v):
return abs(v) < 1e-5
return abs(v) < 1e-4
def clip_segment(bounds, segm):
+6
View File
@@ -397,6 +397,12 @@ def update_drawing_name(
) -> None:
if drawing_tool.get_name(drawing) != name:
ifc.run("attribute.edit_attributes", product=drawing, attributes={"Name": name})
# Update the camera object name
camera = ifc.get_object(drawing)
if camera and camera.name != name:
camera.name = name
group = drawing_tool.get_drawing_group(drawing)
if drawing_tool.get_name(group) != name:
ifc.run("attribute.edit_attributes", product=group, attributes={"Name": name})
+23 -1
View File
@@ -18,6 +18,7 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Optional
import ifcopenshell.util.element
if TYPE_CHECKING:
import bpy
@@ -53,11 +54,32 @@ def copy_class(
geometry.copy_data_links(data, copied_entities)
geometry.change_object_data(obj, data, is_global=True)
geometry.rename_object(data, geometry.get_representation_name(ifc.get_entity(data)))
root.assign_body_styles(new, obj)
# Only assign styles if element doesn't get them from material
if not _has_material_styles(ifc, new):
root.assign_body_styles(new, obj)
collector.assign(obj)
return new
def _has_material_styles(ifc: type[tool.Ifc], element: ifcopenshell.entity_instance) -> bool:
"""Check if element has styles defined through its material.
Returns True if any constituent material has a style representation,
which means styles should NOT be applied directly to the geometry.
"""
materials = ifcopenshell.util.element.get_materials(element)
if not materials:
return False
# Check if any of the constituent materials have styles
for material in materials:
if hasattr(material, 'HasRepresentation') and material.HasRepresentation:
return True
return False
def assign_class(
ifc: type[tool.Ifc],
collector: type[tool.Collector],
+2 -4
View File
@@ -52,12 +52,12 @@ class Collector(bonsai.core.tool.Collector):
tool.Geometry.lock_object(obj)
element = (element.PartOfU or element.PartOfV or element.PartOfW)[0]
if not tool.Spatial.get_grid_props().is_visible:
obj.hide_viewport = True
obj.hide_set(True)
elif element.is_a("IfcGrid"):
if tool.Geometry.is_locked(element):
tool.Geometry.lock_object(obj)
if not tool.Spatial.get_grid_props().is_visible:
obj.hide_viewport = True
obj.hide_set(True)
if element.is_a("IfcProject"):
if tool.Geometry.is_locked(element):
@@ -73,8 +73,6 @@ class Collector(bonsai.core.tool.Collector):
tool.Geometry.lock_object(obj)
collection = cls._create_project_child_collection("IfcSpace")
cls.link_collection_object_safe(collection, obj)
if not tool.Spatial.get_spatial_props().is_visible:
obj.hide_viewport = True
elif element.is_a("IfcStructuralItem"):
collection = cls._create_project_child_collection("IfcStructuralItem")
cls.link_collection_object_safe(collection, obj)
+4 -4
View File
@@ -1213,18 +1213,18 @@ class Spatial(bonsai.core.tool.Spatial):
for element in elements:
if obj := tool.Ifc.get_object(element):
if obj.hide_viewport is True and is_visible:
obj.hide_viewport = False
obj.hide_set(False)
elif obj.hide_viewport is False and not is_visible:
obj.hide_viewport = True
obj.hide_set(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
obj.hide_set(False)
elif obj.hide_viewport is False and not is_visible:
obj.hide_viewport = True
obj.hide_set(True)
@classmethod
def toggle_spaces_visibility_wired_and_textured(cls, spaces: list[ifcopenshell.entity_instance]) -> None: