Add workaround to guess geolocation data from Revit

This commit is contained in:
Dion Moult
2020-11-10 22:43:05 +11:00
parent a9ae92883d
commit b3d180a288
3 changed files with 22 additions and 0 deletions
@@ -507,8 +507,10 @@ class IfcImporter:
self.ifc_import_settings.should_treat_styled_item_as_material = True
if self.is_ifc_class_far_away("IfcSite"):
self.ifc_import_settings.should_ignore_site_coordinates = True
self.ifc_import_settings.should_guess_georeferencing = True
if self.is_ifc_class_far_away("IfcBuilding"):
self.ifc_import_settings.should_ignore_building_coordinates = True
self.ifc_import_settings.should_guess_georeferencing = True
elif "prostructures" in applications[0].ApplicationFullName.lower():
self.ifc_import_settings.should_allow_non_element_aggregates = True
elif applications[0].ApplicationFullName.lower() == "12d model":
@@ -622,15 +624,31 @@ class IfcImporter:
project = self.file.by_type("IfcProject")[0]
if self.ifc_import_settings.should_ignore_site_coordinates:
sites = self.find_decomposed_ifc_class(project, "IfcSite")
if self.ifc_import_settings.should_guess_georeferencing and sites:
self.guess_georeferencing(sites[0])
for site in sites:
self.patch_placement_to_origin(site)
if self.ifc_import_settings.should_ignore_building_coordinates:
buildings = self.find_decomposed_ifc_class(project, "IfcBuilding")
if self.ifc_import_settings.should_guess_georeferencing and buildings:
self.guess_georeferencing(buildings[0])
for building in buildings:
self.patch_placement_to_origin(building)
if self.ifc_import_settings.should_reset_absolute_coordinates:
self.reset_absolute_coordinates()
def guess_georeferencing(self, element):
if not element.ObjectPlacement.is_a("IfcLocalPlacement"):
return
placement = element.ObjectPlacement.RelativePlacement
bpy.context.scene.MapConversion.eastings = str(placement.Location.Coordinates[0])
bpy.context.scene.MapConversion.northings = str(placement.Location.Coordinates[1])
bpy.context.scene.MapConversion.orthogonal_height = str(placement.Location.Coordinates[2])
if placement.RefDirection:
bpy.context.scene.MapConversion.x_axis_abscissa = str(placement.RefDirection.DirectionRatios[0])
bpy.context.scene.MapConversion.x_axis_ordinate = str(placement.RefDirection.DirectionRatios[1] * -1)
bpy.context.scene.MapConversion.scale = "1"
def reset_absolute_coordinates(self):
# 12D can have some funky coordinates out of any sensible range. This
# method will not work all the time, but will catch most issues.
@@ -2278,6 +2296,7 @@ class IfcImportSettings:
settings.should_ignore_site_coordinates = scene_bim.import_should_ignore_site_coordinates
settings.should_ignore_building_coordinates = scene_bim.import_should_ignore_building_coordinates
settings.should_reset_absolute_coordinates = scene_bim.import_should_reset_absolute_coordinates
settings.should_guess_georeferencing = scene_bim.import_should_guess_georeferencing
settings.should_import_type_representations = scene_bim.import_should_import_type_representations
settings.should_import_curves = scene_bim.import_should_import_curves
settings.should_import_opening_elements = scene_bim.import_should_import_opening_elements
@@ -1426,6 +1426,7 @@ class BIMProperties(PropertyGroup):
import_should_ignore_site_coordinates: BoolProperty(name="Import Ignoring Site Coordinates", default=False)
import_should_ignore_building_coordinates: BoolProperty(name="Import Ignoring Building Coordinates", default=False)
import_should_reset_absolute_coordinates: BoolProperty(name="Import Resetting Absolute Coordinates", default=False)
import_should_guess_georeferencing: BoolProperty(name="Import Guessing Georeferencing", default=False)
import_should_import_type_representations: BoolProperty(name="Import Type Representations", default=False)
import_should_import_curves: BoolProperty(name="Import Curves", default=False)
import_should_import_opening_elements: BoolProperty(name="Import Opening Elements", default=False)
@@ -1944,6 +1944,8 @@ class BIM_PT_mvd(Panel):
row = layout.row()
row.prop(bim_properties, "export_should_use_presentation_style_assignment")
row = layout.row()
row.prop(bim_properties, "import_should_guess_georeferencing")
row = layout.row()
row.prop(bim_properties, "import_should_ignore_site_coordinates")
row = layout.row()
row.prop(bim_properties, "import_should_ignore_building_coordinates")