mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 22:50:21 +00:00
Fix bug where blender offsets were not considered in local<->global coordinate conversion
This commit is contained in:
@@ -1107,15 +1107,7 @@ class IfcImporter:
|
|||||||
IfcStore.path = "self.ifc_import_settings.input_file"
|
IfcStore.path = "self.ifc_import_settings.input_file"
|
||||||
|
|
||||||
def calculate_unit_scale(self):
|
def calculate_unit_scale(self):
|
||||||
units = self.file.by_type("IfcUnitAssignment")[0]
|
self.unit_scale = ifcopenshell.util.unit.calculate_unit_scale(self.file)
|
||||||
for unit in units.Units:
|
|
||||||
if not hasattr(unit, "UnitType") or unit.UnitType != "LENGTHUNIT":
|
|
||||||
continue
|
|
||||||
while unit.is_a("IfcConversionBasedUnit"):
|
|
||||||
self.unit_scale *= unit.ConversionFactor.ValueComponent.wrappedValue
|
|
||||||
unit = unit.ConversionFactor.UnitComponent
|
|
||||||
if unit.is_a("IfcSIUnit"):
|
|
||||||
self.unit_scale *= ifcopenshell.util.unit.get_prefix_multiplier(unit.Prefix)
|
|
||||||
|
|
||||||
def set_units(self):
|
def set_units(self):
|
||||||
units = self.file.by_type("IfcUnitAssignment")[0]
|
units = self.file.by_type("IfcUnitAssignment")[0]
|
||||||
|
|||||||
@@ -200,17 +200,42 @@ class ConvertLocalToGlobal(bpy.types.Operator):
|
|||||||
Data.load()
|
Data.load()
|
||||||
props = context.scene.BIMGeoreferenceProperties
|
props = context.scene.BIMGeoreferenceProperties
|
||||||
x, y, z = [float(co) for co in props.coordinate_input.split(",")]
|
x, y, z = [float(co) for co in props.coordinate_input.split(",")]
|
||||||
results = ifcopenshell.util.geolocation.xyz2enh(
|
|
||||||
x,
|
if props.has_blender_offset and props.blender_offset_type == "CARTESIAN_POINT":
|
||||||
y,
|
x -= float(props.blender_eastings)
|
||||||
z,
|
y -= float(props.blender_northings)
|
||||||
Data.map_conversion["Eastings"],
|
z -= float(props.blender_orthogonal_height)
|
||||||
Data.map_conversion["Northings"],
|
elif props.has_blender_offset and props.blender_offset_type == "OBJECT_PLACEMENT":
|
||||||
Data.map_conversion["OrthogonalHeight"],
|
results = ifcopenshell.util.geolocation.xyz2enh(
|
||||||
Data.map_conversion.get("XAxisAbscissa", 1.0),
|
x,
|
||||||
Data.map_conversion.get("XAxisOrdinate", 0.0),
|
y,
|
||||||
Data.map_conversion.get("Scale", 1.0),
|
z,
|
||||||
)
|
float(props.blender_eastings),
|
||||||
|
float(props.blender_northings),
|
||||||
|
float(props.blender_orthogonal_height),
|
||||||
|
float(props.blender_x_axis_abscissa),
|
||||||
|
float(props.blender_x_axis_ordinate),
|
||||||
|
1.0,
|
||||||
|
)
|
||||||
|
x, y, z = results
|
||||||
|
|
||||||
|
# TODO: what if the project CRS units and the project units are different?
|
||||||
|
|
||||||
|
if Data.map_conversion:
|
||||||
|
results = ifcopenshell.util.geolocation.xyz2enh(
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
z,
|
||||||
|
Data.map_conversion["Eastings"],
|
||||||
|
Data.map_conversion["Northings"],
|
||||||
|
Data.map_conversion["OrthogonalHeight"],
|
||||||
|
Data.map_conversion.get("XAxisAbscissa", 1.0),
|
||||||
|
Data.map_conversion.get("XAxisOrdinate", 0.0),
|
||||||
|
Data.map_conversion.get("Scale", 1.0),
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
results = (x, y, z)
|
||||||
|
|
||||||
props.coordinate_output = ",".join([str(r) for r in results])
|
props.coordinate_output = ",".join([str(r) for r in results])
|
||||||
bpy.context.scene.cursor.location = results
|
bpy.context.scene.cursor.location = results
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
@@ -225,17 +250,39 @@ class ConvertGlobalToLocal(bpy.types.Operator):
|
|||||||
Data.load()
|
Data.load()
|
||||||
props = context.scene.BIMGeoreferenceProperties
|
props = context.scene.BIMGeoreferenceProperties
|
||||||
x, y, z = [float(co) for co in props.coordinate_input.split(",")]
|
x, y, z = [float(co) for co in props.coordinate_input.split(",")]
|
||||||
results = ifcopenshell.util.geolocation.enh2xyz(
|
|
||||||
x,
|
if Data.map_conversion:
|
||||||
y,
|
results = ifcopenshell.util.geolocation.enh2xyz(
|
||||||
z,
|
x,
|
||||||
Data.map_conversion["Eastings"],
|
y,
|
||||||
Data.map_conversion["Northings"],
|
z,
|
||||||
Data.map_conversion["OrthogonalHeight"],
|
Data.map_conversion["Eastings"],
|
||||||
Data.map_conversion.get("XAxisAbscissa", 1.0),
|
Data.map_conversion["Northings"],
|
||||||
Data.map_conversion.get("XAxisOrdinate", 0.0),
|
Data.map_conversion["OrthogonalHeight"],
|
||||||
Data.map_conversion.get("Scale", 1.0),
|
Data.map_conversion.get("XAxisAbscissa", 1.0),
|
||||||
)
|
Data.map_conversion.get("XAxisOrdinate", 0.0),
|
||||||
|
Data.map_conversion.get("Scale", 1.0),
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
results = (x, y, z)
|
||||||
|
|
||||||
|
if props.has_blender_offset and props.blender_offset_type == "CARTESIAN_POINT":
|
||||||
|
results[0] += float(props.blender_eastings)
|
||||||
|
results[1] += float(props.blender_northings)
|
||||||
|
results[2] += float(props.blender_orthogonal_height)
|
||||||
|
elif props.has_blender_offset and props.blender_offset_type == "OBJECT_PLACEMENT":
|
||||||
|
results = ifcopenshell.util.geolocation.enh2xyz(
|
||||||
|
results[0],
|
||||||
|
results[1],
|
||||||
|
results[2],
|
||||||
|
float(props.blender_eastings),
|
||||||
|
float(props.blender_northings),
|
||||||
|
float(props.blender_orthogonal_height),
|
||||||
|
float(props.blender_x_axis_abscissa),
|
||||||
|
float(props.blender_x_axis_ordinate),
|
||||||
|
1.0,
|
||||||
|
)
|
||||||
|
|
||||||
props.coordinate_output = ",".join([str(r) for r in results])
|
props.coordinate_output = ",".join([str(r) for r in results])
|
||||||
bpy.context.scene.cursor.location = results
|
bpy.context.scene.cursor.location = results
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|||||||
Reference in New Issue
Block a user