mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Support adding / editing georeferencing for IFC2X3 fallback psets
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api.pset
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
def add_georeferencing(file: ifcopenshell.file) -> None:
|
||||
@@ -42,6 +44,25 @@ def add_georeferencing(file: ifcopenshell.file) -> None:
|
||||
|
||||
ifcopenshell.api.run("georeference.add_georeferencing", model)
|
||||
"""
|
||||
if file.schema == "IFC2X3":
|
||||
if not (project := file.by_type("IfcProject")):
|
||||
return
|
||||
project = project[0]
|
||||
if ifcopenshell.util.element.get_pset(project, "ePSet_ProjectedCRS"):
|
||||
return
|
||||
conversion = ifcopenshell.api.pset.add_pset(file, project, "ePSet_MapConversion")
|
||||
crs = ifcopenshell.api.pset.add_pset(file, project, "ePSet_ProjectedCRS")
|
||||
ifcopenshell.api.pset.edit_pset(file, crs, properties={"Name": ""})
|
||||
ifcopenshell.api.pset.edit_pset(
|
||||
file,
|
||||
conversion,
|
||||
properties={
|
||||
"Eastings": file.createIfcLengthMeasure(0),
|
||||
"Northings": file.createIfcLengthMeasure(0),
|
||||
"OrthogonalHeight": file.createIfcLengthMeasure(0),
|
||||
},
|
||||
)
|
||||
return
|
||||
if file.by_type("IfcProjectedCRS"):
|
||||
return
|
||||
source_crs = None
|
||||
|
||||
@@ -100,13 +100,36 @@ def edit_georeferencing(
|
||||
|
||||
class Usecase:
|
||||
def execute(self):
|
||||
self.set_true_north()
|
||||
if self.file.schema == "IFC2X3":
|
||||
if not (project := self.file.by_type("IfcProject")):
|
||||
return
|
||||
project = project[0]
|
||||
if (crs := ifcopenshell.util.element.get_pset(project, "ePSet_ProjectedCRS")):
|
||||
crs = self.file.by_id(crs["id"])
|
||||
for k, v in self.settings["projected_crs"].items():
|
||||
if k == "Description":
|
||||
v = self.file.createIfcText(v)
|
||||
elif k == "Name":
|
||||
v = self.file.createIfcLabel(v)
|
||||
else:
|
||||
v = self.file.createIfcIdentifier(v)
|
||||
ifcopenshell.api.pset.edit_pset(self.file, crs, properties=self.settings["projected_crs"])
|
||||
if (conversion := ifcopenshell.util.element.get_pset(project, "ePSet_MapConversion")):
|
||||
conversion = self.file.by_id(conversion["id"])
|
||||
for k, v in self.settings["map_conversion"].items():
|
||||
if k in ("XAxisAbscissa", "XAxisOrdinate", "Scale"):
|
||||
v = self.file.createIfcReal(v)
|
||||
else:
|
||||
v = self.file.createIfcLengthMeasure(v)
|
||||
ifcopenshell.api.pset.edit_pset(self.file, conversion, properties=self.settings["map_conversion"])
|
||||
return
|
||||
map_conversion = self.file.by_type("IfcMapConversion")[0]
|
||||
projected_crs = self.file.by_type("IfcProjectedCRS")[0]
|
||||
for name, value in self.settings["map_conversion"].items():
|
||||
setattr(map_conversion, name, value)
|
||||
for name, value in self.settings["projected_crs"].items():
|
||||
setattr(projected_crs, name, value)
|
||||
self.set_true_north()
|
||||
|
||||
def set_true_north(self):
|
||||
if not self.settings["true_north"]:
|
||||
|
||||
Reference in New Issue
Block a user