This commit is contained in:
Andrej730
2026-02-26 17:08:36 +05:00
parent ff3933a117
commit 333b6210a4
12 changed files with 49 additions and 33 deletions
+2 -2
View File
@@ -160,7 +160,7 @@ class BIMBSDDProperties(PropertyGroup):
default=False,
)
classification_psets: CollectionProperty(name="Classification Psets", type=BSDDPset)
if TYPE_CHECKING:
active_dictionary: str
active_dictionary: str
@@ -179,7 +179,7 @@ class BIMBSDDProperties(PropertyGroup):
should_filter_ifc_class: bool
use_only_ifc_properties: bool
classification_psets: bpy.types.bpy_prop_collection_idprop[BSDDPset]
@property
def active_class(self) -> Union[BSDDClassification, None]:
return tool.Blender.get_active_uilist_element(self.classes, self.active_class_index)
+1
View File
@@ -83,6 +83,7 @@ class BIM_PT_bsdd(Panel):
row = self.layout.row()
row.operator("bim.load_bsdd_dictionaries")
class BIM_UL_bsdd_dictionaries(UIList):
def draw_item(
self,
@@ -3871,7 +3871,6 @@ class AddReferenceImage(bpy.types.Operator, tool.Ifc.Operator, ImportHelper):
layout.prop(self, "x_length")
layout.prop(self, "y_length")
def _execute(self, context):
project_props = tool.Project.get_project_props()
project_props.load_indexed_maps = self.show_texture_solid_mode
@@ -3900,7 +3899,7 @@ class AddReferenceImage(bpy.types.Operator, tool.Ifc.Operator, ImportHelper):
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(ifc_file)
hx = self.x_length * 0.5 / unit_scale
hy = self.y_length * 0.5 / unit_scale
verts = [(-hx, -hy, 0.0), ( hx, -hy, 0.0), ( hx, hy, 0.0), (-hx, hy, 0.0)]
verts = [(-hx, -hy, 0.0), (hx, -hy, 0.0), (hx, hy, 0.0), (-hx, hy, 0.0)]
item = builder.mesh(verts, [[0, 1, 2, 3]])
ifc_context = ifcopenshell.util.representation.get_context(ifc_file, "Model", "Body", "MODEL_VIEW")
@@ -897,7 +897,7 @@ class OverrideDelete(bpy.types.Operator):
if not is_valid_data_block:
continue
element = tool.Ifc.get_entity(obj)
if element:
if tool.Geometry.is_locked(element):
+2 -1
View File
@@ -658,7 +658,8 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
name="Load Test Dictionaries", description="Load dictionaries that are for testing only", default=False
)
bsdd_baseurl: StringProperty(
name="bSDD API Base URL", description="Base URL for data dictionary API requests, e.g. https://api.bsdd.buildingsmart.org/api/",
name="bSDD API Base URL",
description="Base URL for data dictionary API requests, e.g. https://api.bsdd.buildingsmart.org/api/",
default="https://api.bsdd.buildingsmart.org/api/",
)
should_disable_undo_on_save: BoolProperty(
+6 -2
View File
@@ -1581,8 +1581,12 @@ class Blender(bonsai.core.tool.Blender):
default_scale = default_dpi * default_pixel_size
system = bpy.context.preferences.system
system_scale = system.dpi * system.pixel_size
return (system_scale / default_scale) * base_size *platform_scale * tool.Blender.get_addon_preferences().decorator_font_scale
return (
(system_scale / default_scale)
* base_size
* platform_scale
* tool.Blender.get_addon_preferences().decorator_font_scale
)
@classmethod
def apply_transform_as_local(cls, obj: bpy.types.Object) -> bool:
+3 -1
View File
@@ -316,7 +316,9 @@ class Georeference(bonsai.core.tool.Georeference):
@classmethod
def global2local(cls, matrix, is_specified_in_map_units: bool) -> tuple[float, float, float]:
matrix = ifcopenshell.util.geolocation.auto_global2local(tool.Ifc.get(), matrix, is_specified_in_map_units=is_specified_in_map_units)
matrix = ifcopenshell.util.geolocation.auto_global2local(
tool.Ifc.get(), matrix, is_specified_in_map_units=is_specified_in_map_units
)
props = cls.get_georeference_props()
if props.has_blender_offset:
matrix = ifcopenshell.util.geolocation.global2local(
+1 -1
View File
@@ -162,7 +162,7 @@ class TestEditTextLiterals(NewFile):
context = ifc.createIfcGeometricRepresentationSubContext(ContextType="Plan", ContextIdentifier="Annotation")
item = ifc.createIfcTextLiteralWithExtent(Literal="Literal", Path="RIGHT", BoxAlignment="bottom-left")
builder = ShapeBuilder(tool.Ifc.get())
polyline = builder.polyline([(0.,0.,0.), (1.,0.,0.)])
polyline = builder.polyline([(0.0, 0.0, 0.0), (1.0, 0.0, 0.0)])
representation = ifc.createIfcShapeRepresentation(ContextOfItems=context, Items=[item, polyline])
element.Representation.Representations = [representation]
tool.Ifc.link(element, obj)
@@ -36,7 +36,7 @@ def _create_offset_curve_representation(
expected_type = "IfcAlignment"
if not alignment.is_a(expected_type):
raise TypeError(f"Expected {expected_type} but got {alignment.is_a()}")
expected_type = "IfcPointByDistanceExpression"
for offset in offsets:
if not offset.is_a(expected_type):
@@ -217,7 +217,8 @@ for id in to_emit:
statements.append("%s << %s" % (id, stmt))
if __name__ == "__main__":
print(r"""
print(
r"""
# This file is generated by IfcOpenShell ifcexpressparser bootstrap.py
from __future__ import annotations
@@ -256,4 +257,6 @@ if __name__ == "__main__":
mdl = importlib.import_module(output)
mdl.Generator(m).emit()
sys.stdout.write(m.schema.name)
""" % ("\n ".join(statements)))
"""
% ("\n ".join(statements))
)
@@ -363,18 +363,24 @@ class EarlyBoundCodeWriter:
)
)
self.statements[self.statements.index("{factory_placeholder}")] = """
self.statements[self.statements.index("{factory_placeholder}")] = (
"""
class %(schema_name)s_instance_factory : public IfcParse::instance_factory {
virtual IfcUtil::IfcBaseClass* operator()(const IfcParse::declaration* decl, IfcEntityInstanceData&& data) const {
%(instance_mapping)s
}
};
""" % locals()
"""
% locals()
)
""
self.statements[self.statements.index("{string_pool_placeholder}")] = """
self.statements[self.statements.index("{string_pool_placeholder}")] = (
"""
const std::string strings[] = {%s};
""" % ",".join(map(lambda s: '"%s"s' % s, self.strings))
"""
% ",".join(map(lambda s: '"%s"s' % s, self.strings))
)
def __str__(self):
return "\n".join(self.statements)
@@ -54,7 +54,7 @@ class TestFormat(test.bootstrap.IFC4):
def test_number_formatting(self):
assert subject.format("round(123, 5)") == "125"
assert subject.format('round("123", 5)') == "125"
assert subject.format('round(-123, 5)') == "-125"
assert subject.format("round(-123, 5)") == "-125"
assert subject.format("int(123.123)") == "123"
assert subject.format("int(123)") == "123"
assert subject.format("number(123)") == "123"
@@ -79,14 +79,14 @@ class TestFormat(test.bootstrap.IFC4):
assert subject.format('imperial_length(3.0, 4, "foot", "foot", False)') == "3' - 0\""
def test_variable_formatting(self):
assert subject.format('{{undefined}}') is None
assert subject.format('upper({{undefined}})') == "NONE"
assert subject.format('int({{undefined}})') == "0"
assert subject.format("{{undefined}}") is None
assert subject.format("upper({{undefined}})") == "NONE"
assert subject.format("int({{undefined}})") == "0"
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
assert subject.format('{{undefined}}', element) is None
assert subject.format('{{class}}', element) == "IfcWall"
assert subject.format('{{ class }}', element) == "IfcWall"
assert subject.format('upper({{ class }})', element) == "IFCWALL"
assert subject.format("{{undefined}}", element) is None
assert subject.format("{{class}}", element) == "IfcWall"
assert subject.format("{{ class }}", element) == "IfcWall"
assert subject.format("upper({{ class }})", element) == "IFCWALL"
def test_list_formatting(self):
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
@@ -98,17 +98,17 @@ class TestFormat(test.bootstrap.IFC4):
layer = ifcopenshell.api.material.add_layer(self.file, layer_set=material_set, material=material2)
layer = ifcopenshell.api.material.add_layer(self.file, layer_set=material_set, material=material3)
ifcopenshell.api.material.assign_material(self.file, products=[element], material=material_set)
assert subject.format('{{materials.Name}}', element) == "CON01, CON03, CON02"
assert subject.format('sort({{materials.Name}})', element) == "CON01, CON02, CON03"
assert subject.format('reverse({{materials.Name}})', element) == "CON02, CON03, CON01"
assert subject.format("{{materials.Name}}", element) == "CON01, CON03, CON02"
assert subject.format("sort({{materials.Name}})", element) == "CON01, CON02, CON03"
assert subject.format("reverse({{materials.Name}})", element) == "CON02, CON03, CON01"
assert subject.format('join("-", {{materials.Name}})', element) == "CON01-CON03-CON02"
def test_expressions(self):
assert subject.format('2+3') == "5"
assert subject.format('-2+3') == "1"
assert subject.format('2-3') == "-1"
assert subject.format('3*2') == "6"
assert subject.format('3/2') == "1.5"
assert subject.format("2+3") == "5"
assert subject.format("-2+3") == "1"
assert subject.format("2-3") == "-1"
assert subject.format("3*2") == "6"
assert subject.format("3/2") == "1.5"
class TestGetElementValue(test.bootstrap.IFC4):