bonsai other ifcopenshell packages #5178

This commit is contained in:
Andrej730
2024-08-14 14:09:45 +05:00
committed by Andrej
parent 5784e3103d
commit 3860884db3
14 changed files with 26 additions and 26 deletions
+2 -2
View File
@@ -288,8 +288,8 @@ class Blender:
def calculate( def calculate(
ifc_file: ifcopenshell.file, elements: set[ifcopenshell.entity_instance], qtos: dict, results: dict ifc_file: ifcopenshell.file, elements: set[ifcopenshell.entity_instance], qtos: dict, results: dict
) -> None: ) -> None:
import blenderbim.tool as tool import bonsai.tool as tool
import blenderbim.bim.module.qto.calculator as calculator import bonsai.bim.module.qto.calculator as calculator
unit_converter = SI2ProjectUnitConverter(ifc_file) unit_converter = SI2ProjectUnitConverter(ifc_file)
formula_functions = {} formula_functions = {}
@@ -24,7 +24,7 @@ from mathutils import Vector, Matrix
from typing import Union, Optional, Literal, Any, TYPE_CHECKING from typing import Union, Optional, Literal, Any, TYPE_CHECKING
if TYPE_CHECKING: if TYPE_CHECKING:
from blenderbim.bim.module.geometry.helper import Helper from bonsai.bim.module.geometry.helper import Helper
Z_AXIS = Vector((0, 0, 1)) Z_AXIS = Vector((0, 0, 1))
@@ -72,7 +72,7 @@ def add_representation(
) -> ifcopenshell.entity_instance: ) -> ifcopenshell.entity_instance:
# lazy import Helper to avoid circular import # lazy import Helper to avoid circular import
if "Helper" not in globals(): if "Helper" not in globals():
from blenderbim.bim.module.geometry.helper import Helper from bonsai.bim.module.geometry.helper import Helper
globals()["Helper"] = Helper globals()["Helper"] = Helper
@@ -460,7 +460,7 @@ class Usecase:
return results return results
def is_mesh_curve_consecutive(self, geom_data): def is_mesh_curve_consecutive(self, geom_data):
import blenderbim.tool as tool import bonsai.tool as tool
bm = tool.Blender.get_bmesh_for_mesh(geom_data) bm = tool.Blender.get_bmesh_for_mesh(geom_data)
bm.verts.ensure_lookup_table() bm.verts.ensure_lookup_table()
@@ -514,7 +514,7 @@ class Usecase:
return self.create_curves_from_mesh_ifc2x3(should_exclude_faces=should_exclude_faces, is_2d=is_2d) return self.create_curves_from_mesh_ifc2x3(should_exclude_faces=should_exclude_faces, is_2d=is_2d)
return self.create_curves_from_mesh(should_exclude_faces=should_exclude_faces, is_2d=is_2d) return self.create_curves_from_mesh(should_exclude_faces=should_exclude_faces, is_2d=is_2d)
import blenderbim.tool as tool import bonsai.tool as tool
selected_objects = bpy.context.selected_objects selected_objects = bpy.context.selected_objects
active_object = bpy.context.active_object active_object = bpy.context.active_object
@@ -568,7 +568,7 @@ class Usecase:
return curves return curves
def remove_doubles_from_mesh(self, mesh): def remove_doubles_from_mesh(self, mesh):
import blenderbim.tool as tool import bonsai.tool as tool
bm = tool.Blender.get_bmesh_for_mesh(mesh) bm = tool.Blender.get_bmesh_for_mesh(mesh)
bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=0.0001) bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=0.0001)
@@ -31,7 +31,7 @@ def edit_georeferencing(
Setting the correct georeferencing parameters is a complex topic and Setting the correct georeferencing parameters is a complex topic and
should ideally be done with three parties present: the lead architect, should ideally be done with three parties present: the lead architect,
surveyor, and a third-party digital engineer with expertise in IFC to surveyor, and a third-party digital engineer with expertise in IFC to
moderate. For more information, read the BlenderBIM Add-on documentation moderate. For more information, read the Bonsai documentation
for Georeferencing: for Georeferencing:
https://docs.bonsaibim.org/users/advanced/georeferencing.html https://docs.bonsaibim.org/users/advanced/georeferencing.html
@@ -63,7 +63,7 @@ def edit_georeferencing(
# For buildings, it is almost always recommended to specify map # For buildings, it is almost always recommended to specify map
# conversion parameters to a false origin and orientation to project # conversion parameters to a false origin and orientation to project
# north. See the diagram in the BlenderBIM Add-on Georeferencing # north. See the diagram in the Bonsai Georeferencing
# documentation for correct calculation of the X Axis Abcissa and # documentation for correct calculation of the X Axis Abcissa and
# Ordinate. # Ordinate.
ifcopenshell.api.georeference.edit_georeferencing(model, ifcopenshell.api.georeference.edit_georeferencing(model,
@@ -174,7 +174,7 @@ class Usecase:
return self.create_surface_texture(links[0].from_node, "DIFFUSE") return self.create_surface_texture(links[0].from_node, "DIFFUSE")
def create_surface_texture(self, node, mode): def create_surface_texture(self, node, mode):
import blenderbim.tool as tool import bonsai.tool as tool
texture = self.file.create_entity( texture = self.file.create_entity(
"IfcImageTexture", "IfcImageTexture",
@@ -28,7 +28,7 @@ HEADER_EXTRACTOR_TEST_FILE_STR = """
ISO-10303-21; ISO-10303-21;
HEADER; HEADER;
FILE_DESCRIPTION(('ViewDefinition[DesignTransferView]'),'2;1'); FILE_DESCRIPTION(('ViewDefinition[DesignTransferView]'),'2;1');
FILE_NAME('file.ifc','2024-06-25T15:48:10+05:00',(),(),'IfcOpenShell 0.0.0','BlenderBIM 0.0.999999-xxxxxxx','Nobody'); FILE_NAME('file.ifc','2024-06-25T15:48:10+05:00',(),(),'IfcOpenShell 0.0.0','Bonsai 0.0.999999-xxxxxxx','Nobody');
FILE_SCHEMA(('IFC4X3_ADD2')); FILE_SCHEMA(('IFC4X3_ADD2'));
ENDSEC; ENDSEC;
DATA; DATA;
@@ -58,10 +58,10 @@ class Patcher:
def patch(self): def patch(self):
import bpy import bpy
import blenderbim.tool as tool import bonsai.tool as tool
import ifcopenshell import ifcopenshell
import ifcopenshell.util.element import ifcopenshell.util.element
from blenderbim.bim.ifc import IfcStore from bonsai.bim.ifc import IfcStore
from mathutils import Vector, Matrix from mathutils import Vector, Matrix
if len(bpy.data.objects) > 0: if len(bpy.data.objects) > 0:
@@ -70,7 +70,7 @@ class Patcher:
def patch(self): def patch(self):
import bpy import bpy
import bmesh import bmesh
import blenderbim.tool as tool import bonsai.tool as tool
from math import degrees from math import degrees
bpy.context.scene.BIMProjectProperties.should_use_native_meshes = True bpy.context.scene.BIMProjectProperties.should_use_native_meshes = True
+1 -1
View File
@@ -34,7 +34,7 @@ class Patcher:
If filesize is an issue, another approach would be to use IFCZIP If filesize is an issue, another approach would be to use IFCZIP
instead to compress the model. Optimising the model only typically instead to compress the model. Optimising the model only typically
affects filesize and has minimal impact on load times. Large filesizes affects filesize and has minimal impact on load times. Large filesizes
can usually be solved through other means. Consult the BlenderBIM Add-on can usually be solved through other means. Consult the bonsai Add-on
documentation on dealing with large models for more details. documentation on dealing with large models for more details.
Warning: this optimise recipe is very, very slow. Please consider using Warning: this optimise recipe is very, very slow. Please consider using
@@ -34,7 +34,7 @@ class Patcher:
If filesize is an issue, another approach would be to use IFCZIP If filesize is an issue, another approach would be to use IFCZIP
instead to compress the model. Optimising the model only typically instead to compress the model. Optimising the model only typically
affects filesize and has minimal impact on load times. Large filesizes affects filesize and has minimal impact on load times. Large filesizes
can usually be solved through other means. Consult the BlenderBIM Add-on can usually be solved through other means. Consult Bonsai
documentation on dealing with large models for more details. documentation on dealing with large models for more details.
This patch may be run multiple times with diminishing returns. This patch may be run multiple times with diminishing returns.
+1 -1
View File
@@ -68,7 +68,7 @@ def ensure_addons_are_enabled(*addon_names: str) -> None:
raise Exception("Some issues were found trying to enable IFC Sverchok:\n" + "\n".join(errors)) raise Exception("Some issues were found trying to enable IFC Sverchok:\n" + "\n".join(errors))
ensure_addons_are_enabled("blenderbim", "sverchok") ensure_addons_are_enabled("bonsai", "sverchok")
from sverchok.ui.nodeview_space_menu import add_node_menu from sverchok.ui.nodeview_space_menu import add_node_menu
+3 -3
View File
@@ -24,8 +24,8 @@ import ifcopenshell
import ifcsverchok.helper import ifcsverchok.helper
import ifcopenshell.api import ifcopenshell.api
from ifcsverchok.ifcstore import SvIfcStore from ifcsverchok.ifcstore import SvIfcStore
import blenderbim.tool as tool import bonsai.tool as tool
import blenderbim.core.geometry as core import bonsai.core.geometry as core
from bpy.props import ( from bpy.props import (
StringProperty, StringProperty,
EnumProperty, EnumProperty,
@@ -35,7 +35,7 @@ from bpy.props import (
) )
from sverchok.node_tree import SverchCustomTreeNode from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode, flatten_data, fixed_iter, flat_iter from sverchok.data_structure import updateNode, flatten_data, fixed_iter, flat_iter
from blenderbim.bim.module.root.prop import get_contexts from bonsai.bim.module.root.prop import get_contexts
from sverchok.data_structure import zip_long_repeat, node_id from sverchok.data_structure import zip_long_repeat, node_id
from sverchok.core.socket_data import sv_get_socket from sverchok.core.socket_data import sv_get_socket
+3 -3
View File
@@ -21,7 +21,7 @@ import logging
import ifcopenshell import ifcopenshell
import ifcsverchok.helper import ifcsverchok.helper
from ifcsverchok.ifcstore import SvIfcStore from ifcsverchok.ifcstore import SvIfcStore
import blenderbim.bim.import_ifc import bonsai.bim.import_ifc
from bpy.props import StringProperty, PointerProperty, BoolProperty from bpy.props import StringProperty, PointerProperty, BoolProperty
from sverchok.node_tree import SverchCustomTreeNode from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode, flatten_data from sverchok.data_structure import updateNode, flatten_data
@@ -84,10 +84,10 @@ class SvIfcCreateShape(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.
if not entity.is_a("IfcProduct"): if not entity.is_a("IfcProduct"):
return return
logger = logging.getLogger("ImportIFC") logger = logging.getLogger("ImportIFC")
self.ifc_import_settings = blenderbim.bim.import_ifc.IfcImportSettings.factory(bpy.context, "", logger) self.ifc_import_settings = bonsai.bim.import_ifc.IfcImportSettings.factory(bpy.context, "", logger)
settings = ifcopenshell.geom.settings() settings = ifcopenshell.geom.settings()
shape = ifcopenshell.geom.create_shape(settings, entity) shape = ifcopenshell.geom.create_shape(settings, entity)
ifc_importer = blenderbim.bim.import_ifc.IfcImporter(self.ifc_import_settings) ifc_importer = bonsai.bim.import_ifc.IfcImporter(self.ifc_import_settings)
ifc_importer.file = self.file ifc_importer.file = self.file
mesh = ifc_importer.create_mesh(entity, shape) mesh = ifc_importer.create_mesh(entity, shape)
obj = bpy.data.objects.new("IFC Element", mesh) obj = bpy.data.objects.new("IFC Element", mesh)
@@ -23,7 +23,7 @@ import ifcsverchok.helper
from bpy.props import StringProperty from bpy.props import StringProperty
from sverchok.node_tree import SverchCustomTreeNode from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode from sverchok.data_structure import updateNode
from blenderbim.bim.ifc import IfcStore from bonsai.bim.ifc import IfcStore
class SvIfcSelectBlenderObjectsRefresh(bpy.types.Operator): class SvIfcSelectBlenderObjectsRefresh(bpy.types.Operator):
+2 -2
View File
@@ -23,8 +23,8 @@ import ifcsverchok.helper
import ifcopenshell.api import ifcopenshell.api
import ifcopenshell.util.representation import ifcopenshell.util.representation
from ifcsverchok.ifcstore import SvIfcStore from ifcsverchok.ifcstore import SvIfcStore
import blenderbim.tool as tool import bonsai.tool as tool
import blenderbim.core.geometry as core import bonsai.core.geometry as core
from bpy.props import StringProperty, EnumProperty, IntProperty, FloatVectorProperty from bpy.props import StringProperty, EnumProperty, IntProperty, FloatVectorProperty
from sverchok.node_tree import SverchCustomTreeNode from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode, ensure_min_nesting from sverchok.data_structure import updateNode, ensure_min_nesting