mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 06:21:40 +00:00
Fix #6182. For convenience, precalculate scale value for projected CRS map unit map conversion
This commit is contained in:
@@ -235,6 +235,11 @@ def update_is_null(self: "Attribute", context: bpy.types.Context) -> None:
|
|||||||
self.set_value(default)
|
self.set_value(default)
|
||||||
if self.is_null is not True:
|
if self.is_null is not True:
|
||||||
self.is_null = True
|
self.is_null = True
|
||||||
|
if self.update:
|
||||||
|
update = globals()
|
||||||
|
for name in self.update.split("."):
|
||||||
|
update = update[name] if isinstance(update, dict) else getattr(update, name)
|
||||||
|
update(self, context)
|
||||||
|
|
||||||
|
|
||||||
def set_int_value(self: "Attribute", new_value: int) -> None:
|
def set_int_value(self: "Attribute", new_value: int) -> None:
|
||||||
@@ -322,6 +327,7 @@ class Attribute(PropertyGroup):
|
|||||||
value_max_constraint: BoolProperty(default=False, description="True if the numerical value has an upper bound")
|
value_max_constraint: BoolProperty(default=False, description="True if the numerical value has an upper bound")
|
||||||
special_type: StringProperty(name="Special Value Type", default="")
|
special_type: StringProperty(name="Special Value Type", default="")
|
||||||
metadata: StringProperty(name="Metadata", description="For storing some additional information about the attribute")
|
metadata: StringProperty(name="Metadata", description="For storing some additional information about the attribute")
|
||||||
|
update: StringProperty(name="Update", description="Custom update function to be executed")
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
name: str
|
name: str
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ class Georeference(bonsai.core.tool.Georeference):
|
|||||||
)
|
)
|
||||||
if data["MapUnit"]:
|
if data["MapUnit"]:
|
||||||
new.enum_value = str(data["MapUnit"].id())
|
new.enum_value = str(data["MapUnit"].id())
|
||||||
|
new.update = "tool.Georeference.update_map_unit"
|
||||||
return True
|
return True
|
||||||
|
|
||||||
props = bpy.context.scene.BIMGeoreferenceProperties
|
props = bpy.context.scene.BIMGeoreferenceProperties
|
||||||
@@ -72,6 +73,21 @@ class Georeference(bonsai.core.tool.Georeference):
|
|||||||
bonsai.bim.helper.import_attributes2(projected_crs, props.projected_crs, callback=callback)
|
bonsai.bim.helper.import_attributes2(projected_crs, props.projected_crs, callback=callback)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def update_map_unit(cls, self, context) -> None:
|
||||||
|
if unit_id := self.get_value():
|
||||||
|
map_unit = tool.Ifc.get().by_id(int(unit_id))
|
||||||
|
project_unit = ifcopenshell.util.unit.get_project_unit(tool.Ifc.get(), "LENGTHUNIT")
|
||||||
|
if map_unit and project_unit:
|
||||||
|
result = ifcopenshell.util.unit.convert_unit(1, project_unit, map_unit)
|
||||||
|
else:
|
||||||
|
result = 1.0
|
||||||
|
else:
|
||||||
|
result = 1.0
|
||||||
|
for attribute in bpy.context.scene.BIMGeoreferenceProperties.coordinate_operation:
|
||||||
|
if attribute.name == "Scale":
|
||||||
|
attribute.set_value(str(result))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def import_coordinate_operation(cls) -> None:
|
def import_coordinate_operation(cls) -> None:
|
||||||
def callback(name, prop, data):
|
def callback(name, prop, data):
|
||||||
|
|||||||
Reference in New Issue
Block a user