mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
You can now configure the distance limit for false origin offsets
This commit is contained in:
@@ -270,7 +270,9 @@ class IfcImporter:
|
||||
|
||||
def is_point_far_away(self, point, is_meters=True):
|
||||
# Locations greater than 1km are not considered "small sites" according to the georeferencing guide
|
||||
limit = 1000 if is_meters else (1000 / self.unit_scale)
|
||||
# Users can configure this if they have to handle larger sites but beware of surveying precision
|
||||
limit = self.ifc_import_settings.distance_limit
|
||||
limit = limit if is_meters else (limit / self.unit_scale)
|
||||
coords = point
|
||||
if hasattr(point, "Coordinates"):
|
||||
coords = point.Coordinates
|
||||
@@ -392,7 +394,7 @@ class IfcImporter:
|
||||
props = bpy.context.scene.BIMGeoreferenceProperties
|
||||
if props.has_blender_offset:
|
||||
return
|
||||
if self.ifc_import_settings.should_offset_model:
|
||||
if self.ifc_import_settings.false_origin:
|
||||
return self.set_manual_blender_offset()
|
||||
if self.file.schema == "IFC2X3":
|
||||
project = self.file.by_type("IfcProject")[0]
|
||||
@@ -408,9 +410,9 @@ class IfcImporter:
|
||||
|
||||
def set_manual_blender_offset(self):
|
||||
props = bpy.context.scene.BIMGeoreferenceProperties
|
||||
props.blender_eastings = str(self.ifc_import_settings.model_offset_coordinates[0])
|
||||
props.blender_northings = str(self.ifc_import_settings.model_offset_coordinates[1])
|
||||
props.blender_orthogonal_height = str(self.ifc_import_settings.model_offset_coordinates[2])
|
||||
props.blender_eastings = str(self.ifc_import_settings.false_origin[0])
|
||||
props.blender_northings = str(self.ifc_import_settings.false_origin[1])
|
||||
props.blender_orthogonal_height = str(self.ifc_import_settings.false_origin[2])
|
||||
props.has_blender_offset = True
|
||||
|
||||
def guess_georeferencing(self, element):
|
||||
@@ -1868,8 +1870,8 @@ class IfcImportSettings:
|
||||
self.should_clean_mesh = True
|
||||
self.deflection_tolerance = 0.001
|
||||
self.angular_tolerance = 0.5
|
||||
self.should_offset_model = False
|
||||
self.model_offset_coordinates = (0, 0, 0)
|
||||
self.distance_limit = 1000
|
||||
self.false_origin = None
|
||||
self.has_filter = None
|
||||
self.should_filter_spatial_elements = True
|
||||
self.elements = set()
|
||||
@@ -1893,10 +1895,12 @@ class IfcImportSettings:
|
||||
settings.should_clean_mesh = props.should_clean_mesh
|
||||
settings.deflection_tolerance = props.deflection_tolerance
|
||||
settings.angular_tolerance = props.angular_tolerance
|
||||
settings.should_offset_model = props.should_offset_model
|
||||
settings.model_offset_coordinates = (
|
||||
[float(o) for o in props.model_offset_coordinates.split(",")]
|
||||
if props.model_offset_coordinates
|
||||
else (0, 0, 0)
|
||||
settings.distance_limit = props.distance_limit
|
||||
settings.false_origin = (
|
||||
[float(o) for o in props.false_origin.split(",")]
|
||||
if props.false_origin
|
||||
else None
|
||||
)
|
||||
if settings.false_origin == [0, 0, 0]:
|
||||
settings.false_origin = None
|
||||
return settings
|
||||
|
||||
@@ -132,10 +132,10 @@ class BIMProjectProperties(PropertyGroup):
|
||||
should_merge_by_material: BoolProperty(name="Import and Merge by Material", default=False)
|
||||
should_merge_materials_by_colour: BoolProperty(name="Import and Merge Materials by Colour", default=False)
|
||||
should_clean_mesh: BoolProperty(name="Import and Clean Mesh", default=True)
|
||||
deflection_tolerance: FloatProperty(name="Import Deflection Tolerance", default=0.001)
|
||||
angular_tolerance: FloatProperty(name="Import Angular Tolerance", default=0.5)
|
||||
should_offset_model: BoolProperty(name="Import and Offset Model", default=False)
|
||||
model_offset_coordinates: StringProperty(name="Model Offset Coordinates", default="0,0,0")
|
||||
deflection_tolerance: FloatProperty(name="Deflection Tolerance", default=0.001)
|
||||
angular_tolerance: FloatProperty(name="Angular Tolerance", default=0.5)
|
||||
distance_limit: FloatProperty(name="Distance Limit", default=1000)
|
||||
false_origin: StringProperty(name="False Origin", default="0,0,0")
|
||||
links: CollectionProperty(name="Links", type=Link)
|
||||
active_link_index: IntProperty(name="Active Link Index")
|
||||
export_schema: EnumProperty(items=get_export_schema, name="IFC Schema")
|
||||
|
||||
@@ -82,9 +82,9 @@ class BIM_PT_project(Panel):
|
||||
row = self.layout.row()
|
||||
row.prop(pprops, "angular_tolerance")
|
||||
row = self.layout.row()
|
||||
row.prop(pprops, "should_offset_model")
|
||||
row.prop(pprops, "distance_limit")
|
||||
row = self.layout.row()
|
||||
row.prop(pprops, "model_offset_coordinates")
|
||||
row.prop(pprops, "false_origin")
|
||||
|
||||
row = self.layout.row(align=True)
|
||||
row.operator("bim.load_project_elements")
|
||||
|
||||
@@ -269,16 +269,14 @@ Scenario: Load project elements - load with the spatial decomposition collection
|
||||
Scenario: Load project elements - manual offset of object placements
|
||||
Given an empty Blender session
|
||||
And I press "bim.load_project(filepath='{cwd}/test/files/manual-geolocation.ifc', is_advanced=True)"
|
||||
When I set "scene.BIMProjectProperties.should_offset_model" to "True"
|
||||
And I set "scene.BIMProjectProperties.model_offset_coordinates" to "268388500, 5774506000, 21900"
|
||||
When I set "scene.BIMProjectProperties.false_origin" to "268388500, 5774506000, 21900"
|
||||
And I press "bim.load_project_elements"
|
||||
Then the object "IfcPlate/1780 x 270 PRECAST WALL" is at "0,0,0"
|
||||
|
||||
Scenario: Load project elements - manual offset of cartesian points
|
||||
Given an empty Blender session
|
||||
And I press "bim.load_project(filepath='{cwd}/test/files/manual-geolocation-coords.ifc', is_advanced=True)"
|
||||
When I set "scene.BIMProjectProperties.should_offset_model" to "True"
|
||||
And I set "scene.BIMProjectProperties.model_offset_coordinates" to "1990711,5971553,22700"
|
||||
When I set "scene.BIMProjectProperties.false_origin" to "1990711,5971553,22700"
|
||||
And I press "bim.load_project_elements"
|
||||
Then the object "IfcBuildingElementProxy/NAME" is at "0,0,0"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user