Fix uses of ifcopenshell.file

This commit is contained in:
Andrej730
2026-08-03 13:18:15 +05:00
parent a86667d063
commit 26b412cff6
13 changed files with 26 additions and 26 deletions
@@ -462,7 +462,7 @@ def create_entity(type: str, schema: str = "IFC4", *args: Any, **kwargs: Any) ->
if fi := _global_ifc_models.get(schema.lower()):
pass
else:
fi = _global_ifc_models[schema.lower()] = file(schema=schema)
fi = _global_ifc_models[schema.lower()] = file(schema_identifier=schema)
return fi.create_entity(type, *args, **kwargs)
@@ -187,7 +187,7 @@ try:
exclude.update([st.name().upper() for st in ifcopenshell.util.schema.get_subtypes(declaration)])
# For creating C++ instances so that some of the calls here work
self.shadow_file = ifcopenshell.file(schema_identifier=self.ifc_schema)
self.shadow_file = ifcopenshell.file(schema=self.schema)
# But we only create them once per type because we basically only need access to 'semi-static' such as get_attribute_category()
self.instance_map = {}
@@ -24,7 +24,7 @@ import ifcopenshell.api.context
import ifcopenshell.api.unit
try:
ifcopenshell.file(schema="IFC4X3_ADD2")
ifcopenshell.file(schema="IFC4")
IFC4X3_AVAILABLE = True
except RuntimeError:
IFC4X3_AVAILABLE = False
@@ -32,7 +32,7 @@ except RuntimeError:
@pytest.mark.skipif(not IFC4X3_AVAILABLE, reason="IFC4X3 not available")
def test_create():
file = ifcopenshell.file(schema="IFC4X3_ADD2")
file = ifcopenshell.file(schema="IFC4X3")
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
ifcopenshell.api.unit.assign_unit(file, units=[length])
@@ -26,7 +26,7 @@ import ifcopenshell.util
import ifcopenshell.util.unit
try:
ifcopenshell.file(schema="IFC4X3_ADD2")
ifcopenshell.file(schema="IFC4X3")
IFC4X3_AVAILABLE = True
except RuntimeError:
IFC4X3_AVAILABLE = False
@@ -34,7 +34,7 @@ except RuntimeError:
@pytest.mark.skipif(not IFC4X3_AVAILABLE, reason="IFC4X3 not available")
def test_create_as_offset_curve():
file = ifcopenshell.file(schema="IFC4X3_ADD2")
file = ifcopenshell.file(schema="IFC4X3")
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="OCBD Test Alignment")
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
ifcopenshell.api.unit.assign_unit(file, units=[length])
@@ -23,7 +23,7 @@ import ifcopenshell.api.alignment
import ifcopenshell.api.unit
try:
ifcopenshell.file(schema="IFC4X3_ADD2")
ifcopenshell.file(schema="IFC4X3")
IFC4X3_AVAILABLE = True
except RuntimeError:
IFC4X3_AVAILABLE = False
@@ -31,7 +31,7 @@ except RuntimeError:
@pytest.mark.skipif(not IFC4X3_AVAILABLE, reason="IFC4X3 not available")
def test_create_as_polyline():
file = ifcopenshell.file(schema="IFC4X3_ADD2")
file = ifcopenshell.file(schema="IFC4X3")
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
ifcopenshell.api.unit.assign_unit(file, units=[length])
@@ -25,14 +25,14 @@ import ifcopenshell.api.context
import ifcopenshell.api.unit
try:
ifcopenshell.file(schema="IFC4X3_ADD2")
ifcopenshell.file(schema="IFC4X3")
IFC4X3_AVAILABLE = True
except RuntimeError:
IFC4X3_AVAILABLE = False
def _test_horizontal() -> ifcopenshell.file:
file = ifcopenshell.file(schema="IFC4X3_ADD2")
file = ifcopenshell.file(schema="IFC4X3")
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
ifcopenshell.api.unit.assign_unit(file, units=[length])
@@ -131,7 +131,7 @@ def _test_horizontal() -> ifcopenshell.file:
def _test_horizontal_vertical():
file = ifcopenshell.file(schema="IFC4X3_ADD2")
file = ifcopenshell.file(schema="IFC4X3")
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
ifcopenshell.api.unit.assign_unit(file, units=[length])
@@ -23,7 +23,7 @@ import ifcopenshell.api.alignment
import ifcopenshell.api.unit
try:
ifcopenshell.file(schema="IFC4X3_ADD2")
ifcopenshell.file(schema="IFC4X3")
IFC4X3_AVAILABLE = True
except RuntimeError:
IFC4X3_AVAILABLE = False
@@ -31,7 +31,7 @@ except RuntimeError:
@pytest.mark.skipif(not IFC4X3_AVAILABLE, reason="IFC4X3 not available")
def test_create_no_geometry():
file = ifcopenshell.file(schema="IFC4X3_ADD2")
file = ifcopenshell.file(schema="IFC4X3")
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
ifcopenshell.api.unit.assign_unit(file, units=[length])
@@ -56,7 +56,7 @@ def test_create_representation():
(12799.99998062693, 89.99999997234107, 0.9999875002340269, -0.004999937569813611),
]
file = ifcopenshell.file(schema="IFC4X3_ADD2")
file = ifcopenshell.file(schema="IFC4X3")
file.header.file_description.description = ["ViewDefinition [Alignment-basedView]"]
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="FHWA Alignment")
@@ -24,7 +24,7 @@ import ifcopenshell.api.context
import ifcopenshell.api.unit
try:
ifcopenshell.file(schema="IFC4X3_ADD2")
ifcopenshell.file(schema="IFC4X3")
IFC4X3_AVAILABLE = True
except RuntimeError:
IFC4X3_AVAILABLE = False
@@ -32,7 +32,7 @@ except RuntimeError:
@pytest.mark.skipif(not IFC4X3_AVAILABLE, reason="IFC4X3 not available")
def test_get_alignment():
file = ifcopenshell.file(schema="IFC4X3_ADD2")
file = ifcopenshell.file(schema="IFC4X3")
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
ifcopenshell.api.unit.assign_unit(file, units=[length])
@@ -23,7 +23,7 @@ import ifcopenshell.api.cogo
import ifcopenshell.api.context
try:
ifcopenshell.file(schema="IFC4X3_ADD2")
ifcopenshell.file(schema="IFC4X3")
IFC4X3_AVAILABLE = True
except RuntimeError:
IFC4X3_AVAILABLE = False
@@ -31,7 +31,7 @@ except RuntimeError:
@pytest.mark.skipif(not IFC4X3_AVAILABLE, reason="IFC4X3 not available")
def test_add_survey_point():
file = ifcopenshell.file(schema="IFC4X3_ADD2")
file = ifcopenshell.file(schema="IFC4X3")
project = file.createIfcProject(Name="Test")
site = file.createIfcSite(GlobalId=ifcopenshell.guid.new(), Name="MySite")
ifcopenshell.api.aggregate.assign_object(file, relating_object=project, products=[site])
@@ -23,7 +23,7 @@ import ifcopenshell.api.cogo
import ifcopenshell.api.context
try:
ifcopenshell.file(schema="IFC4X3_ADD2")
ifcopenshell.file(schema="IFC4X3")
IFC4X3_AVAILABLE = True
except RuntimeError:
IFC4X3_AVAILABLE = False
@@ -31,7 +31,7 @@ except RuntimeError:
@pytest.mark.skipif(not IFC4X3_AVAILABLE, reason="IFC4X3 not available")
def test_assign_survey_point():
file = ifcopenshell.file(schema="IFC4X3_ADD2")
file = ifcopenshell.file(schema="IFC4X3")
project = file.createIfcProject(Name="Test")
site = file.createIfcSite(GlobalId=ifcopenshell.guid.new(), Name="MySite")
ifcopenshell.api.aggregate.assign_object(file, relating_object=project, products=[site])
@@ -23,7 +23,7 @@ import ifcopenshell.api.cogo
import ifcopenshell.api.context
try:
ifcopenshell.file(schema="IFC4X3_ADD2")
ifcopenshell.file(schema="IFC4X3")
IFC4X3_AVAILABLE = True
except RuntimeError:
IFC4X3_AVAILABLE = False
@@ -31,7 +31,7 @@ except RuntimeError:
@pytest.mark.skipif(not IFC4X3_AVAILABLE, reason="IFC4X3 not available")
def test_edit_survey_point():
file = ifcopenshell.file(schema="IFC4X3_ADD2")
file = ifcopenshell.file(schema="IFC4X3")
project = file.createIfcProject(Name="Test")
site = file.createIfcSite(GlobalId=ifcopenshell.guid.new(), Name="MySite")
ifcopenshell.api.aggregate.assign_object(file, relating_object=project, products=[site])
@@ -23,14 +23,14 @@ import ifcopenshell.api.unit
import ifcopenshell.util.alignment as sta
try:
ifcopenshell.file(schema="IFC4X3_ADD2")
ifcopenshell.file(schema="IFC4X3")
IFC4X3_AVAILABLE = True
except RuntimeError:
IFC4X3_AVAILABLE = False
def _test_si_stations():
file = ifcopenshell.file(schema="IFC4X3_ADD2")
file = ifcopenshell.file(schema="IFC4X3")
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") # meter
ifcopenshell.api.unit.assign_unit(file, units=[length])
@@ -52,7 +52,7 @@ def _test_si_stations():
def _test_si_stations_millimeter():
file = ifcopenshell.file(schema="IFC4X3_ADD2")
file = ifcopenshell.file(schema="IFC4X3")
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
ifcopenshell.api.unit.assign_unit(file)
@@ -64,7 +64,7 @@ def _test_si_stations_millimeter():
def _test_us_stations():
file = ifcopenshell.file(schema="IFC4X3_ADD2")
file = ifcopenshell.file(schema="IFC4X3")
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
length = ifcopenshell.api.unit.add_conversion_based_unit(file, name="foot")
ifcopenshell.api.unit.assign_unit(file, units=[length])