mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Run black on IOS-Python
This commit is contained in:
@@ -81,13 +81,21 @@ autoapi_add_toctree_entry = True
|
||||
autoapi_type = "python"
|
||||
|
||||
# autoapi works by reading source code instead of importing modules
|
||||
autoapi_dirs = ['../ifcopenshell', '../../bcf/bcf', '../../bsdd', '../../ifccsv', '../../ifcdiff', '../../ifcpatch/ifcpatch', '../../ifctester/ifctester']
|
||||
autoapi_dirs = [
|
||||
"../ifcopenshell",
|
||||
"../../bcf/bcf",
|
||||
"../../bsdd",
|
||||
"../../ifccsv",
|
||||
"../../ifcdiff",
|
||||
"../../ifcpatch/ifcpatch",
|
||||
"../../ifctester/ifctester",
|
||||
]
|
||||
# autoapi_dirs = ['../../ifcdiff']
|
||||
# autoapi_dirs = ['../../ifcdiff', '../ifcopenshell/util']
|
||||
# autoapi_dirs = ['../../bcf/bcf', '../../bsdd', '../../ifccsv', '../../ifcdiff', '../../ifcpatch/ifcpatch', '../../ifctester/ifctester']
|
||||
|
||||
# These are auto-generated based on the IFC schema, so exclude them
|
||||
autoapi_ignore = ['*ifcopenshell/express/rules*']
|
||||
autoapi_ignore = ["*ifcopenshell/express/rules*"]
|
||||
|
||||
# Custom autoapi templates to make it easier to read our docs
|
||||
autoapi_template_dir = "_autoapi_templates"
|
||||
|
||||
@@ -74,7 +74,5 @@ def add_cost_item(
|
||||
},
|
||||
)
|
||||
elif settings["cost_item"]:
|
||||
ifcopenshell.api.nest.assign_object(
|
||||
file, related_objects=[cost_item], relating_object=settings["cost_item"]
|
||||
)
|
||||
ifcopenshell.api.nest.assign_object(file, related_objects=[cost_item], relating_object=settings["cost_item"])
|
||||
return cost_item
|
||||
|
||||
@@ -26,6 +26,7 @@ geometry extrusions).
|
||||
from .. import wrap_usecases
|
||||
from .add_axis_representation import add_axis_representation
|
||||
from .add_boolean import add_boolean
|
||||
|
||||
try:
|
||||
from .add_door_representation import add_door_representation
|
||||
except ModuleNotFoundError as e:
|
||||
@@ -33,6 +34,7 @@ except ModuleNotFoundError as e:
|
||||
from .add_footprint_representation import add_footprint_representation
|
||||
from .add_mesh_representation import add_mesh_representation
|
||||
from .add_profile_representation import add_profile_representation
|
||||
|
||||
try:
|
||||
from .add_railing_representation import add_railing_representation
|
||||
except ModuleNotFoundError as e:
|
||||
@@ -44,6 +46,7 @@ except ModuleNotFoundError as e:
|
||||
print(f"Note: API not available due to missing dependencies: geometry.add_representation - {e}")
|
||||
from .add_slab_representation import add_slab_representation
|
||||
from .add_wall_representation import add_wall_representation
|
||||
|
||||
try:
|
||||
from .add_window_representation import add_window_representation
|
||||
except ModuleNotFoundError as e:
|
||||
|
||||
@@ -857,13 +857,19 @@ class Usecase:
|
||||
z = self.convert_si_to_unit(z)
|
||||
return self.file.createIfcCartesianPoint((x, y, z))
|
||||
|
||||
def create_cartesian_point_list_from_vertices(self, vertices: list[bpy.types.MeshVertex], is_2d=False, is_model_coords=True):
|
||||
def create_cartesian_point_list_from_vertices(
|
||||
self, vertices: list[bpy.types.MeshVertex], is_2d=False, is_model_coords=True
|
||||
):
|
||||
if is_model_coords and self.settings["coordinate_offset"]:
|
||||
if is_2d:
|
||||
xy_offset = Vector((self.settings["coordinate_offset"][0:2]))
|
||||
return self.file.createIfcCartesianPointList2D([self.convert_si_to_unit(v.co.xy + xy_offset) for v in vertices])
|
||||
return self.file.createIfcCartesianPointList2D(
|
||||
[self.convert_si_to_unit(v.co.xy + xy_offset) for v in vertices]
|
||||
)
|
||||
xyz_offset = Vector((self.settings["coordinate_offset"][0:3]))
|
||||
return self.file.createIfcCartesianPointList3D([self.convert_si_to_unit(v.co.xyz + xyz_offset) for v in vertices])
|
||||
return self.file.createIfcCartesianPointList3D(
|
||||
[self.convert_si_to_unit(v.co.xyz + xyz_offset) for v in vertices]
|
||||
)
|
||||
if is_2d:
|
||||
return self.file.createIfcCartesianPointList2D([self.convert_si_to_unit(v.co.xy) for v in vertices])
|
||||
return self.file.createIfcCartesianPointList3D([self.convert_si_to_unit(v.co) for v in vertices])
|
||||
|
||||
@@ -57,7 +57,7 @@ def edit_true_north(file: ifcopenshell.file, true_north: Optional[Union[tuple[fl
|
||||
|
||||
for context in file.by_type("IfcGeometricRepresentationContext", include_subtypes=False):
|
||||
if context.TrueNorth and true_north is None:
|
||||
old_true_north = context.TrueNorth
|
||||
old_true_north = context.TrueNorth
|
||||
context.TrueNorth = None
|
||||
if not file.get_total_inverses(old_true_north):
|
||||
ifcopenshell.util.element.remove_deep2(file, old_true_north)
|
||||
|
||||
@@ -22,6 +22,7 @@ A grid in IFC may contain two or more axes running in two or more directions.
|
||||
"""
|
||||
|
||||
from .. import wrap_usecases
|
||||
|
||||
try:
|
||||
from .create_axis_curve import create_axis_curve
|
||||
except ModuleNotFoundError as e:
|
||||
|
||||
@@ -20,7 +20,10 @@ from typing import Optional
|
||||
|
||||
|
||||
def add_material(
|
||||
file: ifcopenshell.file, name: Optional[str] = None, category: Optional[str] = None, description: Optional[str] = None
|
||||
file: ifcopenshell.file,
|
||||
name: Optional[str] = None,
|
||||
category: Optional[str] = None,
|
||||
description: Optional[str] = None,
|
||||
) -> ifcopenshell.entity_instance:
|
||||
"""Adds a new material
|
||||
|
||||
@@ -50,8 +53,8 @@ def add_material(
|
||||
Note that categories are not available in IFC2X3. This shortcoming is
|
||||
one of the big reasons projects should upgrade to IFC4.
|
||||
|
||||
Additionally, a material's description provides more information beyond
|
||||
its name or category.
|
||||
Additionally, a material's description provides more information beyond
|
||||
its name or category.
|
||||
|
||||
:param name: The name of the material, typically tagged in a finishes
|
||||
drawing or schedule.
|
||||
@@ -78,7 +81,7 @@ def add_material(
|
||||
# "Style" has been specified.
|
||||
ifcopenshell.api.material.assign_material(model, products=[concrete_bench], material=concrete)
|
||||
"""
|
||||
settings = {"name": name or "Unnamed", "category": category, "description": description }
|
||||
settings = {"name": name or "Unnamed", "category": category, "description": description}
|
||||
|
||||
material = file.create_entity("IfcMaterial", **{"Name": settings["name"] or "Unnamed"})
|
||||
if settings["category"]:
|
||||
|
||||
@@ -97,6 +97,7 @@ def assign_profile(
|
||||
|
||||
class Usecase:
|
||||
file: ifcopenshell.file
|
||||
|
||||
def execute(self) -> None:
|
||||
# TODO: handle composite profiles
|
||||
old_profile = self.settings["material_profile"].Profile
|
||||
|
||||
@@ -19,7 +19,9 @@ import ifcopenshell
|
||||
from typing import Any
|
||||
|
||||
|
||||
def edit_assigned_material(file: ifcopenshell.file, element: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
|
||||
def edit_assigned_material(
|
||||
file: ifcopenshell.file, element: ifcopenshell.entity_instance, attributes: dict[str, Any]
|
||||
) -> None:
|
||||
"""Edits the attributes of an IfcMaterial
|
||||
|
||||
For more information about the attributes and data types of an
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
import ifcopenshell
|
||||
|
||||
|
||||
def add_role(file: ifcopenshell.file, assigned_object: ifcopenshell.entity_instance, role: str = "ARCHITECT") -> ifcopenshell.entity_instance:
|
||||
def add_role(
|
||||
file: ifcopenshell.file, assigned_object: ifcopenshell.entity_instance, role: str = "ARCHITECT"
|
||||
) -> ifcopenshell.entity_instance:
|
||||
"""Adds and assigns a new role
|
||||
|
||||
People and organisations must play one or more roles on a project. Roles
|
||||
|
||||
@@ -19,7 +19,9 @@ import ifcopenshell
|
||||
from typing import Any
|
||||
|
||||
|
||||
def edit_organisation(file: ifcopenshell.file, organisation: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
|
||||
def edit_organisation(
|
||||
file: ifcopenshell.file, organisation: ifcopenshell.entity_instance, attributes: dict[str, Any]
|
||||
) -> None:
|
||||
"""Edits the attributes of an IfcOrganization
|
||||
|
||||
For more information about the attributes and data types of an
|
||||
|
||||
@@ -95,7 +95,7 @@ def add_pset(file: ifcopenshell.file, product: ifcopenshell.entity_instance, nam
|
||||
"GlobalId": ifcopenshell.guid.new(),
|
||||
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
|
||||
"Name": settings["name"],
|
||||
}
|
||||
},
|
||||
)
|
||||
file.create_entity(
|
||||
"IfcRelDefinesByProperties",
|
||||
@@ -104,7 +104,7 @@ def add_pset(file: ifcopenshell.file, product: ifcopenshell.entity_instance, nam
|
||||
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
|
||||
"RelatedObjects": [settings["product"]],
|
||||
"RelatingPropertyDefinition": pset,
|
||||
}
|
||||
},
|
||||
)
|
||||
return pset
|
||||
elif settings["product"].is_a("IfcTypeObject"):
|
||||
@@ -118,7 +118,7 @@ def add_pset(file: ifcopenshell.file, product: ifcopenshell.entity_instance, nam
|
||||
"GlobalId": ifcopenshell.guid.new(),
|
||||
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
|
||||
"Name": settings["name"],
|
||||
}
|
||||
},
|
||||
)
|
||||
has_property_sets = list(settings["product"].HasPropertySets or [])
|
||||
has_property_sets.append(pset)
|
||||
@@ -142,7 +142,7 @@ def add_pset(file: ifcopenshell.file, product: ifcopenshell.entity_instance, nam
|
||||
**{
|
||||
"Name": settings["name"],
|
||||
"Material": settings["product"],
|
||||
}
|
||||
},
|
||||
)
|
||||
elif settings["product"].is_a("IfcProfileDef"):
|
||||
# in IFC2X3 IfcProfileProperties doesn't have Name and we cannot identify them
|
||||
|
||||
@@ -50,7 +50,9 @@ def edit_prop_template(
|
||||
if enum_values := attributes.get("Enumerators", None):
|
||||
prop_name = attributes.get("Name", None) or getattr(prop_template, "Name", None) or "Unnamed"
|
||||
primary_measure_type = (
|
||||
attributes.get("PrimaryMeasureType", None) or getattr(prop_template, "PrimaryMeasureType", None) or "IfcLabel"
|
||||
attributes.get("PrimaryMeasureType", None)
|
||||
or getattr(prop_template, "PrimaryMeasureType", None)
|
||||
or "IfcLabel"
|
||||
)
|
||||
enum_values = [file.create_entity(primary_measure_type, v) for v in enum_values]
|
||||
if enumerators := prop_template.Enumerators:
|
||||
|
||||
@@ -38,10 +38,7 @@ def add_structural_load_case(
|
||||
"""
|
||||
|
||||
load_case = ifcopenshell.api.root.create_entity(
|
||||
file,
|
||||
ifc_class="IfcStructuralLoadCase",
|
||||
predefined_type="LOAD_CASE",
|
||||
name=name
|
||||
file, ifc_class="IfcStructuralLoadCase", predefined_type="LOAD_CASE", name=name
|
||||
)
|
||||
load_case.ActionType = action_type
|
||||
load_case.ActionSource = action_source
|
||||
|
||||
@@ -83,11 +83,15 @@ def register_schema_attributes(schema: ifcopenshell_wrapper.schema_definition) -
|
||||
|
||||
# resolve to actual functions in wrapper
|
||||
functions = [
|
||||
set_derived_attribute
|
||||
if mname == "setArgumentAsDerived"
|
||||
else set_unsupported_attribute
|
||||
if mname == "setArgumentAsUnknown"
|
||||
else getattr(ifcopenshell_wrapper.entity_instance, mname)
|
||||
(
|
||||
set_derived_attribute
|
||||
if mname == "setArgumentAsDerived"
|
||||
else (
|
||||
set_unsupported_attribute
|
||||
if mname == "setArgumentAsUnknown"
|
||||
else getattr(ifcopenshell_wrapper.entity_instance, mname)
|
||||
)
|
||||
)
|
||||
for mname in fn_names
|
||||
]
|
||||
|
||||
@@ -203,15 +207,20 @@ class entity_instance:
|
||||
rules = importlib.import_module(f"ifcopenshell.express.rules.{schema_name}")
|
||||
except:
|
||||
import os
|
||||
current_dir_files = {fn.lower(): fn for fn in os.listdir('.')}
|
||||
exp_filename = schema_name.lower() + '.exp'
|
||||
|
||||
current_dir_files = {fn.lower(): fn for fn in os.listdir(".")}
|
||||
exp_filename = schema_name.lower() + ".exp"
|
||||
schema_path = current_dir_files.get(exp_filename)
|
||||
if schema_path is None:
|
||||
raise Exception(f"Couldn't find express file '{schema_name.lower()}.exp' in the current folder: '{os.getcwd()}'.")
|
||||
fn = schema_path[:-4] + '.py'
|
||||
raise Exception(
|
||||
f"Couldn't find express file '{schema_name.lower()}.exp' in the current folder: '{os.getcwd()}'."
|
||||
)
|
||||
fn = schema_path[:-4] + ".py"
|
||||
if not os.path.exists(fn):
|
||||
subprocess.run([sys.executable, "-m", "ifcopenshell.express.rule_compiler", schema_path, fn], check=True)
|
||||
time.sleep(1.)
|
||||
subprocess.run(
|
||||
[sys.executable, "-m", "ifcopenshell.express.rule_compiler", schema_path, fn], check=True
|
||||
)
|
||||
time.sleep(1.0)
|
||||
rules = importlib.import_module(schema_name)
|
||||
|
||||
def yield_supertypes():
|
||||
@@ -255,7 +264,7 @@ class entity_instance:
|
||||
# Define condition and transformation functions
|
||||
condition = lambda v: v == old
|
||||
transform = lambda v: new
|
||||
|
||||
|
||||
# Usage example
|
||||
attribute_value = element.RelatedElements
|
||||
print(old in attribute_value, new in attribute_value) # True, False
|
||||
|
||||
@@ -204,7 +204,6 @@ class application(QtWidgets.QApplication):
|
||||
with two tree views and a graphical 3d view"""
|
||||
|
||||
class abstract_treeview(QtWidgets.QTreeWidget):
|
||||
|
||||
"""Base class for the two treeview controls"""
|
||||
|
||||
instanceSelected = QtCore.pyqtSignal([object])
|
||||
@@ -255,7 +254,6 @@ class application(QtWidgets.QApplication):
|
||||
)
|
||||
|
||||
class decomposition_treeview(abstract_treeview):
|
||||
|
||||
"""Treeview with typical IFC decomposition relationships"""
|
||||
|
||||
ATTRIBUTES = ["Entity", "GlobalId", "Name"]
|
||||
@@ -301,7 +299,6 @@ class application(QtWidgets.QApplication):
|
||||
self.expandAll()
|
||||
|
||||
class type_treeview(abstract_treeview):
|
||||
|
||||
"""Treeview with typical IFC decomposition relationships"""
|
||||
|
||||
ATTRIBUTES = ["Name"]
|
||||
|
||||
@@ -37,7 +37,7 @@ def compress(g):
|
||||
bs = [int(g[i : i + 2], 16) for i in range(0, len(g), 2)]
|
||||
|
||||
def b64(v, l=4):
|
||||
return "".join([chars[(v // (64 ** i)) % 64] for i in range(l)][::-1])
|
||||
return "".join([chars[(v // (64**i)) % 64] for i in range(l)][::-1])
|
||||
|
||||
return "".join([b64(bs[0], 2)] + [b64((bs[i] << 16) + (bs[i + 1] << 8) + bs[i + 2]) for i in range(1, 16, 3)])
|
||||
|
||||
|
||||
@@ -33,4 +33,4 @@ element or None. Example:
|
||||
#2=IfcRelAssignsToGroup($,$,$,$,$,$,#1)
|
||||
"""
|
||||
|
||||
unpack_non_aggregate_inverses = False
|
||||
unpack_non_aggregate_inverses = False
|
||||
|
||||
@@ -11,19 +11,19 @@ try:
|
||||
class StreamTransformer(Transformer):
|
||||
def string(self, items):
|
||||
return str(items[0])[1:-1]
|
||||
|
||||
|
||||
def float(self, items):
|
||||
return float(items[0])
|
||||
|
||||
|
||||
def ifcint(self, items):
|
||||
return int(items[0])
|
||||
|
||||
|
||||
def null(self, items):
|
||||
return None
|
||||
|
||||
|
||||
def derived(self, items):
|
||||
return None
|
||||
|
||||
|
||||
def enum(self, items):
|
||||
if items[0] == ".T.":
|
||||
return True
|
||||
@@ -32,7 +32,7 @@ try:
|
||||
elif items[0] == ".U.":
|
||||
return "UNKNOWN"
|
||||
return str(items[0])[1:-1]
|
||||
|
||||
|
||||
def list(self, items):
|
||||
# List is always called twice, I think due to an ambiguity in the Lark
|
||||
# definition between a list and an arg, but I'm not quite sure.
|
||||
@@ -40,7 +40,7 @@ try:
|
||||
if items and isinstance(items[0], dict):
|
||||
return tuple(items[0]["list"])
|
||||
return {"list": items}
|
||||
|
||||
|
||||
def inline_type(self, items):
|
||||
# inline_type is also always called twice. Why?
|
||||
if items and isinstance(items[0], dict):
|
||||
@@ -48,20 +48,19 @@ try:
|
||||
entity = ifcopenshell.create_entity(items[0])
|
||||
entity[0] = items[1]
|
||||
return {"inline_type": entity}
|
||||
|
||||
|
||||
def reference(self, items):
|
||||
return self.file.by_id(int(items[0][1:]))
|
||||
|
||||
|
||||
def arg(self, items):
|
||||
return items[0]
|
||||
|
||||
|
||||
def args(self, items):
|
||||
return items
|
||||
|
||||
|
||||
def start(self, items):
|
||||
return (int(items[0]), str(items[1]), items[2])
|
||||
|
||||
|
||||
|
||||
class stream(file):
|
||||
def __init__(self, filepath):
|
||||
self.wrapped_data = None
|
||||
@@ -69,9 +68,9 @@ try:
|
||||
self.history = []
|
||||
self.future = []
|
||||
self.transaction = None
|
||||
|
||||
|
||||
self.filepath = filepath
|
||||
|
||||
|
||||
self.file = open(filepath, "r")
|
||||
self.id_map = {}
|
||||
self.class_map = {}
|
||||
@@ -80,7 +79,7 @@ try:
|
||||
self.reference_pattern = re.compile(r"#(\d+)")
|
||||
self.entity_cache = {}
|
||||
self.inverses = {}
|
||||
|
||||
|
||||
# common.INT doesn't support negative integers.
|
||||
grammar = r"""
|
||||
start: "#" NUMBER "=" TYPE "(" args ")" ";"
|
||||
@@ -114,11 +113,11 @@ try:
|
||||
%import common.INT
|
||||
%import common.CNAME
|
||||
"""
|
||||
|
||||
|
||||
transformer = StreamTransformer()
|
||||
transformer.file = self
|
||||
self.parser = Lark(grammar, parser="lalr", transformer=transformer)
|
||||
|
||||
|
||||
exclude_classes = [
|
||||
"IfcObjectPlacement",
|
||||
"IfcPresentationItem",
|
||||
@@ -128,9 +127,9 @@ try:
|
||||
"IfcRepresentationItem",
|
||||
]
|
||||
exclude_classes = []
|
||||
|
||||
|
||||
exclude = set()
|
||||
|
||||
|
||||
offset = 0
|
||||
for line in self.file:
|
||||
line = line.strip()
|
||||
@@ -138,14 +137,14 @@ try:
|
||||
step_id, ifc_class = line.split("(")[0].split("=")
|
||||
step_id = int(step_id.strip()[1:])
|
||||
ifc_class = ifc_class.strip()
|
||||
|
||||
|
||||
if ifc_class in exclude:
|
||||
offset += len(line) + 1 # +1 for the newline character
|
||||
continue
|
||||
|
||||
|
||||
for reference_id in self.reference_pattern.findall(line[1:]):
|
||||
self.inverses.setdefault(int(reference_id), []).append(step_id)
|
||||
|
||||
|
||||
self.id_map[step_id] = ifc_class
|
||||
self.class_map.setdefault(ifc_class, []).append(step_id)
|
||||
self.id_offset[step_id] = offset
|
||||
@@ -156,9 +155,9 @@ try:
|
||||
declaration = self.ifc_schema.declaration_by_name(ifc_class)
|
||||
exclude.update([st.name().upper() for st in ifcopenshell.util.schema.get_subtypes(declaration)])
|
||||
offset += len(line) + 1 # +1 for the newline character
|
||||
|
||||
|
||||
self.preprocess_schema()
|
||||
|
||||
|
||||
def preprocess_schema(self):
|
||||
self.ifc_class_names = {}
|
||||
self.ifc_class_subtypes = {}
|
||||
@@ -166,32 +165,32 @@ try:
|
||||
self.ifc_class_inverse_attributes = {}
|
||||
self.ifc_class_references = {}
|
||||
self.ifc_class_inverses = {}
|
||||
|
||||
|
||||
for declaration in self.ifc_schema.entities():
|
||||
self.ifc_class_names[declaration.name().upper()] = declaration.name()
|
||||
|
||||
|
||||
self.ifc_class_subtypes[declaration.name()] = ifcopenshell.util.schema.get_subtypes(declaration)
|
||||
self.ifc_class_attributes[declaration.name()] = {a.name(): a for a in declaration.all_attributes()}
|
||||
self.ifc_class_inverse_attributes[declaration.name()] = {
|
||||
a.name(): a for a in declaration.all_inverse_attributes()
|
||||
}
|
||||
|
||||
|
||||
entity = []
|
||||
entity_list = []
|
||||
for attribute in declaration.all_attributes():
|
||||
primitive = ifcopenshell.util.attribute.get_primitive_type(attribute)
|
||||
if primitive == "entity":
|
||||
entity.append(attribute.name())
|
||||
|
||||
|
||||
attribute_entity = attribute.type_of_attribute().declared_type()
|
||||
for subtype in ifcopenshell.util.schema.get_subtypes(attribute_entity):
|
||||
self.ifc_class_inverses.setdefault(subtype.name(), {})
|
||||
self.ifc_class_inverses[subtype.name()].setdefault(declaration.name(), [])
|
||||
self.ifc_class_inverses[subtype.name()][declaration.name()].append(attribute.name())
|
||||
|
||||
|
||||
elif self.is_entity_list(attribute):
|
||||
entity_list.append(attribute.name())
|
||||
|
||||
|
||||
for entity_name in re.findall("<entity (.*?)>", str(attribute)):
|
||||
attribute_entity = self.ifc_schema.declaration_by_name(entity_name)
|
||||
for subtype in ifcopenshell.util.schema.get_subtypes(attribute_entity):
|
||||
@@ -199,15 +198,15 @@ try:
|
||||
self.ifc_class_inverses.setdefault(subtype.name(), {})
|
||||
self.ifc_class_inverses[subtype.name()].setdefault(declaration.name(), [])
|
||||
self.ifc_class_inverses[subtype.name()][declaration.name()].append(attribute.name())
|
||||
|
||||
|
||||
self.ifc_class_references[declaration.name()] = {"entity": entity, "entity_list": entity_list}
|
||||
|
||||
|
||||
def clear_cache(self):
|
||||
self.entity_cache = {}
|
||||
|
||||
|
||||
def create_entity(self, type, *args, **kawrgs):
|
||||
assert False
|
||||
|
||||
|
||||
def by_id(self, id):
|
||||
entity = self.entity_cache.get(id, None)
|
||||
if entity:
|
||||
@@ -217,35 +216,35 @@ try:
|
||||
entity = stream_entity(id, self.ifc_class_names[ifc_class], self)
|
||||
self.entity_cache[id] = entity
|
||||
return entity
|
||||
|
||||
|
||||
def by_type(self, type, include_subtypes=True):
|
||||
results = []
|
||||
subtypes = self.ifc_class_subtypes[type] if include_subtypes else self.ifc_class_subtypes[type][0:1]
|
||||
for subtype in subtypes:
|
||||
results.extend([self.by_id(i) for i in self.class_map.get(subtype.name().upper(), [])])
|
||||
return results
|
||||
|
||||
|
||||
def traverse(self, inst, max_levels=None, breadth_first=False):
|
||||
results = [inst]
|
||||
queue = [inst]
|
||||
while queue:
|
||||
if max_levels is not None:
|
||||
max_levels -= 1
|
||||
|
||||
|
||||
cur = queue.pop()
|
||||
level_results = set()
|
||||
|
||||
|
||||
for reference_id in self.reference_pattern.findall(str(cur)[1:]):
|
||||
result = self.by_id(int(reference_id))
|
||||
results.append(result)
|
||||
if max_levels is None or max_levels:
|
||||
queue.append(result)
|
||||
|
||||
|
||||
return results
|
||||
|
||||
|
||||
def get_inverse(self, inst, allow_duplicate=False, with_attribute_indices=False):
|
||||
return {self.by_id(e) for e in self.inverses.get(inst.stream_wrapper.id, [])}
|
||||
|
||||
|
||||
def is_entity_list(self, attribute):
|
||||
attribute = str(attribute.type_of_attribute())
|
||||
if (attribute.startswith("<list") or attribute.startswith("<set")) and "<entity" in attribute:
|
||||
@@ -254,8 +253,7 @@ try:
|
||||
return False
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
|
||||
class stream_entity(entity_instance):
|
||||
def __init__(self, id, ifc_class, file=None):
|
||||
if not ifc_class:
|
||||
@@ -265,39 +263,39 @@ try:
|
||||
s = stream_wrapper(id, ifc_class, file)
|
||||
super(entity_instance, self).__setattr__("wrapped_data", e)
|
||||
super(entity_instance, self).__setattr__("stream_wrapper", s)
|
||||
|
||||
|
||||
def id(self):
|
||||
return self.stream_wrapper.id
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
offset = self.stream_wrapper.file.id_offset[self.stream_wrapper.id]
|
||||
self.stream_wrapper.file.file.seek(offset)
|
||||
return self.stream_wrapper.file.file.readline().strip()
|
||||
|
||||
|
||||
def __del__(self):
|
||||
pass
|
||||
|
||||
|
||||
def __getitem__(self, key):
|
||||
return self.__getattr__(list(self.stream_wrapper.attributes.keys())[key])
|
||||
|
||||
|
||||
def __setattr__(self, key, value):
|
||||
query = f"UPDATE `{self.stream_wrapper.ifc_class}` SET `{key}` = ? WHERE ifc_id = {self.stream_wrapper.id}"
|
||||
self.stream_wrapper.file.cursor.execute(query, (value,))
|
||||
self.stream_wrapper.file.db.commit()
|
||||
self.stream_wrapper.attribute_cache = {}
|
||||
|
||||
|
||||
def __getattr__(self, name):
|
||||
INVALID, FORWARD, INVERSE = range(3)
|
||||
attr_cat = self.wrapped_data.get_attribute_category(name)
|
||||
if attr_cat == FORWARD:
|
||||
if self.stream_wrapper.attribute_cache:
|
||||
return self.stream_wrapper.attribute_cache[name]
|
||||
|
||||
|
||||
offset = self.stream_wrapper.file.id_offset[self.stream_wrapper.id]
|
||||
self.stream_wrapper.file.file.seek(offset)
|
||||
line = self.stream_wrapper.file.file.readline()
|
||||
attributes = self.stream_wrapper.file.parser.parse(line.strip())[2]
|
||||
|
||||
|
||||
for i, attribute in enumerate(self.stream_wrapper.attributes.values()):
|
||||
self.stream_wrapper.attribute_cache[attribute.name()] = attributes[i]
|
||||
return self.stream_wrapper.attribute_cache[name]
|
||||
@@ -306,19 +304,19 @@ try:
|
||||
results = self.stream_wrapper.inverse_attribute_cache.get(name, None)
|
||||
if results is not None:
|
||||
return results
|
||||
|
||||
|
||||
results = []
|
||||
|
||||
|
||||
element_ids = self.stream_wrapper.file.inverses.get(self.stream_wrapper.id, [])
|
||||
if not element_ids:
|
||||
self.stream_wrapper.inverse_attribute_cache[name] = tuple()
|
||||
return self.stream_wrapper.inverse_attribute_cache[name]
|
||||
|
||||
|
||||
attribute = self.stream_wrapper.inverse_attributes[name]
|
||||
entity_class = attribute.entity_reference().name()
|
||||
declaration = self.stream_wrapper.file.ifc_schema.declaration_by_name(entity_class)
|
||||
forward_name = attribute.attribute_reference().name()
|
||||
|
||||
|
||||
subtypes = [st.name() for st in ifcopenshell.util.schema.get_subtypes(declaration)]
|
||||
for element_id in element_ids:
|
||||
ifc_class = self.stream_wrapper.file.ifc_class_names[self.stream_wrapper.file.id_map[element_id]]
|
||||
@@ -332,14 +330,14 @@ try:
|
||||
results.append(potential_result)
|
||||
elif forward_value.id() == self.stream_wrapper.id:
|
||||
results.append(potential_result)
|
||||
|
||||
|
||||
self.stream_wrapper.inverse_attribute_cache[name] = tuple(results)
|
||||
return self.stream_wrapper.inverse_attribute_cache[name]
|
||||
|
||||
|
||||
raise AttributeError(
|
||||
"entity instance of type '%s' has no attribute '%s'" % (self.wrapped_data.is_a(True), name)
|
||||
)
|
||||
|
||||
|
||||
def __eq__(self, other):
|
||||
if not isinstance(self, type(other)):
|
||||
return False
|
||||
@@ -348,19 +346,18 @@ try:
|
||||
if self.stream_wrapper.id:
|
||||
return self.stream_wrapper.id == other.stream_wrapper.id
|
||||
assert False # not implemented
|
||||
|
||||
|
||||
def __hash__(self):
|
||||
if self.stream_wrapper.id:
|
||||
return hash((self.stream_wrapper.id, self.stream_wrapper.file.filepath))
|
||||
|
||||
|
||||
def get_info(self, include_identifier=True, recursive=False, return_type=dict, ignore=(), scalar_only=False):
|
||||
info = {"id": self.stream_wrapper.id, "type": self.stream_wrapper.ifc_class}
|
||||
if not self.stream_wrapper.attribute_cache:
|
||||
self.__getitem__(0) # This will get all attributes
|
||||
info.update(self.stream_wrapper.attribute_cache)
|
||||
return info
|
||||
|
||||
|
||||
|
||||
class stream_wrapper:
|
||||
def __init__(self, id, ifc_class, file):
|
||||
self.id = id
|
||||
@@ -370,10 +367,11 @@ try:
|
||||
self.inverse_attributes = self.file.ifc_class_inverse_attributes[self.ifc_class]
|
||||
self.attribute_cache = {}
|
||||
self.inverse_attribute_cache = {}
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
return "todo"
|
||||
|
||||
except ImportError as e:
|
||||
import sys
|
||||
|
||||
print(f"No stream support: {e}", file=sys.stderr)
|
||||
|
||||
@@ -60,14 +60,14 @@ class TransitionCurve:
|
||||
def _calc_biquadratic_parabola_point(self, lpt, L, R, ccw):
|
||||
x = lpt
|
||||
if x <= (L / 2):
|
||||
y = x ** 4 / (6 * R * L ** 2)
|
||||
y = x**4 / (6 * R * L**2)
|
||||
else:
|
||||
|
||||
yterm_1 = (-1 * x ** 4) / (6 * R * L ** 2)
|
||||
yterm_2 = (2 * x ** 3) / (3 * R * L)
|
||||
yterm_3 = x ** 2 / (2 * R)
|
||||
yterm_1 = (-1 * x**4) / (6 * R * L**2)
|
||||
yterm_2 = (2 * x**3) / (3 * R * L)
|
||||
yterm_3 = x**2 / (2 * R)
|
||||
yterm_4 = (L * x) / (6 * R)
|
||||
yterm_5 = L ** 2 / (48 * R)
|
||||
yterm_5 = L**2 / (48 * R)
|
||||
|
||||
y = yterm_1 + yterm_2 - yterm_3 + yterm_4 - yterm_5
|
||||
|
||||
@@ -82,16 +82,16 @@ class TransitionCurve:
|
||||
def _calc_clothoid_curve_point(self, lpt, L, R, ccw):
|
||||
RL = R * L
|
||||
xterm_1 = 1
|
||||
xterm_2 = lpt ** 4 / (40 * RL ** 2)
|
||||
xterm_3 = lpt ** 8 / (3456 * RL ** 4)
|
||||
xterm_4 = lpt ** 12 / (599040 * RL ** 6)
|
||||
xterm_2 = lpt**4 / (40 * RL**2)
|
||||
xterm_3 = lpt**8 / (3456 * RL**4)
|
||||
xterm_4 = lpt**12 / (599040 * RL**6)
|
||||
x = lpt * (xterm_1 - xterm_2 + xterm_3 - xterm_4)
|
||||
|
||||
factor = lpt ** 3 / (6 * RL)
|
||||
factor = lpt**3 / (6 * RL)
|
||||
yterm_1 = 1
|
||||
yterm_2 = lpt ** 4 / (56 * RL ** 2)
|
||||
yterm_3 = lpt ** 8 / (7040 * RL ** 4)
|
||||
yterm_4 = lpt ** 12 / (1612800 * RL ** 6)
|
||||
yterm_2 = lpt**4 / (56 * RL**2)
|
||||
yterm_3 = lpt**8 / (7040 * RL**4)
|
||||
yterm_4 = lpt**12 / (1612800 * RL**6)
|
||||
|
||||
y = factor * (yterm_1 - yterm_2 + yterm_3 - yterm_4)
|
||||
|
||||
@@ -104,9 +104,9 @@ class TransitionCurve:
|
||||
pi = math.pi
|
||||
psi_x = (pi * lpt) / L
|
||||
|
||||
xterm_1 = (L ** 2) / (8.0 * pi ** 2 * R ** 2)
|
||||
xterm_1 = (L**2) / (8.0 * pi**2 * R**2)
|
||||
xterm_2 = L / pi
|
||||
xterm_3 = psi_x ** 3 / (3.0)
|
||||
xterm_3 = psi_x**3 / (3.0)
|
||||
xterm_4 = psi_x / (2.0)
|
||||
xterm_5 = (math.sin(psi_x) * math.cos(psi_x)) / (2.0)
|
||||
xterm_6 = psi_x * math.cos(psi_x)
|
||||
|
||||
@@ -130,6 +130,8 @@ def get_attributes_keep_md(resource, builder):
|
||||
|
||||
# Temporary fix for https://github.com/buildingSMART/IFC4.3.x-development/issues/754.
|
||||
_original_get_resource_path = get_resource_path
|
||||
|
||||
|
||||
def get_resource_path(resource: str, abort_on_error=False) -> Union[str, None]:
|
||||
md = _original_get_resource_path(resource, abort_on_error)
|
||||
if md and resource == "IfcURIReference":
|
||||
|
||||
@@ -74,8 +74,7 @@ def get_calendar(task: ifcopenshell.entity_instance) -> Union[ifcopenshell.entit
|
||||
calendar = [
|
||||
rel.RelatingControl
|
||||
for rel in task.HasAssignments or []
|
||||
if rel.is_a("IfcRelAssignsToControl")
|
||||
and rel.RelatingControl.is_a("IfcWorkCalendar")
|
||||
if rel.is_a("IfcRelAssignsToControl") and rel.RelatingControl.is_a("IfcWorkCalendar")
|
||||
]
|
||||
if calendar:
|
||||
return calendar[0]
|
||||
@@ -88,11 +87,7 @@ def count_working_days(start, finish, calendar: ifcopenshell.entity_instance) ->
|
||||
current_date = datetime.date(start.year, start.month, start.day)
|
||||
finish_date = datetime.date(finish.year, finish.month, finish.day)
|
||||
while current_date <= finish_date:
|
||||
if (
|
||||
calendar
|
||||
and calendar.WorkingTimes
|
||||
and is_working_day(current_date, calendar)
|
||||
):
|
||||
if calendar and calendar.WorkingTimes and is_working_day(current_date, calendar):
|
||||
result += 1
|
||||
elif not calendar or not is_calendar_applicable(current_date, calendar):
|
||||
result += 1
|
||||
@@ -132,9 +127,7 @@ def offset_date(start, duration, duration_type: DURATION_TYPE, calendar: ifcopen
|
||||
abs_duration = abs((duration.days + months * 30 + years * 12 * 30))
|
||||
date_offset = datetime.timedelta(days=1 if duration.days > 0 else -1)
|
||||
while abs_duration > 0:
|
||||
if duration_type == "ELAPSEDTIME" or not is_calendar_applicable(
|
||||
current_date, calendar
|
||||
):
|
||||
if duration_type == "ELAPSEDTIME" or not is_calendar_applicable(current_date, calendar):
|
||||
abs_duration -= 1
|
||||
elif is_working_day(current_date, calendar):
|
||||
abs_duration -= 1
|
||||
@@ -245,16 +238,13 @@ def is_work_time_applicable_to_day(work_time: ifcopenshell.entity_instance, day)
|
||||
return False # TODO
|
||||
elif recurrence_type == "MONTHLY_BY_POSITION":
|
||||
if not recurrence.Interval and not recurrence.Occurrences:
|
||||
return (day.weekday() + 1) in recurrence.WeekdayComponent and floor(
|
||||
day.day / 7
|
||||
) + 1 == recurrence["Position"]
|
||||
return (day.weekday() + 1) in recurrence.WeekdayComponent and floor(day.day / 7) + 1 == recurrence[
|
||||
"Position"
|
||||
]
|
||||
return False # TODO
|
||||
elif recurrence_type == "YEARLY_BY_DAY_OF_MONTH":
|
||||
if not recurrence.Interval and not recurrence.Occurrences:
|
||||
return (
|
||||
day.month in recurrence.MonthComponent
|
||||
and day.day in recurrence.DayComponent
|
||||
)
|
||||
return day.month in recurrence.MonthComponent and day.day in recurrence.DayComponent
|
||||
return False # TODO
|
||||
elif recurrence_type == "YEARLY_BY_POSITION":
|
||||
if not recurrence.Interval and not recurrence.Occurrences:
|
||||
@@ -272,9 +262,7 @@ def get_task_work_schedule(task: ifcopenshell.entity_instance) -> Union[ifcopens
|
||||
return get_task_work_schedule(parent_task) or get_task_work_schedule(task)
|
||||
else:
|
||||
for rel in task.HasAssignments:
|
||||
if rel.is_a("IfcRelAssignsToControl") and rel.RelatingControl.is_a(
|
||||
"IfcWorkSchedule"
|
||||
):
|
||||
if rel.is_a("IfcRelAssignsToControl") and rel.RelatingControl.is_a("IfcWorkSchedule"):
|
||||
return rel.RelatingControl
|
||||
return None
|
||||
|
||||
@@ -304,21 +292,11 @@ def get_work_schedule_tasks(work_schedule: ifcopenshell.entity_instance) -> list
|
||||
|
||||
|
||||
def get_root_tasks(work_schedule: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_instance]:
|
||||
return [
|
||||
obj
|
||||
for rel in work_schedule.Controls
|
||||
for obj in rel.RelatedObjects
|
||||
if obj.is_a("IfcTask")
|
||||
]
|
||||
return [obj for rel in work_schedule.Controls for obj in rel.RelatedObjects if obj.is_a("IfcTask")]
|
||||
|
||||
|
||||
def get_root_tasks_ids(work_schedule: ifcopenshell.entity_instance) -> list[int]:
|
||||
return [
|
||||
obj.id()
|
||||
for rel in work_schedule.Controls
|
||||
for obj in rel.RelatedObjects
|
||||
if obj.is_a("IfcTask")
|
||||
]
|
||||
return [obj.id() for rel in work_schedule.Controls for obj in rel.RelatedObjects if obj.is_a("IfcTask")]
|
||||
|
||||
|
||||
def guess_date_range(work_schedule: ifcopenshell.entity_instance):
|
||||
@@ -344,22 +322,14 @@ def guess_date_range(work_schedule: ifcopenshell.entity_instance):
|
||||
|
||||
|
||||
def get_direct_task_outputs(task: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_instance]:
|
||||
return [
|
||||
rel.RelatingProduct
|
||||
for rel in task.HasAssignments
|
||||
if rel.is_a("IfcRelAssignsToProduct")
|
||||
]
|
||||
return [rel.RelatingProduct for rel in task.HasAssignments if rel.is_a("IfcRelAssignsToProduct")]
|
||||
|
||||
|
||||
def get_task_outputs(task: ifcopenshell.entity_instance, is_deep: bool = False) -> list[ifcopenshell.entity_instance]:
|
||||
if not is_deep:
|
||||
return get_direct_task_outputs(task)
|
||||
else:
|
||||
return [
|
||||
output
|
||||
for nested_task in get_all_nested_tasks(task)
|
||||
for output in get_direct_task_outputs(nested_task)
|
||||
]
|
||||
return [output for nested_task in get_all_nested_tasks(task) for output in get_direct_task_outputs(nested_task)]
|
||||
|
||||
|
||||
def get_task_inputs(task: ifcopenshell.entity_instance, is_deep: bool = False) -> list[ifcopenshell.entity_instance]:
|
||||
@@ -434,8 +404,7 @@ def get_tasks_for_product(
|
||||
inputs = [
|
||||
assignement.RelatingProcess
|
||||
for assignement in product.HasAssignments
|
||||
if assignement.is_a("IfcRelAssignsToProcess")
|
||||
and assignement.RelatingProcess.is_a("IfcTask")
|
||||
if assignement.is_a("IfcRelAssignsToProcess") and assignement.RelatingProcess.is_a("IfcTask")
|
||||
]
|
||||
outputs = [
|
||||
obj
|
||||
@@ -446,16 +415,8 @@ def get_tasks_for_product(
|
||||
]
|
||||
|
||||
if schedule:
|
||||
inputs = [
|
||||
task
|
||||
for task in inputs
|
||||
if get_task_work_schedule(task).id() == schedule.id()
|
||||
]
|
||||
outputs = [
|
||||
task
|
||||
for task in outputs
|
||||
if get_task_work_schedule(task).id() == schedule.id()
|
||||
]
|
||||
inputs = [task for task in inputs if get_task_work_schedule(task).id() == schedule.id()]
|
||||
outputs = [task for task in outputs if get_task_work_schedule(task).id() == schedule.id()]
|
||||
|
||||
return inputs, outputs
|
||||
|
||||
|
||||
@@ -36,9 +36,7 @@ class TestRemoveReference(test.bootstrap.IFC4):
|
||||
name="Foobar",
|
||||
classification=result,
|
||||
)
|
||||
ifcopenshell.api.classification.remove_reference(
|
||||
self.file, products=[element, element2], reference=reference
|
||||
)
|
||||
ifcopenshell.api.classification.remove_reference(self.file, products=[element, element2], reference=reference)
|
||||
assert len(ifcopenshell.util.classification.get_references(element)) == 0
|
||||
assert len(ifcopenshell.util.classification.get_references(element2)) == 0
|
||||
assert len(self.file.by_type("IfcClassificationReference")) == 0
|
||||
@@ -90,9 +88,7 @@ class TestRemoveReference(test.bootstrap.IFC4):
|
||||
classification=result,
|
||||
)
|
||||
assert len(self.file.by_type("IfcClassificationReference")) == 1
|
||||
ifcopenshell.api.classification.remove_reference(
|
||||
self.file, products=[element, element2], reference=reference
|
||||
)
|
||||
ifcopenshell.api.classification.remove_reference(self.file, products=[element, element2], reference=reference)
|
||||
assert len(self.file.by_type("IfcClassificationReference")) == 1
|
||||
ifcopenshell.api.classification.remove_reference(self.file, products=[element3], reference=reference)
|
||||
assert len(self.file.by_type("IfcClassificationReference")) == 0
|
||||
|
||||
@@ -27,9 +27,7 @@ class TestAssignConstraint(test.bootstrap.IFC4):
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
constraint = ifcopenshell.api.constraint.add_objective(self.file)
|
||||
ifcopenshell.api.constraint.assign_constraint(
|
||||
self.file, products=[element, element2], constraint=constraint
|
||||
)
|
||||
ifcopenshell.api.constraint.assign_constraint(self.file, products=[element, element2], constraint=constraint)
|
||||
assert ifcopenshell.util.constraint.get_constrained_elements(constraint) == {element, element2}
|
||||
assert len(self.file.by_type("IfcRelAssociatesConstraint")) == 1
|
||||
|
||||
@@ -37,13 +35,9 @@ class TestAssignConstraint(test.bootstrap.IFC4):
|
||||
constraint = ifcopenshell.api.constraint.add_objective(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.constraint.assign_constraint(
|
||||
self.file, products=[element, element2], constraint=constraint
|
||||
)
|
||||
ifcopenshell.api.constraint.assign_constraint(self.file, products=[element, element2], constraint=constraint)
|
||||
total_elements = len([e for e in self.file])
|
||||
ifcopenshell.api.constraint.assign_constraint(
|
||||
self.file, products=[element, element2], constraint=constraint
|
||||
)
|
||||
ifcopenshell.api.constraint.assign_constraint(self.file, products=[element, element2], constraint=constraint)
|
||||
assert len([e for e in self.file]) == total_elements
|
||||
|
||||
def test_that_old_relationships_are_updated_if_they_still_contain_elements(self):
|
||||
@@ -54,9 +48,7 @@ class TestAssignConstraint(test.bootstrap.IFC4):
|
||||
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.constraint.assign_constraint(
|
||||
self.file, products=[element2, element3], constraint=constraint
|
||||
)
|
||||
ifcopenshell.api.constraint.assign_constraint(self.file, products=[element2, element3], constraint=constraint)
|
||||
assert len(rel.RelatedObjects) == 3
|
||||
|
||||
|
||||
|
||||
@@ -27,12 +27,8 @@ class TestUnassignConstraint(test.bootstrap.IFC4):
|
||||
constraint = ifcopenshell.api.constraint.add_objective(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.constraint.assign_constraint(
|
||||
self.file, products=[element, element2], constraint=constraint
|
||||
)
|
||||
ifcopenshell.api.constraint.unassign_constraint(
|
||||
self.file, products=[element, element2], constraint=constraint
|
||||
)
|
||||
ifcopenshell.api.constraint.assign_constraint(self.file, products=[element, element2], constraint=constraint)
|
||||
ifcopenshell.api.constraint.unassign_constraint(self.file, products=[element, element2], constraint=constraint)
|
||||
assert ifcopenshell.util.constraint.get_constrained_elements(element) == set()
|
||||
assert len(self.file.by_type("IfcRelAssociatesConstraint")) == 0
|
||||
|
||||
@@ -40,9 +36,7 @@ class TestUnassignConstraint(test.bootstrap.IFC4):
|
||||
constraint = ifcopenshell.api.constraint.add_objective(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.constraint.unassign_constraint(
|
||||
self.file, products=[element, element2], constraint=constraint
|
||||
)
|
||||
ifcopenshell.api.constraint.unassign_constraint(self.file, products=[element, element2], constraint=constraint)
|
||||
assert ifcopenshell.util.constraint.get_constrained_elements(element) == set()
|
||||
assert ifcopenshell.util.constraint.get_constrained_elements(element2) == set()
|
||||
|
||||
@@ -54,12 +48,8 @@ class TestUnassignConstraint(test.bootstrap.IFC4):
|
||||
ifcopenshell.api.constraint.assign_constraint(self.file, products=[element1], constraint=constraint)
|
||||
rel = self.file.by_type("IfcRelAssociatesConstraint")[0]
|
||||
|
||||
ifcopenshell.api.constraint.assign_constraint(
|
||||
self.file, products=[element2, element3], constraint=constraint
|
||||
)
|
||||
ifcopenshell.api.constraint.unassign_constraint(
|
||||
self.file, products=[element1, element2], constraint=constraint
|
||||
)
|
||||
ifcopenshell.api.constraint.assign_constraint(self.file, products=[element2, element3], constraint=constraint)
|
||||
ifcopenshell.api.constraint.unassign_constraint(self.file, products=[element1, element2], constraint=constraint)
|
||||
assert rel.RelatedObjects == (element3,)
|
||||
|
||||
|
||||
|
||||
@@ -27,24 +27,18 @@ class TestAssignControl(test.bootstrap.IFC4):
|
||||
control = ifcopenshell.api.cost.add_cost_schedule(self.file)
|
||||
|
||||
# simple assignment
|
||||
relation = ifcopenshell.api.control.assign_control(
|
||||
self.file, relating_control=control, related_object=wall
|
||||
)
|
||||
relation = ifcopenshell.api.control.assign_control(self.file, relating_control=control, related_object=wall)
|
||||
assert len(self.file.by_type("IfcRelAssignsToControl")) == 1
|
||||
assert relation.RelatingControl == control
|
||||
assert relation.RelatedObjects == (wall,)
|
||||
|
||||
# trying to establish existing relationship
|
||||
relation = ifcopenshell.api.control.assign_control(
|
||||
self.file, relating_control=control, related_object=wall
|
||||
)
|
||||
relation = ifcopenshell.api.control.assign_control(self.file, relating_control=control, related_object=wall)
|
||||
assert relation is None
|
||||
|
||||
# assigning same control to another object
|
||||
wall1 = self.file.createIfcWall()
|
||||
relation = ifcopenshell.api.control.assign_control(
|
||||
self.file, relating_control=control, related_object=wall1
|
||||
)
|
||||
relation = ifcopenshell.api.control.assign_control(self.file, relating_control=control, related_object=wall1)
|
||||
assert relation is not None
|
||||
assert len(self.file.by_type("IfcRelAssignsToControl")) == 1
|
||||
assert relation.RelatingControl == control
|
||||
|
||||
@@ -27,17 +27,13 @@ class TestUnassignControl(test.bootstrap.IFC4):
|
||||
control = ifcopenshell.api.cost.add_cost_schedule(self.file)
|
||||
|
||||
# assign and unassign
|
||||
relation = ifcopenshell.api.control.assign_control(
|
||||
self.file, relating_control=control, related_object=wall
|
||||
)
|
||||
relation = ifcopenshell.api.control.assign_control(self.file, relating_control=control, related_object=wall)
|
||||
ifcopenshell.api.control.unassign_control(self.file, relating_control=control, related_object=wall)
|
||||
assert len(self.file.by_type("IfcRelAssignsToControl")) == 0
|
||||
|
||||
# 1 control 2 related objects
|
||||
wall1 = self.file.createIfcWall()
|
||||
relation = ifcopenshell.api.control.assign_control(
|
||||
self.file, relating_control=control, related_object=wall
|
||||
)
|
||||
relation = ifcopenshell.api.control.assign_control(self.file, relating_control=control, related_object=wall)
|
||||
ifcopenshell.api.control.assign_control(self.file, relating_control=control, related_object=wall1)
|
||||
ifcopenshell.api.control.unassign_control(self.file, relating_control=control, related_object=wall1)
|
||||
assert len(self.file.by_type("IfcRelAssignsToControl")) == 1
|
||||
|
||||
@@ -33,9 +33,7 @@ class TestAddCostItemQuantity(test.bootstrap.IFC4):
|
||||
|
||||
quantities = []
|
||||
for quantity_type in quantity_types:
|
||||
quantity = ifcopenshell.api.cost.add_cost_item_quantity(
|
||||
self.file, cost_item=item, ifc_class=quantity_type
|
||||
)
|
||||
quantity = ifcopenshell.api.cost.add_cost_item_quantity(self.file, cost_item=item, ifc_class=quantity_type)
|
||||
assert quantity.is_a(quantity_type)
|
||||
assert quantity.Name == "Unnamed"
|
||||
if quantity_type == "IfcQuantityCount":
|
||||
|
||||
@@ -36,9 +36,7 @@ class TestUnassignDocument(test.bootstrap.IFC4):
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
reference = ifcopenshell.api.document.add_reference(self.file, information=None)
|
||||
ifcopenshell.api.document.assign_document(
|
||||
self.file, products=[element, element2, element3], document=reference
|
||||
)
|
||||
ifcopenshell.api.document.assign_document(self.file, products=[element, element2, element3], document=reference)
|
||||
ifcopenshell.api.document.unassign_document(self.file, products=[element, element2], document=reference)
|
||||
assert ifcopenshell.util.element.get_referenced_elements(reference) == {element3}
|
||||
|
||||
|
||||
@@ -30,9 +30,7 @@ class TestUnassignRepresentation(test.bootstrap.IFC4):
|
||||
)
|
||||
ifcopenshell.api.geometry.unassign_representation(self.file, product=wall, representation=representation)
|
||||
assert representation not in wall.Representation.Representations
|
||||
ifcopenshell.api.geometry.unassign_representation(
|
||||
self.file, product=wall, representation=representation2
|
||||
)
|
||||
ifcopenshell.api.geometry.unassign_representation(self.file, product=wall, representation=representation2)
|
||||
assert not wall.Representation
|
||||
assert len(self.file.by_type("IfcShapeRepresentation")) == 2
|
||||
assert len(self.file.by_type("IfcProductDefinitionShape")) == 0
|
||||
@@ -42,9 +40,7 @@ class TestUnassignRepresentation(test.bootstrap.IFC4):
|
||||
origin = self.file.createIfcAxis2Placement3D()
|
||||
repmap = self.file.createIfcRepresentationMap(MappedRepresentation=representation, MappingOrigin=origin)
|
||||
walltype = self.file.createIfcWallType(RepresentationMaps=[repmap])
|
||||
ifcopenshell.api.geometry.unassign_representation(
|
||||
self.file, product=walltype, representation=representation
|
||||
)
|
||||
ifcopenshell.api.geometry.unassign_representation(self.file, product=walltype, representation=representation)
|
||||
assert not walltype.RepresentationMaps
|
||||
assert len(self.file.by_type("IfcAxis2Placement3D")) == 0
|
||||
assert len(self.file.by_type("IfcRepresentationMap")) == 0
|
||||
@@ -59,9 +55,7 @@ class TestUnassignRepresentation(test.bootstrap.IFC4):
|
||||
rep = self.file.createIfcShapeRepresentation(Items=[mapped_item])
|
||||
prodrep = self.file.createIfcProductDefinitionShape(Representations=[rep])
|
||||
wall = self.file.createIfcWall(Representation=prodrep)
|
||||
ifcopenshell.api.geometry.unassign_representation(
|
||||
self.file, product=walltype, representation=representation
|
||||
)
|
||||
ifcopenshell.api.geometry.unassign_representation(self.file, product=walltype, representation=representation)
|
||||
assert not walltype.RepresentationMaps
|
||||
assert len(self.file.by_type("IfcAxis2Placement3D")) == 0
|
||||
assert len(self.file.by_type("IfcRepresentationMap")) == 0
|
||||
|
||||
@@ -33,5 +33,6 @@ class TestUnassignReference(test.bootstrap.IFC4):
|
||||
assert ifcopenshell.util.element.get_referenced_elements(reference) == set()
|
||||
assert len(self.file.by_type("IfcRelAssociatesLibrary")) == 0
|
||||
|
||||
|
||||
class TestUnassignReferenceIFC2X3(test.bootstrap.IFC2X3, TestUnassignReference):
|
||||
pass
|
||||
|
||||
@@ -111,9 +111,7 @@ class TestRemoveMaterialIFC4(test.bootstrap.IFC4, TestRemoveMaterialIFC2X3):
|
||||
def test_removing_material_in_constituent(self):
|
||||
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.material.add_material(self.file)
|
||||
material_set = ifcopenshell.api.material.add_material_set(
|
||||
self.file, set_type="IfcMaterialConstituentSet"
|
||||
)
|
||||
material_set = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialConstituentSet")
|
||||
ifcopenshell.api.material.add_constituent(self.file, constituent_set=material_set, material=material)
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[wall], material=material_set)
|
||||
assert len(self.file.by_type("IfcMaterialConstituentSet")[0].MaterialConstituents) == 1
|
||||
|
||||
@@ -79,9 +79,7 @@ class TestAssignObject(test.bootstrap.IFC4):
|
||||
|
||||
# maintain the order in the affected relationships too
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
|
||||
ifcopenshell.api.nest.assign_object(
|
||||
self.file, related_objects=subelements[2:3], relating_object=element2
|
||||
)
|
||||
ifcopenshell.api.nest.assign_object(self.file, related_objects=subelements[2:3], relating_object=element2)
|
||||
assert rel.RelatedObjects == tuple(subelements[:2] + subelements[3:])
|
||||
|
||||
|
||||
|
||||
@@ -24,9 +24,7 @@ class TestAddPersonAndOrganisation(test.bootstrap.IFC4):
|
||||
def test_adding(self):
|
||||
person = self.file.createIfcPerson()
|
||||
organisation = self.file.createIfcOrganization()
|
||||
ifcopenshell.api.owner.add_person_and_organisation(
|
||||
self.file, person=person, organisation=organisation
|
||||
)
|
||||
ifcopenshell.api.owner.add_person_and_organisation(self.file, person=person, organisation=organisation)
|
||||
|
||||
|
||||
class TestAddPersonAndOrganisationIFC2X3(test.bootstrap.IFC2X3, TestAddPersonAndOrganisation):
|
||||
|
||||
@@ -57,9 +57,7 @@ class TestAssignDeclaration(test.bootstrap.IFC4):
|
||||
def test_that_old_relationships_are_updated_if_they_still_contain_elements(self):
|
||||
element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
library = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProjectLibrary")
|
||||
ifcopenshell.api.project.assign_declaration(
|
||||
self.file, definitions=[element_type], relating_context=library
|
||||
)
|
||||
ifcopenshell.api.project.assign_declaration(self.file, definitions=[element_type], relating_context=library)
|
||||
rel = self.file.by_type("IfcRelDeclares")[0]
|
||||
|
||||
element_type2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
|
||||
@@ -61,9 +61,7 @@ class TestUnassignDeclaration(test.bootstrap.IFC4):
|
||||
element_type1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element_type2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element_type3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.project.assign_declaration(
|
||||
self.file, definitions=[element_type1], relating_context=library
|
||||
)
|
||||
ifcopenshell.api.project.assign_declaration(self.file, definitions=[element_type1], relating_context=library)
|
||||
rel = self.file.by_type("IfcRelDeclares")[0]
|
||||
|
||||
ifcopenshell.api.project.assign_declaration(
|
||||
|
||||
@@ -183,9 +183,7 @@ class TestEditPset(test.bootstrap.IFC4):
|
||||
assert pset.HasProperties[0].NominalValue.wrappedValue == 34
|
||||
|
||||
def test_editing_list_valued_properties(self):
|
||||
cable = ifcopenshell.api.root.create_entity(
|
||||
self.file, ifc_class="IfcDistributionPort", predefined_type="CABLE"
|
||||
)
|
||||
cable = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcDistributionPort", predefined_type="CABLE")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=cable, name="Pset_DistributionPortTypeCable")
|
||||
ifcopenshell.api.pset.edit_pset(
|
||||
self.file,
|
||||
|
||||
@@ -29,9 +29,7 @@ class TestEditPropTemplate(test.bootstrap.IFC4):
|
||||
prop_template=prop,
|
||||
attributes={"Name": "DemoA", "PrimaryMeasureType": "IfcLabel"},
|
||||
)
|
||||
ifcopenshell.api.pset_template.edit_prop_template(
|
||||
self.file, prop_template=prop, attributes={"Name": "DemoB"}
|
||||
)
|
||||
ifcopenshell.api.pset_template.edit_prop_template(self.file, prop_template=prop, attributes={"Name": "DemoB"})
|
||||
assert prop.Name == "DemoB"
|
||||
|
||||
def test_editing_an_enumeration(self):
|
||||
|
||||
@@ -62,9 +62,7 @@ class TestReassignClass(test.bootstrap.IFC4):
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element2], relating_type=element_type)
|
||||
|
||||
element_type = ifcopenshell.api.root.reassign_class(
|
||||
self.file, product=element_type, ifc_class="IfcSlabType"
|
||||
)
|
||||
element_type = ifcopenshell.api.root.reassign_class(self.file, product=element_type, ifc_class="IfcSlabType")
|
||||
|
||||
# type occurrences have reassigned classes
|
||||
occurrences = ifcopenshell.util.element.get_types(element_type)
|
||||
|
||||
@@ -93,12 +93,8 @@ class TestAssignContainer(test.bootstrap.IFC4):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
)
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=element1, matrix=matrix1.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=element2, matrix=matrix2.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element1, matrix=matrix1.copy(), is_si=False)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element2, matrix=matrix2.copy(), is_si=False)
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=subelement, matrix=matrix1.copy(), is_si=False
|
||||
)
|
||||
|
||||
@@ -51,9 +51,7 @@ class TestDereferenceStructure(test.bootstrap.IFC4):
|
||||
subelement1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
subelement3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.spatial.reference_structure(
|
||||
self.file, products=[subelement1], relating_structure=element
|
||||
)
|
||||
ifcopenshell.api.spatial.reference_structure(self.file, products=[subelement1], relating_structure=element)
|
||||
ifcopenshell.api.spatial.reference_structure(
|
||||
self.file, products=[subelement2, subelement3], relating_structure=element
|
||||
)
|
||||
|
||||
@@ -82,9 +82,7 @@ class TestAssignMaterialStyleIFC4(test.bootstrap.IFC4, TestAssignMaterialStyleIF
|
||||
|
||||
style = self.file.createIfcSurfaceStyle()
|
||||
material = ifcopenshell.api.material.add_material(self.file)
|
||||
material_set = ifcopenshell.api.material.add_material_set(
|
||||
self.file, set_type="IfcMaterialConstituentSet"
|
||||
)
|
||||
material_set = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialConstituentSet")
|
||||
constituent = ifcopenshell.api.material.add_constituent(
|
||||
self.file, constituent_set=material_set, material=material
|
||||
)
|
||||
|
||||
@@ -61,9 +61,7 @@ class TestAssignPort(test.bootstrap.IFC4):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
)
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=element, matrix=matrix.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix.copy(), is_si=False)
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
)
|
||||
|
||||
@@ -51,9 +51,7 @@ class TestAssignType(test.bootstrap.IFC4):
|
||||
element_type2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(
|
||||
self.file, related_objects=[element1, element2], relating_type=element_type1
|
||||
)
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element1, element2], relating_type=element_type1)
|
||||
rel = element1.IsDefinedBy[0] if self.file.schema == "IFC2X3" else element1.IsTypedBy[0]
|
||||
assert len(rel.RelatedObjects) == 2
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element1], relating_type=element_type2)
|
||||
@@ -110,9 +108,7 @@ class TestAssignType(test.bootstrap.IFC4):
|
||||
mapped_rep_id = mapped_rep.id()
|
||||
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(
|
||||
self.file, related_objects=[element1, element2], relating_type=element_type
|
||||
)
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element1, element2], relating_type=element_type)
|
||||
assert (mapped_rep := ifcopenshell.util.representation.get_representation(element1, context=context))
|
||||
assert mapped_rep.id() == mapped_rep_id
|
||||
|
||||
@@ -139,9 +135,7 @@ class TestAssignType(test.bootstrap.IFC4):
|
||||
|
||||
# use 2 elements to trigger material assignment code block
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(
|
||||
self.file, related_objects=[element1, element2], relating_type=element_type
|
||||
)
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element1, element2], relating_type=element_type)
|
||||
assert (material := ifcopenshell.util.element.get_material(element1))
|
||||
assert material.id() == material_id
|
||||
|
||||
|
||||
@@ -29,9 +29,7 @@ class TestUnassignType(test.bootstrap.IFC4):
|
||||
element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(
|
||||
self.file, related_objects=[element1, element2], relating_type=element_type
|
||||
)
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element1, element2], relating_type=element_type)
|
||||
ifcopenshell.api.type.unassign_type(self.file, related_objects=[element1, element2])
|
||||
assert ifcopenshell.util.element.get_type(element1) is None
|
||||
assert ifcopenshell.util.element.get_type(element2) is None
|
||||
|
||||
@@ -61,12 +61,8 @@ class TestAddOpening(test.bootstrap.IFC4):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
)
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=wall, matrix=matrix1.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=opening, matrix=matrix1.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=wall, matrix=matrix1.copy(), is_si=False)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=opening, matrix=matrix1.copy(), is_si=False)
|
||||
ifcopenshell.api.void.add_opening(self.file, opening=opening, element=wall)
|
||||
assert opening.ObjectPlacement.PlacementRelTo.PlacesObject[0] == wall
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(opening.ObjectPlacement), matrix1)
|
||||
|
||||
+25
-15
@@ -1,18 +1,28 @@
|
||||
import time
|
||||
import ifcopenshell
|
||||
|
||||
for i in range(3):
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
p = f.createIfcPerson(Id="tfk", GivenName="Thomas")
|
||||
o = f.createIfcOrganization(Name="AECgeeks")
|
||||
pando = f.createIfcPersonAndOrganization(p, o)
|
||||
appl = f.createIfcApplication(o, ifcopenshell.version, "IfcOpenShell", f"IfcOpenShell {ifcopenshell.version}")
|
||||
units = f.createIfcUnitAssignment(Units=[f.createIfcSIUnit(None, "LENGTHUNIT", None, "METRE")])
|
||||
ownerhist = f.createIfcOwnerHistory(pando, appl, ChangeAction="ADDED", CreationDate=int(time.time()))
|
||||
for j in range(i):
|
||||
f.createIfcProject(ifcopenshell.guid.new(), ownerhist, 'My Project', UnitsInContext=units, RepresentationContexts=[
|
||||
f.createIfcGeometricRepresentationContext(
|
||||
None, None, 3, None,
|
||||
f.create_entity(f'IfcAxis2Placement3D', f.createIfcCartesianPoint((0., 0., 0.))),
|
||||
)
|
||||
])
|
||||
f.write(f"{'fail' if i == 2 else 'pass'}-{i}-projects-ifc2x3.ifc")
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
p = f.createIfcPerson(Id="tfk", GivenName="Thomas")
|
||||
o = f.createIfcOrganization(Name="AECgeeks")
|
||||
pando = f.createIfcPersonAndOrganization(p, o)
|
||||
appl = f.createIfcApplication(o, ifcopenshell.version, "IfcOpenShell", f"IfcOpenShell {ifcopenshell.version}")
|
||||
units = f.createIfcUnitAssignment(Units=[f.createIfcSIUnit(None, "LENGTHUNIT", None, "METRE")])
|
||||
ownerhist = f.createIfcOwnerHistory(pando, appl, ChangeAction="ADDED", CreationDate=int(time.time()))
|
||||
for j in range(i):
|
||||
f.createIfcProject(
|
||||
ifcopenshell.guid.new(),
|
||||
ownerhist,
|
||||
"My Project",
|
||||
UnitsInContext=units,
|
||||
RepresentationContexts=[
|
||||
f.createIfcGeometricRepresentationContext(
|
||||
None,
|
||||
None,
|
||||
3,
|
||||
None,
|
||||
f.create_entity(f"IfcAxis2Placement3D", f.createIfcCartesianPoint((0.0, 0.0, 0.0))),
|
||||
)
|
||||
],
|
||||
)
|
||||
f.write(f"{'fail' if i == 2 else 'pass'}-{i}-projects-ifc2x3.ifc")
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import ifcopenshell
|
||||
for i, box_alignment in enumerate(['top-left', 'center', 'invalid', 'CENTER']):
|
||||
|
||||
for i, box_alignment in enumerate(["top-left", "center", "invalid", "CENTER"]):
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
|
||||
f.createIfcTextLiteralWithExtent(
|
||||
"My presentable text",
|
||||
f.createIfcAxis2Placement2D(f.createIfcCartesianPoint((0., 0.))),
|
||||
'RIGHT',
|
||||
f.createIfcPlanarExtent(10., 10.),
|
||||
box_alignment
|
||||
f.createIfcAxis2Placement2D(f.createIfcCartesianPoint((0.0, 0.0))),
|
||||
"RIGHT",
|
||||
f.createIfcPlanarExtent(10.0, 10.0),
|
||||
box_alignment,
|
||||
)
|
||||
|
||||
f.write(f"{'pass' if i in (0,1) else 'fail'}-{i}-box-alignment-{box_alignment}-ifc2x3.ifc")
|
||||
|
||||
+15
-6
@@ -28,11 +28,20 @@ for i, (is_valid, lat) in enumerate(latitudes):
|
||||
ownerhist = f.createIfcOwnerHistory(pando, appl, ChangeAction="ADDED", CreationDate=int(time.time()))
|
||||
units = f.createIfcUnitAssignment(Units=[f.createIfcSIUnit(None, "LENGTHUNIT", None, "METRE")])
|
||||
site = f.createIfcSite(ifcopenshell.guid.new(), ownerhist, RefLatitude=lat)
|
||||
proj = f.createIfcProject(ifcopenshell.guid.new(), ownerhist, 'My Project', UnitsInContext=units, RepresentationContexts=[
|
||||
f.createIfcGeometricRepresentationContext(
|
||||
None, None, 3, None,
|
||||
f.create_entity(f'IfcAxis2Placement3D', f.createIfcCartesianPoint((0., 0., 0.))),
|
||||
)
|
||||
])
|
||||
proj = f.createIfcProject(
|
||||
ifcopenshell.guid.new(),
|
||||
ownerhist,
|
||||
"My Project",
|
||||
UnitsInContext=units,
|
||||
RepresentationContexts=[
|
||||
f.createIfcGeometricRepresentationContext(
|
||||
None,
|
||||
None,
|
||||
3,
|
||||
None,
|
||||
f.create_entity(f"IfcAxis2Placement3D", f.createIfcCartesianPoint((0.0, 0.0, 0.0))),
|
||||
)
|
||||
],
|
||||
)
|
||||
f.createIfcRelAggregates(ifcopenshell.guid.new(), ownerhist, None, None, proj, [site])
|
||||
f.write(f"{'pass' if is_valid else 'fail'}-site-latitude-{i}-ifc2x3.ifc")
|
||||
|
||||
+5
-10
@@ -1,18 +1,13 @@
|
||||
import ifcopenshell
|
||||
|
||||
for depth in (-1., 0., 1.):
|
||||
for depth in (-1.0, 0.0, 1.0):
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcExtrudedAreaSolid(
|
||||
f.createIfcRectangleProfileDef(
|
||||
"AREA", None,
|
||||
f.createIfcAxis2Placement2D(
|
||||
f.createIfcCartesianPoint((0., 0.))
|
||||
), 1., 1.
|
||||
"AREA", None, f.createIfcAxis2Placement2D(f.createIfcCartesianPoint((0.0, 0.0))), 1.0, 1.0
|
||||
),
|
||||
f.createIfcAxis2Placement3D(
|
||||
f.createIfcCartesianPoint((0., 0., 0.))
|
||||
),
|
||||
f.createIfcDirection((0., 0., 1.)),
|
||||
depth
|
||||
f.createIfcAxis2Placement3D(f.createIfcCartesianPoint((0.0, 0.0, 0.0))),
|
||||
f.createIfcDirection((0.0, 0.0, 1.0)),
|
||||
depth,
|
||||
)
|
||||
f.write(f"{'pass' if depth > 0. else 'fail'}-extrusion-depth-{depth}-ifc2x3.ifc")
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import ifcopenshell
|
||||
|
||||
for i, (r1, r2) in enumerate([("SUPPLIER", None), ("SUPPLIER", "Valid"), ("USERDEFINED", "Valid"), ("USERDEFINED", None)]):
|
||||
for i, (r1, r2) in enumerate(
|
||||
[("SUPPLIER", None), ("SUPPLIER", "Valid"), ("USERDEFINED", "Valid"), ("USERDEFINED", None)]
|
||||
):
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcActorRole(r1, r2)
|
||||
f.write(f"{'fail' if i == 3 else 'pass'}-actor-role-{r1}-{r2}-ifc2x3.ifc")
|
||||
f.write(f"{'fail' if i == 3 else 'pass'}-actor-role-{r1}-{r2}-ifc2x3.ifc")
|
||||
|
||||
+11
-7
@@ -1,18 +1,22 @@
|
||||
import ifcopenshell
|
||||
|
||||
options = {
|
||||
'IfcPostalAddress': ({}, {'Country': 'The Netherlands'}, {'Country': 'The Netherlands', 'Town': 'Eindhoven'}),
|
||||
'IfcTelecomAddress': ({}, {'TelephoneNumbers': ['040-12345678']}, {'TelephoneNumbers': ['040-12345678'], 'PagerNumber': '12345'})
|
||||
"IfcPostalAddress": ({}, {"Country": "The Netherlands"}, {"Country": "The Netherlands", "Town": "Eindhoven"}),
|
||||
"IfcTelecomAddress": (
|
||||
{},
|
||||
{"TelephoneNumbers": ["040-12345678"]},
|
||||
{"TelephoneNumbers": ["040-12345678"], "PagerNumber": "12345"},
|
||||
),
|
||||
}
|
||||
|
||||
for ent in ('IfcPostalAddress', 'IfcTelecomAddress'):
|
||||
for purpose in (None, 'USERDEFINED', 'HOME'):
|
||||
for ud in (None, 'SomethingUserdefined'):
|
||||
for ent in ("IfcPostalAddress", "IfcTelecomAddress"):
|
||||
for purpose in (None, "USERDEFINED", "HOME"):
|
||||
for ud in (None, "SomethingUserdefined"):
|
||||
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.create_entity(ent, purpose, None, ud, **options[ent][1])
|
||||
|
||||
valid = not (purpose == 'USERDEFINED' and ud is None)
|
||||
valid = not (purpose == "USERDEFINED" and ud is None)
|
||||
|
||||
f.write(f"{'pass' if valid else 'fail'}-{ent}-{purpose}-{ud}-ifc2x3.ifc")
|
||||
|
||||
@@ -21,5 +25,5 @@ for ent in ('IfcPostalAddress', 'IfcTelecomAddress'):
|
||||
f.create_entity(ent, **kwargs)
|
||||
valid = len(kwargs) >= 1
|
||||
if not valid:
|
||||
kwargs = {'all-unset': 1}
|
||||
kwargs = {"all-unset": 1}
|
||||
f.write(f"{'pass' if valid else 'fail'}-{ent}-{'-'.join(kwargs.keys())}-ifc2x3.ifc")
|
||||
|
||||
@@ -2,13 +2,13 @@ import itertools
|
||||
import time
|
||||
import ifcopenshell
|
||||
|
||||
for pty, ety in itertools.product(('GRILLE', 'USERDEFINED'), (None, 'Something')):
|
||||
for pty, ety in itertools.product(("GRILLE", "USERDEFINED"), (None, "Something")):
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
p = f.createIfcPerson(Id="tfk", GivenName="Thomas")
|
||||
o = f.createIfcOrganization(Name="AECgeeks")
|
||||
pando = f.createIfcPersonAndOrganization(p, o)
|
||||
appl = f.createIfcApplication(o, ifcopenshell.version, "IfcOpenShell", f"IfcOpenShell {ifcopenshell.version}")
|
||||
ownerhist = f.createIfcOwnerHistory(pando, appl, ChangeAction="ADDED", CreationDate=int(time.time()))
|
||||
f.createIfcAirTerminalType(ifcopenshell.guid.new(), ownerhist, 'My Type', ElementType=ety, PredefinedType=pty)
|
||||
valid = pty != 'USERDEFINED' or ety is not None
|
||||
f.createIfcAirTerminalType(ifcopenshell.guid.new(), ownerhist, "My Type", ElementType=ety, PredefinedType=pty)
|
||||
valid = pty != "USERDEFINED" or ety is not None
|
||||
f.write(f"{'pass' if valid else 'fail'}-air-terminal-type-{pty}-{ety}-ifc2x3.ifc")
|
||||
|
||||
+10
-4
@@ -1,10 +1,16 @@
|
||||
import ifcopenshell
|
||||
|
||||
create_none = lambda f: None
|
||||
create_polyline = lambda f: f.createIfcPolyline((f.createIfcCartesianPoint((0., 0.)), f.createIfcCartesianPoint((1., 0.))))
|
||||
create_point = lambda f: f.createIfcCartesianPoint((0., 0.))
|
||||
create_polyline = lambda f: f.createIfcPolyline(
|
||||
(f.createIfcCartesianPoint((0.0, 0.0)), f.createIfcCartesianPoint((1.0, 0.0)))
|
||||
)
|
||||
create_point = lambda f: f.createIfcCartesianPoint((0.0, 0.0))
|
||||
|
||||
for i, make_item in enumerate((create_none, create_polyline, create_point)):
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
inst = f.createIfcAnnotationCurveOccurrence(make_item(f), [f.createIfcPresentationStyleAssignment([f.createIfcCurveStyle()])])
|
||||
f.write(f"{'fail' if i == 2 else 'pass'}-annotation-curve-occurence-{'None' if inst.Item is None else inst.Item.is_a()}-ifc2x3.ifc")
|
||||
inst = f.createIfcAnnotationCurveOccurrence(
|
||||
make_item(f), [f.createIfcPresentationStyleAssignment([f.createIfcCurveStyle()])]
|
||||
)
|
||||
f.write(
|
||||
f"{'fail' if i == 2 else 'pass'}-annotation-curve-occurence-{'None' if inst.Item is None else inst.Item.is_a()}-ifc2x3.ifc"
|
||||
)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import ifcopenshell
|
||||
|
||||
create_plane = lambda f: f.createIfcPlane(f.createIfcAxis2Placement3D(f.createIfcCartesianPoint((0., 0., 0.))))
|
||||
create_polyline = lambda f: f.createIfcPolyline((f.createIfcCartesianPoint((0., 0.)), f.createIfcCartesianPoint((1., 0.))))
|
||||
create_plane = lambda f: f.createIfcPlane(f.createIfcAxis2Placement3D(f.createIfcCartesianPoint((0.0, 0.0, 0.0))))
|
||||
create_polyline = lambda f: f.createIfcPolyline(
|
||||
(f.createIfcCartesianPoint((0.0, 0.0)), f.createIfcCartesianPoint((1.0, 0.0)))
|
||||
)
|
||||
|
||||
for i, make_item in enumerate((create_plane, create_polyline)):
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
|
||||
+8
-14
@@ -1,22 +1,16 @@
|
||||
import ifcopenshell
|
||||
|
||||
pts = [(0., 0.), (1., 0.), (1., 1.)]
|
||||
dims = [
|
||||
(2,3,3),
|
||||
(3,3,2),
|
||||
(2,2,2),
|
||||
(3,3,3)
|
||||
]
|
||||
pts = [(0.0, 0.0), (1.0, 0.0), (1.0, 1.0)]
|
||||
dims = [(2, 3, 3), (3, 3, 2), (2, 2, 2), (3, 3, 3)]
|
||||
|
||||
|
||||
def make_point(xy, dim):
|
||||
return f.createIfcCartesianPoint((xy + (0.,))[0:dim])
|
||||
return f.createIfcCartesianPoint((xy + (0.0,))[0:dim])
|
||||
|
||||
|
||||
for d in dims:
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
inst = f.createIfcBSplineCurve(1,
|
||||
list(map(lambda t: make_point(*t), zip(pts, d))),
|
||||
"POLYLINE_FORM",
|
||||
False,
|
||||
False
|
||||
inst = f.createIfcBSplineCurve(1, list(map(lambda t: make_point(*t), zip(pts, d))), "POLYLINE_FORM", False, False)
|
||||
f.write(
|
||||
f"{'pass' if len(set(d)) == 1 else 'fail'}-bspline-curve-point-dimensions-{'-'.join(map(str, d))}-ifc2x3.ifc"
|
||||
)
|
||||
f.write(f"{'pass' if len(set(d)) == 1 else 'fail'}-bspline-curve-point-dimensions-{'-'.join(map(str, d))}-ifc2x3.ifc")
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import itertools
|
||||
import ifcopenshell
|
||||
|
||||
defaults = {'Girth': 1., 'WallThickness': 0.11}
|
||||
depths = [2., 3.]
|
||||
defaults = {"Girth": 1.0, "WallThickness": 0.11}
|
||||
depths = [2.0, 3.0]
|
||||
widths = [0.2, 0.3]
|
||||
|
||||
for d, w in itertools.product(depths, widths):
|
||||
@@ -12,9 +12,9 @@ for d, w in itertools.product(depths, widths):
|
||||
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
|
||||
valid = (Girth < (Depth / 2.)) and ((WallThickness < Width/2.) and (WallThickness < Depth/2.))
|
||||
valid = (Girth < (Depth / 2.0)) and ((WallThickness < Width / 2.0) and (WallThickness < Depth / 2.0))
|
||||
|
||||
inst = f.createIfcCShapeProfileDef(
|
||||
'AREA', None, f.createIfcAxis2Placement2D(f.createIfcCartesianPoint((0., 0.))), **D
|
||||
"AREA", None, f.createIfcAxis2Placement2D(f.createIfcCartesianPoint((0.0, 0.0))), **D
|
||||
)
|
||||
f.write(f"{'pass' if valid else 'fail'}-cshape-profile-width-{w}-depth-{d}-ifc2x3.ifc")
|
||||
|
||||
+10
-15
@@ -1,34 +1,29 @@
|
||||
import ifcopenshell
|
||||
|
||||
depth = 1.0
|
||||
for (dir_x, dir_z) in ((0., -1.), (0., 0.), (1., 0.), (1., 0.001), (0., 1.)):
|
||||
for dir_x, dir_z in ((0.0, -1.0), (0.0, 0.0), (1.0, 0.0), (1.0, 0.001), (0.0, 1.0)):
|
||||
|
||||
schemas = ['IFC2X3']
|
||||
if (dir_x, dir_z) == (0., 0.):
|
||||
schemas.append('IFC4')
|
||||
schemas = ["IFC2X3"]
|
||||
if (dir_x, dir_z) == (0.0, 0.0):
|
||||
schemas.append("IFC4")
|
||||
|
||||
for schema in schemas:
|
||||
f = ifcopenshell.file(schema=schema)
|
||||
f.createIfcExtrudedAreaSolid(
|
||||
f.createIfcRectangleProfileDef(
|
||||
"AREA", None,
|
||||
f.createIfcAxis2Placement2D(
|
||||
f.createIfcCartesianPoint((0., 0.))
|
||||
), 1., 1.
|
||||
"AREA", None, f.createIfcAxis2Placement2D(f.createIfcCartesianPoint((0.0, 0.0))), 1.0, 1.0
|
||||
),
|
||||
f.createIfcAxis2Placement3D(
|
||||
f.createIfcCartesianPoint((0., 0., 0.))
|
||||
),
|
||||
f.createIfcDirection((dir_x, 0., dir_z)),
|
||||
depth
|
||||
f.createIfcAxis2Placement3D(f.createIfcCartesianPoint((0.0, 0.0, 0.0))),
|
||||
f.createIfcDirection((dir_x, 0.0, dir_z)),
|
||||
depth,
|
||||
)
|
||||
|
||||
# Due to the way IfcDotProduct and IfcNormalise interact, (0 0 0) actually
|
||||
# results into indeterminate. But in IFC4 onwars there is a rule in IfcDirection
|
||||
# for non-zero magnitude
|
||||
|
||||
valid = dir_z != 0.
|
||||
if f.schema == 'IFC2X3' and (dir_x, dir_z) == (0., 0.):
|
||||
valid = dir_z != 0.0
|
||||
if f.schema == "IFC2X3" and (dir_x, dir_z) == (0.0, 0.0):
|
||||
valid = True
|
||||
|
||||
f.write(f"{'pass' if valid else 'fail'}-extrusion-dir-{dir_x}-{dir_z}-{f.schema.lower()}.ifc")
|
||||
|
||||
+11
-19
@@ -1,9 +1,9 @@
|
||||
import ifcopenshell
|
||||
|
||||
coords = [(0., 0.), (10., 0.), (10., 10.), (0., 10.)]
|
||||
make_3d = lambda cs: [c + (0.,) for c in cs]
|
||||
inner_1 = [(1., 1.), (2., 1.), (2., 2.), (1., 2.)]
|
||||
inner_2 = [(3., 3.), (4., 3.), (4., 4.), (3., 4.)]
|
||||
coords = [(0.0, 0.0), (10.0, 0.0), (10.0, 10.0), (0.0, 10.0)]
|
||||
make_3d = lambda cs: [c + (0.0,) for c in cs]
|
||||
inner_1 = [(1.0, 1.0), (2.0, 1.0), (2.0, 2.0), (1.0, 2.0)]
|
||||
inner_2 = [(3.0, 3.0), (4.0, 3.0), (4.0, 4.0), (3.0, 4.0)]
|
||||
|
||||
old_map = map
|
||||
map = lambda fn, *args: list(old_map(fn, *args))
|
||||
@@ -16,7 +16,7 @@ f.createIfcArbitraryProfileDefWithVoids(
|
||||
[
|
||||
f.createIfcPolyline(map(f.createIfcCartesianPoint, inner_1)),
|
||||
f.createIfcPolyline(map(f.createIfcCartesianPoint, inner_2)),
|
||||
]
|
||||
],
|
||||
)
|
||||
f.write(f"pass-arbitrary-profile-with-voids-ifc2x3.ifc")
|
||||
|
||||
@@ -28,7 +28,7 @@ f.createIfcArbitraryProfileDefWithVoids(
|
||||
[
|
||||
f.createIfcPolyline(map(f.createIfcCartesianPoint, inner_1)),
|
||||
f.createIfcPolyline(map(f.createIfcCartesianPoint, inner_2)),
|
||||
]
|
||||
],
|
||||
)
|
||||
f.write(f"fail-arbitrary-profile-with-voids-curve-ifc2x3.ifc")
|
||||
|
||||
@@ -40,7 +40,7 @@ f.createIfcArbitraryProfileDefWithVoids(
|
||||
[
|
||||
f.createIfcPolyline(map(f.createIfcCartesianPoint, inner_1)),
|
||||
f.createIfcPolyline(map(f.createIfcCartesianPoint, inner_2)),
|
||||
]
|
||||
],
|
||||
)
|
||||
f.write(f"fail-arbitrary-profile-with-voids-3d-outer-ifc2x3.ifc")
|
||||
|
||||
@@ -52,7 +52,7 @@ f.createIfcArbitraryProfileDefWithVoids(
|
||||
[
|
||||
f.createIfcPolyline(map(f.createIfcCartesianPoint, make_3d(inner_1))),
|
||||
f.createIfcPolyline(map(f.createIfcCartesianPoint, inner_2)),
|
||||
]
|
||||
],
|
||||
)
|
||||
f.write(f"fail-arbitrary-profile-with-voids-3d-inner-ifc2x3.ifc")
|
||||
|
||||
@@ -64,7 +64,7 @@ f.createIfcArbitraryProfileDefWithVoids(
|
||||
[
|
||||
f.createIfcPolyline(map(f.createIfcCartesianPoint, make_3d(inner_1))),
|
||||
f.createIfcPolyline(map(f.createIfcCartesianPoint, make_3d(inner_2))),
|
||||
]
|
||||
],
|
||||
)
|
||||
f.write(f"fail-arbitrary-profile-with-voids-3d-inner-2-ifc2x3.ifc")
|
||||
|
||||
@@ -73,14 +73,6 @@ f.createIfcArbitraryProfileDefWithVoids(
|
||||
"AREA",
|
||||
None,
|
||||
f.createIfcPolyline(map(f.createIfcCartesianPoint, coords)),
|
||||
[
|
||||
f.createIfcLine(
|
||||
f.createIfcCartesianPoint((0., 0.)),
|
||||
f.createIfcVector(
|
||||
f.createIfcDirection((0., 0.)),
|
||||
1.
|
||||
)
|
||||
)
|
||||
]
|
||||
[f.createIfcLine(f.createIfcCartesianPoint((0.0, 0.0)), f.createIfcVector(f.createIfcDirection((0.0, 0.0)), 1.0))],
|
||||
)
|
||||
f.write(f"fail-arbitrary-profile-with-voids-inner-line-ifc2x3.ifc")
|
||||
f.write(f"fail-arbitrary-profile-with-voids-inner-line-ifc2x3.ifc")
|
||||
|
||||
+25
-27
@@ -1,77 +1,75 @@
|
||||
import ifcopenshell
|
||||
|
||||
coords = [(0., 0.), (10., 0.), (10., 10.), (0., 10.)]
|
||||
make_3d = lambda cs: [c + (0.,) for c in cs]
|
||||
inner_1 = [(1., 1.), (2., 1.), (2., 2.), (1., 2.)]
|
||||
inner_2 = [(3., 3.), (4., 3.), (4., 4.), (3., 4.)]
|
||||
coords = [(0.0, 0.0), (10.0, 0.0), (10.0, 10.0), (0.0, 10.0)]
|
||||
make_3d = lambda cs: [c + (0.0,) for c in cs]
|
||||
inner_1 = [(1.0, 1.0), (2.0, 1.0), (2.0, 2.0), (1.0, 2.0)]
|
||||
inner_2 = [(3.0, 3.0), (4.0, 3.0), (4.0, 4.0), (3.0, 4.0)]
|
||||
|
||||
old_map = map
|
||||
map = lambda fn, *args: list(old_map(fn, *args))
|
||||
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcAxis2Placement3D(
|
||||
f.createIfcCartesianPoint((0., 0., 0.))
|
||||
)
|
||||
f.createIfcAxis2Placement3D(f.createIfcCartesianPoint((0.0, 0.0, 0.0)))
|
||||
f.write(f"pass-axis2-3d-pos-ifc2x3.ifc")
|
||||
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcAxis2Placement3D(
|
||||
f.createIfcCartesianPoint((0., 0., 0.)),
|
||||
f.createIfcDirection((0., 0., 1.)),
|
||||
f.createIfcDirection((1., 0., 0.)),
|
||||
f.createIfcCartesianPoint((0.0, 0.0, 0.0)),
|
||||
f.createIfcDirection((0.0, 0.0, 1.0)),
|
||||
f.createIfcDirection((1.0, 0.0, 0.0)),
|
||||
)
|
||||
f.write(f"pass-axis2-two-directions-ifc2x3.ifc")
|
||||
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcAxis2Placement3D(
|
||||
f.createIfcCartesianPoint((0., 0., 0.)),
|
||||
Axis=f.createIfcDirection((0., 0., 1.)),
|
||||
f.createIfcCartesianPoint((0.0, 0.0, 0.0)),
|
||||
Axis=f.createIfcDirection((0.0, 0.0, 1.0)),
|
||||
RefDirection=None,
|
||||
)
|
||||
f.write(f"fail-axis2-only-axis-ifc2x3.ifc")
|
||||
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcAxis2Placement3D(
|
||||
f.createIfcCartesianPoint((0., 0., 0.)),
|
||||
f.createIfcCartesianPoint((0.0, 0.0, 0.0)),
|
||||
Axis=None,
|
||||
RefDirection=f.createIfcDirection((1., 0., 0.)),
|
||||
RefDirection=f.createIfcDirection((1.0, 0.0, 0.0)),
|
||||
)
|
||||
f.write(f"fail-axis2-only-ref-ifc2x3.ifc")
|
||||
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcAxis2Placement3D(
|
||||
f.createIfcCartesianPoint((0., 0., 0.)),
|
||||
f.createIfcDirection((1., 0.)),
|
||||
f.createIfcDirection((0., 1., 0.)),
|
||||
f.createIfcCartesianPoint((0.0, 0.0, 0.0)),
|
||||
f.createIfcDirection((1.0, 0.0)),
|
||||
f.createIfcDirection((0.0, 1.0, 0.0)),
|
||||
)
|
||||
f.write(f"fail-axis2-2d-axis-ifc2x3.ifc")
|
||||
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcAxis2Placement3D(
|
||||
f.createIfcCartesianPoint((0., 0.)),
|
||||
f.createIfcCartesianPoint((0.0, 0.0)),
|
||||
)
|
||||
f.write(f"fail-axis2-2d-pos-ifc2x3.ifc")
|
||||
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcAxis2Placement3D(
|
||||
f.createIfcCartesianPoint((0., 0., 0.)),
|
||||
f.createIfcDirection((0., 0., 1.)),
|
||||
f.createIfcDirection((1., 0.)),
|
||||
f.createIfcCartesianPoint((0.0, 0.0, 0.0)),
|
||||
f.createIfcDirection((0.0, 0.0, 1.0)),
|
||||
f.createIfcDirection((1.0, 0.0)),
|
||||
)
|
||||
f.write(f"fail-axis2-2d-ref-ifc2x3.ifc")
|
||||
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcAxis2Placement3D(
|
||||
f.createIfcCartesianPoint((0., 0., 0.)),
|
||||
Axis=f.createIfcDirection((0., 0., 1.)),
|
||||
RefDirection=f.createIfcDirection((0., 0., 1.)),
|
||||
f.createIfcCartesianPoint((0.0, 0.0, 0.0)),
|
||||
Axis=f.createIfcDirection((0.0, 0.0, 1.0)),
|
||||
RefDirection=f.createIfcDirection((0.0, 0.0, 1.0)),
|
||||
)
|
||||
f.write(f"fail-axis2-parallel-axes.ifc")
|
||||
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcAxis2Placement3D(
|
||||
f.createIfcCartesianPoint((0., 0., 0.)),
|
||||
Axis=f.createIfcDirection((0., 0., 1.)),
|
||||
RefDirection=f.createIfcDirection((0., 0., -1.)),
|
||||
f.createIfcCartesianPoint((0.0, 0.0, 0.0)),
|
||||
Axis=f.createIfcDirection((0.0, 0.0, 1.0)),
|
||||
RefDirection=f.createIfcDirection((0.0, 0.0, -1.0)),
|
||||
)
|
||||
f.write(f"fail-axis2-anti-parallel-axes.ifc")
|
||||
|
||||
+8
-15
@@ -1,26 +1,19 @@
|
||||
import ifcopenshell
|
||||
|
||||
dims = [
|
||||
(1,0,0,0,0,0,0),
|
||||
(1,1,0,0,0,0,0),
|
||||
(0,1,0,0,0,0,0),
|
||||
(-1,0,0,0,0,0,0),
|
||||
(2,0,0,0,0,0,0),
|
||||
(1, 0, 0, 0, 0, 0, 0),
|
||||
(1, 1, 0, 0, 0, 0, 0),
|
||||
(0, 1, 0, 0, 0, 0, 0),
|
||||
(-1, 0, 0, 0, 0, 0, 0),
|
||||
(2, 0, 0, 0, 0, 0, 0),
|
||||
]
|
||||
|
||||
for i, d in enumerate(dims):
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcConversionBasedUnit(
|
||||
f.createIfcDimensionalExponents(*d),
|
||||
'LENGTHUNIT',
|
||||
'beard-second',
|
||||
f.createIfcMeasureWithUnit(
|
||||
f.createIfcLengthMeasure(5.0),
|
||||
f.createIfcSIUnit(
|
||||
Prefix='NANO',
|
||||
Name='METRE'
|
||||
)
|
||||
)
|
||||
|
||||
"LENGTHUNIT",
|
||||
"beard-second",
|
||||
f.createIfcMeasureWithUnit(f.createIfcLengthMeasure(5.0), f.createIfcSIUnit(Prefix="NANO", Name="METRE")),
|
||||
)
|
||||
f.write(f"{'pass' if i == 0 else 'fail'}-conv-unit-{i}-ifc2x3.ifc")
|
||||
|
||||
+59
-54
@@ -1,72 +1,77 @@
|
||||
import ifcopenshell
|
||||
|
||||
coords = [(0., 0.), (10., 0.)]
|
||||
coords_2 = [(0., 0.), (10., 0.), (10., 10.), (0., 10.)]
|
||||
make_3d = lambda cs: [c + (0.,) for c in cs]
|
||||
make_nd = lambda d: lambda c: (c + (0.,)) if d == 3 else c
|
||||
coords = [(0.0, 0.0), (10.0, 0.0)]
|
||||
coords_2 = [(0.0, 0.0), (10.0, 0.0), (10.0, 10.0), (0.0, 10.0)]
|
||||
make_3d = lambda cs: [c + (0.0,) for c in cs]
|
||||
make_nd = lambda d: lambda c: (c + (0.0,)) if d == 3 else c
|
||||
|
||||
old_map = map
|
||||
map = lambda fn, *args: list(old_map(fn, *args))
|
||||
|
||||
poly_2d = lambda f: [f.createIfcPolyline(map(f.createIfcCartesianPoint, coords))]
|
||||
poly_3d = lambda f: [f.createIfcPolyline(map(f.createIfcCartesianPoint, make_3d(coords)))]
|
||||
plane = lambda f: [f.createIfcPlane(f.createIfcAxis2Placement3D(f.createIfcCartesianPoint((0., 0., 0.))))]
|
||||
fbsm = lambda f: [f.createIfcFaceBasedSurfaceModel(
|
||||
FbsmFaces=[f.createIfcOpenShell(
|
||||
CfsFaces=[f.createIfcFace(
|
||||
Bounds=[f.createIfcFaceOuterBound(
|
||||
Bound=f.createIfcPolyLoop(
|
||||
Polygon=map(f.createIfcCartesianPoint, make_3d(coords_2))
|
||||
)
|
||||
)]
|
||||
)]
|
||||
)]
|
||||
)]
|
||||
extrusion = lambda f: [f.createIfcExtrudedAreaSolid(
|
||||
f.createIfcRectangleProfileDef(
|
||||
"AREA", None,
|
||||
f.createIfcAxis2Placement2D(
|
||||
f.createIfcCartesianPoint((0., 0.))
|
||||
), 1., 1.
|
||||
),
|
||||
f.createIfcAxis2Placement3D(
|
||||
f.createIfcCartesianPoint((0., 0., 0.))
|
||||
),
|
||||
f.createIfcDirection((0., 0., 1.)),
|
||||
1.
|
||||
)]
|
||||
bbox = lambda f: [f.createIfcBoundingBox(
|
||||
f.createIfcCartesianPoint((0., 0., 0.)),
|
||||
1., 1., 1.
|
||||
)]
|
||||
plane = lambda f: [f.createIfcPlane(f.createIfcAxis2Placement3D(f.createIfcCartesianPoint((0.0, 0.0, 0.0))))]
|
||||
fbsm = lambda f: [
|
||||
f.createIfcFaceBasedSurfaceModel(
|
||||
FbsmFaces=[
|
||||
f.createIfcOpenShell(
|
||||
CfsFaces=[
|
||||
f.createIfcFace(
|
||||
Bounds=[
|
||||
f.createIfcFaceOuterBound(
|
||||
Bound=f.createIfcPolyLoop(Polygon=map(f.createIfcCartesianPoint, make_3d(coords_2)))
|
||||
)
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
]
|
||||
extrusion = lambda f: [
|
||||
f.createIfcExtrudedAreaSolid(
|
||||
f.createIfcRectangleProfileDef(
|
||||
"AREA", None, f.createIfcAxis2Placement2D(f.createIfcCartesianPoint((0.0, 0.0))), 1.0, 1.0
|
||||
),
|
||||
f.createIfcAxis2Placement3D(f.createIfcCartesianPoint((0.0, 0.0, 0.0))),
|
||||
f.createIfcDirection((0.0, 0.0, 1.0)),
|
||||
1.0,
|
||||
)
|
||||
]
|
||||
bbox = lambda f: [f.createIfcBoundingBox(f.createIfcCartesianPoint((0.0, 0.0, 0.0)), 1.0, 1.0, 1.0)]
|
||||
|
||||
gcs = lambda fn: lambda f: [f.createIfcGeometricSet(fn(f))]
|
||||
repeat = lambda n, fn: lambda f: fn(f) * n
|
||||
|
||||
options = [
|
||||
(True, 2, 'Curve2D', '2d-polyline', poly_2d),
|
||||
(False, 3, 'Curve2D', '3d-polyline', poly_3d),
|
||||
(True, 2, 'GeometricCurveSet', 'with-curve', gcs(poly_2d)),
|
||||
(False, 3, 'GeometricCurveSet', 'with-surface', gcs(plane)),
|
||||
(False, 3, 'SurfaceModel', '3d-polyline', poly_3d),
|
||||
(True, 3, 'SurfaceModel', 'surface-model', fbsm),
|
||||
(False, 3, 'SweptSolid', '3d-polyline', poly_3d),
|
||||
(True, 3, 'SweptSolid', 'extrusion', extrusion),
|
||||
(True, 3, 'BoundingBox', 'single-bbox', bbox),
|
||||
(False, 3, 'BoundingBox', 'multiple-bbox', repeat(2, bbox)),
|
||||
(True, 2, "Curve2D", "2d-polyline", poly_2d),
|
||||
(False, 3, "Curve2D", "3d-polyline", poly_3d),
|
||||
(True, 2, "GeometricCurveSet", "with-curve", gcs(poly_2d)),
|
||||
(False, 3, "GeometricCurveSet", "with-surface", gcs(plane)),
|
||||
(False, 3, "SurfaceModel", "3d-polyline", poly_3d),
|
||||
(True, 3, "SurfaceModel", "surface-model", fbsm),
|
||||
(False, 3, "SweptSolid", "3d-polyline", poly_3d),
|
||||
(True, 3, "SweptSolid", "extrusion", extrusion),
|
||||
(True, 3, "BoundingBox", "single-bbox", bbox),
|
||||
(False, 3, "BoundingBox", "multiple-bbox", repeat(2, bbox)),
|
||||
]
|
||||
|
||||
for is_valid, dims, rep_type, name, fn in options:
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcProductDefinitionShape(Representations=[
|
||||
f.createIfcShapeRepresentation(
|
||||
f.createIfcGeometricRepresentationContext(
|
||||
None, None, dims, None,
|
||||
f.create_entity(f'IfcAxis2Placement{dims}D', f.createIfcCartesianPoint(make_nd(dims)((0., 0.)))),
|
||||
),
|
||||
'Body',
|
||||
rep_type,
|
||||
fn(f)
|
||||
)
|
||||
])
|
||||
f.createIfcProductDefinitionShape(
|
||||
Representations=[
|
||||
f.createIfcShapeRepresentation(
|
||||
f.createIfcGeometricRepresentationContext(
|
||||
None,
|
||||
None,
|
||||
dims,
|
||||
None,
|
||||
f.create_entity(f"IfcAxis2Placement{dims}D", f.createIfcCartesianPoint(make_nd(dims)((0.0, 0.0)))),
|
||||
),
|
||||
"Body",
|
||||
rep_type,
|
||||
fn(f),
|
||||
)
|
||||
]
|
||||
)
|
||||
f.write(f"{'pass' if is_valid else 'fail'}-shaperep-{rep_type.lower()}-{name}-ifc2x3.ifc")
|
||||
|
||||
+3
-11
@@ -1,10 +1,7 @@
|
||||
import time
|
||||
import ifcopenshell
|
||||
|
||||
names = [
|
||||
("Same", "Same"),
|
||||
("Different", "SomethingElse")
|
||||
]
|
||||
names = [("Same", "Same"), ("Different", "SomethingElse")]
|
||||
|
||||
make_prop = lambda f: lambda nm: f.createIfcPropertySingleValue(Name=nm)
|
||||
|
||||
@@ -19,11 +16,6 @@ for nms in names:
|
||||
appl = f.createIfcApplication(o, ifcopenshell.version, "IfcOpenShell", f"IfcOpenShell {ifcopenshell.version}")
|
||||
units = f.createIfcUnitAssignment(Units=[f.createIfcSIUnit(None, "LENGTHUNIT", None, "METRE")])
|
||||
ownerhist = f.createIfcOwnerHistory(pando, appl, ChangeAction="ADDED", CreationDate=int(time.time()))
|
||||
f.createIfcPropertySet(
|
||||
ifcopenshell.guid.new(),
|
||||
ownerhist,
|
||||
"MyPset",
|
||||
HasProperties=map(make_prop(f), nms)
|
||||
)
|
||||
f.createIfcPropertySet(ifcopenshell.guid.new(), ownerhist, "MyPset", HasProperties=map(make_prop(f), nms))
|
||||
f.write(f"{'pass' if len(set(nms)) == len(nms) else 'fail'}-property-{'-'.join(map(str.lower, nms))}-ifc2x3.ifc")
|
||||
15
|
||||
15
|
||||
|
||||
+4
-10
@@ -9,18 +9,12 @@ for i, nm in enumerate(("no-mls", "mls", "mlsu")):
|
||||
appl = f.createIfcApplication(o, ifcopenshell.version, "IfcOpenShell", f"IfcOpenShell {ifcopenshell.version}")
|
||||
units = f.createIfcUnitAssignment(Units=[f.createIfcSIUnit(None, "LENGTHUNIT", None, "METRE")])
|
||||
ownerhist = f.createIfcOwnerHistory(pando, appl, ChangeAction="ADDED", CreationDate=int(time.time()))
|
||||
wall = f.createIfcWallStandardCase(
|
||||
ifcopenshell.guid.new(),
|
||||
ownerhist
|
||||
)
|
||||
if i in (1,2):
|
||||
wall = f.createIfcWallStandardCase(ifcopenshell.guid.new(), ownerhist)
|
||||
if i in (1, 2):
|
||||
mls = f.createIfcMaterialLayerSet([f.createIfcMaterialLayer(None, 0.1)])
|
||||
if i == 2:
|
||||
mls = f.createIfcMaterialLayerSetUsage(mls, 'AXIS2', 'POSITIVE', 0.)
|
||||
mls = f.createIfcMaterialLayerSetUsage(mls, "AXIS2", "POSITIVE", 0.0)
|
||||
f.createIfcRelAssociatesMaterial(
|
||||
ifcopenshell.guid.new(),
|
||||
ownerhist,
|
||||
RelatedObjects=[wall],
|
||||
RelatingMaterial=mls
|
||||
ifcopenshell.guid.new(), ownerhist, RelatedObjects=[wall], RelatingMaterial=mls
|
||||
)
|
||||
f.write(f"{'pass' if i == 2 else 'fail'}-wall-{nm}-ifc2x3.ifc")
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import ifcopenshell
|
||||
|
||||
for i, type_decl in enumerate(('IfcLengthMeasure', 'IfcPlaneAngleMeasure')):
|
||||
for i, type_decl in enumerate(("IfcLengthMeasure", "IfcPlaneAngleMeasure")):
|
||||
f = ifcopenshell.file(schema="IFC4X3_ADD1")
|
||||
f.createIfcRigidOperation(
|
||||
SourceCRS=f.createIfcGeographicCRS('EPSG:4326'),
|
||||
TargetCRS=f.createIfcGeographicCRS('EPSG:3857'),
|
||||
SourceCRS=f.createIfcGeographicCRS("EPSG:4326"),
|
||||
TargetCRS=f.createIfcGeographicCRS("EPSG:3857"),
|
||||
FirstCoordinate=f.create_entity(type_decl, 0.0),
|
||||
SecondCoordinate=f.create_entity('IfcPlaneAngleMeasure', 0.0),
|
||||
Height=0.0
|
||||
SecondCoordinate=f.create_entity("IfcPlaneAngleMeasure", 0.0),
|
||||
Height=0.0,
|
||||
)
|
||||
f.write(f"{'pass' if i else 'fail'}-rigid-op-IfcPlaneAngleMeasure-{type_decl}-ifc4x3_add1.ifc")
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
import ifcopenshell
|
||||
|
||||
make_nd = lambda d: lambda *c: (c + (0.,)) if d == 3 else c
|
||||
make_nd = lambda d: lambda *c: (c + (0.0,)) if d == 3 else c
|
||||
|
||||
for d1, d2 in ((2,3), (3,3), (3,2)):
|
||||
for d1, d2 in ((2, 3), (3, 3), (3, 2)):
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
f.createIfcLocalPlacement(
|
||||
PlacementRelTo=f.createIfcLocalPlacement(
|
||||
PlacementRelTo=None,
|
||||
RelativePlacement=f.create_entity(f'IfcAxis2Placement{d1}D',
|
||||
f.createIfcCartesianPoint(make_nd(d1)(0., 0.))
|
||||
)
|
||||
RelativePlacement=f.create_entity(
|
||||
f"IfcAxis2Placement{d1}D", f.createIfcCartesianPoint(make_nd(d1)(0.0, 0.0))
|
||||
),
|
||||
),
|
||||
RelativePlacement=f.create_entity(f'IfcAxis2Placement{d2}D',
|
||||
f.createIfcCartesianPoint(make_nd(d2)(0., 0.))
|
||||
)
|
||||
RelativePlacement=f.create_entity(f"IfcAxis2Placement{d2}D", f.createIfcCartesianPoint(make_nd(d2)(0.0, 0.0))),
|
||||
)
|
||||
f.write(f"{'pass' if d1 >= d2 else 'fail'}-placement-{d1}d-{d2}d-ifc2x3.ifc")
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import ifcopenshell
|
||||
|
||||
task = lambda f: f.createIfcTask(ifcopenshell.guid.new(),None,'sleep',IsMilestone=True)
|
||||
task = lambda f: f.createIfcTask(ifcopenshell.guid.new(), None, "sleep", IsMilestone=True)
|
||||
wall = lambda f: f.createIfcWall(ifcopenshell.guid.new())
|
||||
|
||||
for i,fn in enumerate((task, wall)):
|
||||
for i, fn in enumerate((task, wall)):
|
||||
f = ifcopenshell.file(schema="IFC4")
|
||||
elem = fn(f)
|
||||
f.createIfcRelAssociatesMaterial(ifcopenshell.guid.new(), None, None, None, [elem], f.createIfcMaterial('brick'))
|
||||
f.createIfcRelAssociatesMaterial(ifcopenshell.guid.new(), None, None, None, [elem], f.createIfcMaterial("brick"))
|
||||
f.write(f"{'pass' if i else 'fail'}-assoc-material-{elem.is_a()}-{f.schema}.ifc")
|
||||
|
||||
+20
-7
@@ -1,13 +1,26 @@
|
||||
import itertools
|
||||
import ifcopenshell
|
||||
|
||||
def EXISTS(v): return v is not None
|
||||
def NOT(v): return not v
|
||||
|
||||
for LiningDepth, LiningThickness in itertools.product((None, 1.), (None, 1.)):
|
||||
def EXISTS(v):
|
||||
return v is not None
|
||||
|
||||
|
||||
def NOT(v):
|
||||
return not v
|
||||
|
||||
|
||||
for LiningDepth, LiningThickness in itertools.product((None, 1.0), (None, 1.0)):
|
||||
f = ifcopenshell.file(schema="IFC4")
|
||||
valid = NOT(EXISTS(LiningDepth) and NOT(EXISTS(LiningThickness)))
|
||||
f.createIfcWindowType(ifcopenshell.guid.new(), None, 'WindowType', HasPropertySets=[
|
||||
f.createIfcWindowLiningProperties(ifcopenshell.guid.new(), LiningDepth=LiningDepth, LiningThickness=LiningThickness)
|
||||
])
|
||||
f.write(f"{'pass' if valid else 'fail'}-lining-properties-{LiningDepth}-{LiningThickness}.ifc")
|
||||
f.createIfcWindowType(
|
||||
ifcopenshell.guid.new(),
|
||||
None,
|
||||
"WindowType",
|
||||
HasPropertySets=[
|
||||
f.createIfcWindowLiningProperties(
|
||||
ifcopenshell.guid.new(), LiningDepth=LiningDepth, LiningThickness=LiningThickness
|
||||
)
|
||||
],
|
||||
)
|
||||
f.write(f"{'pass' if valid else 'fail'}-lining-properties-{LiningDepth}-{LiningThickness}.ifc")
|
||||
|
||||
+41
-8
@@ -1,21 +1,54 @@
|
||||
import ifcopenshell
|
||||
|
||||
for cnt in range(0,3):
|
||||
for cnt in range(0, 3):
|
||||
f = ifcopenshell.file(schema="IFC4")
|
||||
elem = f.createIfcWall(ifcopenshell.guid.new())
|
||||
for i in range(cnt):
|
||||
f.createIfcRelDefinesByProperties(ifcopenshell.guid.new(), None, None, None, [elem],
|
||||
f.createIfcPropertySet(ifcopenshell.guid.new(), None, 'Pset_WallCommon', None, [f.createIfcPropertySingleValue('LoadBearing', None, f.createIfcBoolean(True))])
|
||||
f.createIfcRelDefinesByProperties(
|
||||
ifcopenshell.guid.new(),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
[elem],
|
||||
f.createIfcPropertySet(
|
||||
ifcopenshell.guid.new(),
|
||||
None,
|
||||
"Pset_WallCommon",
|
||||
None,
|
||||
[f.createIfcPropertySingleValue("LoadBearing", None, f.createIfcBoolean(True))],
|
||||
),
|
||||
)
|
||||
f.write(f"{'pass' if cnt < 2 else 'fail'}-wall-{cnt}-same-psets.ifc")
|
||||
|
||||
|
||||
f = ifcopenshell.file(schema="IFC4")
|
||||
elem = f.createIfcWall(ifcopenshell.guid.new())
|
||||
f.createIfcRelDefinesByProperties(ifcopenshell.guid.new(), None, None, None, [elem],
|
||||
f.createIfcPropertySet(ifcopenshell.guid.new(), None, 'Pset_WallCommon', None, [f.createIfcPropertySingleValue('LoadBearing', None, f.createIfcBoolean(True))])
|
||||
f.createIfcRelDefinesByProperties(
|
||||
ifcopenshell.guid.new(),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
[elem],
|
||||
f.createIfcPropertySet(
|
||||
ifcopenshell.guid.new(),
|
||||
None,
|
||||
"Pset_WallCommon",
|
||||
None,
|
||||
[f.createIfcPropertySingleValue("LoadBearing", None, f.createIfcBoolean(True))],
|
||||
),
|
||||
)
|
||||
f.createIfcRelDefinesByProperties(ifcopenshell.guid.new(), None, None, None, [elem],
|
||||
f.createIfcPropertySet(ifcopenshell.guid.new(), None, 'Custom', None, [f.createIfcPropertySingleValue('IsBeautiful', None, f.createIfcBoolean(True))])
|
||||
f.createIfcRelDefinesByProperties(
|
||||
ifcopenshell.guid.new(),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
[elem],
|
||||
f.createIfcPropertySet(
|
||||
ifcopenshell.guid.new(),
|
||||
None,
|
||||
"Custom",
|
||||
None,
|
||||
[f.createIfcPropertySingleValue("IsBeautiful", None, f.createIfcBoolean(True))],
|
||||
),
|
||||
)
|
||||
f.write(f"pass-wall-different-psets.ifc")
|
||||
f.write(f"pass-wall-different-psets.ifc")
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import ifcopenshell
|
||||
|
||||
fns = [
|
||||
(False, lambda f: f.createIfcLengthMeasure(-1.)),
|
||||
(True, lambda f: f.createIfcLengthMeasure(1.)),
|
||||
(True, lambda f: f.createIfcPositiveLengthMeasure(1.)),
|
||||
(False, lambda f: f.createIfcDescriptiveMeasure('large'))
|
||||
(False, lambda f: f.createIfcLengthMeasure(-1.0)),
|
||||
(True, lambda f: f.createIfcLengthMeasure(1.0)),
|
||||
(True, lambda f: f.createIfcPositiveLengthMeasure(1.0)),
|
||||
(False, lambda f: f.createIfcDescriptiveMeasure("large")),
|
||||
]
|
||||
|
||||
for valid, fn in fns:
|
||||
f = ifcopenshell.file(schema="IFC4")
|
||||
fs = fn(f)
|
||||
f.createIfcTextStyleFontModel('Comic Sans', ('Comic Sans',), FontSize=fs)
|
||||
f.createIfcTextStyleFontModel("Comic Sans", ("Comic Sans",), FontSize=fs)
|
||||
f.write(f"{'pass' if valid else 'fail'}-font-{fs.is_a()}-{fs[0]}.ifc")
|
||||
|
||||
+43
-18
@@ -1,7 +1,18 @@
|
||||
import time
|
||||
import ifcopenshell
|
||||
|
||||
for ents in [('IfcWall',), ('IfcSpace',), ('IfcZone', 'IfcSpace',), ('IfcWall', 'IfcSpace',)]:
|
||||
for ents in [
|
||||
("IfcWall",),
|
||||
("IfcSpace",),
|
||||
(
|
||||
"IfcZone",
|
||||
"IfcSpace",
|
||||
),
|
||||
(
|
||||
"IfcWall",
|
||||
"IfcSpace",
|
||||
),
|
||||
]:
|
||||
f = ifcopenshell.file(schema="IFC2X3")
|
||||
p = f.createIfcPerson(Id="tfk", GivenName="Thomas")
|
||||
o = f.createIfcOrganization(Name="AECgeeks")
|
||||
@@ -9,24 +20,38 @@ for ents in [('IfcWall',), ('IfcSpace',), ('IfcZone', 'IfcSpace',), ('IfcWall',
|
||||
appl = f.createIfcApplication(o, ifcopenshell.version, "IfcOpenShell", f"IfcOpenShell {ifcopenshell.version}")
|
||||
units = f.createIfcUnitAssignment(Units=[f.createIfcSIUnit(None, "LENGTHUNIT", None, "METRE")])
|
||||
ownerhist = f.createIfcOwnerHistory(pando, appl, ChangeAction="ADDED", CreationDate=int(time.time()))
|
||||
proj = f.createIfcProject(ifcopenshell.guid.new(), ownerhist, 'My Project', UnitsInContext=units, RepresentationContexts=[
|
||||
f.createIfcGeometricRepresentationContext(
|
||||
None, None, 3, None,
|
||||
f.create_entity(f'IfcAxis2Placement3D', f.createIfcCartesianPoint((0., 0., 0.))),
|
||||
)
|
||||
])
|
||||
proj = f.createIfcProject(
|
||||
ifcopenshell.guid.new(),
|
||||
ownerhist,
|
||||
"My Project",
|
||||
UnitsInContext=units,
|
||||
RepresentationContexts=[
|
||||
f.createIfcGeometricRepresentationContext(
|
||||
None,
|
||||
None,
|
||||
3,
|
||||
None,
|
||||
f.create_entity(f"IfcAxis2Placement3D", f.createIfcCartesianPoint((0.0, 0.0, 0.0))),
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
def elems():
|
||||
for ent in ents:
|
||||
el = f.create_entity(ent,
|
||||
ifcopenshell.guid.new(),
|
||||
ownerhist
|
||||
)
|
||||
if ent == 'IfcZone':
|
||||
f.createIfcRelAssignsToGroup(ifcopenshell.guid.new(),ownerhist,RelatedObjects=[f.createIfcSpace(ifcopenshell.guid.new(),
|
||||
ownerhist)],RelatingGroup=el)
|
||||
el = f.create_entity(ent, ifcopenshell.guid.new(), ownerhist)
|
||||
if ent == "IfcZone":
|
||||
f.createIfcRelAssignsToGroup(
|
||||
ifcopenshell.guid.new(),
|
||||
ownerhist,
|
||||
RelatedObjects=[f.createIfcSpace(ifcopenshell.guid.new(), ownerhist)],
|
||||
RelatingGroup=el,
|
||||
)
|
||||
yield el
|
||||
zone = f.createIfcZone(ifcopenshell.guid.new(),ownerhist)
|
||||
f.createIfcRelAssignsToGroup(ifcopenshell.guid.new(),ownerhist,RelatedObjects=list(elems()),RelatingGroup=zone)
|
||||
f.createIfcRelAggregates(ifcopenshell.guid.new(),ownerhist,RelatingObject=proj,RelatedObjects=f.by_type('IfcSpace'))
|
||||
valid = not (set(ents) - {'IfcZone', 'IfcSpace'})
|
||||
|
||||
zone = f.createIfcZone(ifcopenshell.guid.new(), ownerhist)
|
||||
f.createIfcRelAssignsToGroup(ifcopenshell.guid.new(), ownerhist, RelatedObjects=list(elems()), RelatingGroup=zone)
|
||||
f.createIfcRelAggregates(
|
||||
ifcopenshell.guid.new(), ownerhist, RelatingObject=proj, RelatedObjects=f.by_type("IfcSpace")
|
||||
)
|
||||
valid = not (set(ents) - {"IfcZone", "IfcSpace"})
|
||||
f.write(f"{'pass' if valid else 'fail'}-zone-with-{'-'.join(ents)}-{f.schema.lower()}.ifc")
|
||||
|
||||
@@ -2,13 +2,15 @@ import ifcopenshell
|
||||
|
||||
segs = [
|
||||
lambda _: None,
|
||||
lambda f: [f.createIfcLineIndex((1,2)),f.createIfcLineIndex((2,3))],
|
||||
lambda f: [f.createIfcLineIndex((1,2)),f.createIfcLineIndex((1,2))]
|
||||
lambda f: [f.createIfcLineIndex((1, 2)), f.createIfcLineIndex((2, 3))],
|
||||
lambda f: [f.createIfcLineIndex((1, 2)), f.createIfcLineIndex((1, 2))],
|
||||
]
|
||||
|
||||
for schema in ('ifc4', 'ifc4x3_add1'):
|
||||
for schema in ("ifc4", "ifc4x3_add1"):
|
||||
for i, seg in enumerate(segs):
|
||||
f = ifcopenshell.file(schema=schema)
|
||||
s = seg(f)
|
||||
f.createIfcIndexedPolyCurve(f.createIfcCartesianPointList2D([(0.0, 0.0),(0.0, 1.0),(1.0, 1.0)]), s)
|
||||
f.write(f'{"fail" if i == 2 else "pass"}-poly-curve-{"no-segments" if s is None else "-".join(["-".join(map(str, x[0])) for x in s])}-{schema}.ifc')
|
||||
f.createIfcIndexedPolyCurve(f.createIfcCartesianPointList2D([(0.0, 0.0), (0.0, 1.0), (1.0, 1.0)]), s)
|
||||
f.write(
|
||||
f'{"fail" if i == 2 else "pass"}-poly-curve-{"no-segments" if s is None else "-".join(["-".join(map(str, x[0])) for x in s])}-{schema}.ifc'
|
||||
)
|
||||
|
||||
@@ -6,21 +6,22 @@ import ifcopenshell.guid
|
||||
def test_global_id_updates():
|
||||
g1, g2, g3 = (ifcopenshell.guid.new() for i in range(3))
|
||||
f = ifcopenshell.file()
|
||||
|
||||
|
||||
f.createIfcWall(g1)
|
||||
f[g1].GlobalId = g2
|
||||
with pytest.raises(RuntimeError):
|
||||
f[g1]
|
||||
assert f[g2]
|
||||
|
||||
|
||||
inst = f.createIfcWall()
|
||||
inst.GlobalId = g3
|
||||
assert f[g3]
|
||||
|
||||
|
||||
# Non-unique guid, succeeds but logs an error
|
||||
ifcopenshell.get_log()
|
||||
inst = f.createIfcWall(g3)
|
||||
assert "Overwriting" in ifcopenshell.get_log()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main(["-sx", __file__])
|
||||
|
||||
@@ -2,17 +2,19 @@ import pytest
|
||||
import ifcopenshell
|
||||
import ifcopenshell.guid
|
||||
|
||||
|
||||
def test_file_gc():
|
||||
f = ifcopenshell.file()
|
||||
inst = f.createIfcWall(ifcopenshell.guid.new(), Name=chr(0x1F37A))
|
||||
# 0x1F37A should be encoded using X4
|
||||
assert '\\X4\\' in inst.to_string()
|
||||
assert "\\X4\\" in inst.to_string()
|
||||
# to_string() should use upper case entity names
|
||||
assert 'IFCWALL' in inst.to_string()
|
||||
assert "IFCWALL" in inst.to_string()
|
||||
# __str__ uses camel case entity names
|
||||
assert 'IfcWall' in str(inst)
|
||||
assert "IfcWall" in str(inst)
|
||||
# in fact, __str__ is equal to to_string(False)
|
||||
assert str(inst) == inst.to_string(False)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main(["-sx", __file__])
|
||||
|
||||
@@ -9,11 +9,11 @@ import ifcopenshell.api
|
||||
|
||||
|
||||
def test_inverse_indices():
|
||||
f = ifcopenshell.file()
|
||||
f = ifcopenshell.file()
|
||||
|
||||
p0 = f.createIfcCartesianPoint((0.,0.,0.))
|
||||
p1 = f.createIfcCartesianPoint((1.,0.,0.))
|
||||
p2 = f.createIfcCartesianPoint((1.,1.,0.))
|
||||
p0 = f.createIfcCartesianPoint((0.0, 0.0, 0.0))
|
||||
p1 = f.createIfcCartesianPoint((1.0, 0.0, 0.0))
|
||||
p2 = f.createIfcCartesianPoint((1.0, 1.0, 0.0))
|
||||
|
||||
poly = f.createIfcPolyline((p0, p1, p2, p0))
|
||||
place = f.createIfcAxis2Placement3D(p0)
|
||||
@@ -26,7 +26,7 @@ def test_inverse_indices():
|
||||
# @nb this doesn't account for nested lists
|
||||
v = list(v)
|
||||
i = v.index(p0)
|
||||
v[i:i+1] = []
|
||||
v[i : i + 1] = []
|
||||
else:
|
||||
v = p1
|
||||
inst[idx] = v
|
||||
|
||||
@@ -32,24 +32,16 @@ class TestOpen:
|
||||
assert ifcopenshell.open(TEST_FILE_DIR / "wall-with-opening-and-window.ifcxml")
|
||||
|
||||
def test_open_ifc_zip_ifcxml_format(self):
|
||||
assert ifcopenshell.open(
|
||||
TEST_FILE_DIR / "wall-with-opening-and-window_ifcxml_format.ifczip"
|
||||
)
|
||||
assert ifcopenshell.open(TEST_FILE_DIR / "wall-with-opening-and-window_ifcxml_format.ifczip")
|
||||
|
||||
def test_open_ifc_zip_ifcspf_format(self):
|
||||
assert ifcopenshell.open(
|
||||
TEST_FILE_DIR / "WallInstance_IFC4Add2_ifcspf_format.ifczip"
|
||||
)
|
||||
assert ifcopenshell.open(TEST_FILE_DIR / "WallInstance_IFC4Add2_ifcspf_format.ifczip")
|
||||
|
||||
def test_open_zip(self):
|
||||
assert ifcopenshell.open(
|
||||
TEST_FILE_DIR / "WallInstance_IFC4Add2_ifcspf_format.zip"
|
||||
)
|
||||
assert ifcopenshell.open(TEST_FILE_DIR / "WallInstance_IFC4Add2_ifcspf_format.zip")
|
||||
|
||||
def test_open_anyextension_ifcspf_format(self):
|
||||
assert ifcopenshell.open(
|
||||
TEST_FILE_DIR / "WallInstance_IFC4Add2_ifcspf_format.anyextension"
|
||||
)
|
||||
assert ifcopenshell.open(TEST_FILE_DIR / "WallInstance_IFC4Add2_ifcspf_format.anyextension")
|
||||
|
||||
def test_open_anyextension_ifczip_ifcspf_format(self):
|
||||
assert ifcopenshell.open(
|
||||
|
||||
@@ -9,10 +9,13 @@ import ifcopenshell.validate
|
||||
import ifcopenshell.express.rule_executor
|
||||
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"filename",
|
||||
[fn for fn in glob.glob(os.path.join(os.path.dirname(__file__), "fixtures/rules/*.ifc")) if len(sys.argv) < 2 or sys.argv[1] in os.path.basename(fn)],
|
||||
[
|
||||
fn
|
||||
for fn in glob.glob(os.path.join(os.path.dirname(__file__), "fixtures/rules/*.ifc"))
|
||||
if len(sys.argv) < 2 or sys.argv[1] in os.path.basename(fn)
|
||||
],
|
||||
)
|
||||
def test_file(filename):
|
||||
base = os.path.basename(filename)
|
||||
@@ -27,12 +30,14 @@ def test_file(filename):
|
||||
print(f"{len(results)} errors")
|
||||
|
||||
if results:
|
||||
print(tabulate.tabulate(
|
||||
[[c or '' for c in r.values()] for r in results],
|
||||
maxcolwidths=[20,100,20],
|
||||
tablefmt="simple_grid",
|
||||
headers=results[0].keys()
|
||||
))
|
||||
print(
|
||||
tabulate.tabulate(
|
||||
[[c or "" for c in r.values()] for r in results],
|
||||
maxcolwidths=[20, 100, 20],
|
||||
tablefmt="simple_grid",
|
||||
headers=results[0].keys(),
|
||||
)
|
||||
)
|
||||
|
||||
if base.startswith("fail-"):
|
||||
assert len(results) > 0
|
||||
|
||||
@@ -230,7 +230,11 @@ class TestWallOpenings:
|
||||
|
||||
if i == 0 and j == 0:
|
||||
for ln, st in cs:
|
||||
assert len([l for l in log if l.startswith(st)]) == ln, f"\nOn file:\n - {fn}\nMessages:" + "".join(f'\n - "{l}"' for l in log) + f"\nExpected:\n - \"{st}\""
|
||||
assert len([l for l in log if l.startswith(st)]) == ln, (
|
||||
f"\nOn file:\n - {fn}\nMessages:"
|
||||
+ "".join(f'\n - "{l}"' for l in log)
|
||||
+ f'\nExpected:\n - "{st}"'
|
||||
)
|
||||
|
||||
# breakpoint()
|
||||
|
||||
|
||||
@@ -379,23 +379,17 @@ class TestGetMaterial(test.bootstrap.IFC4):
|
||||
|
||||
def test_getting_a_material_layer_set_of_a_product(self):
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel = ifcopenshell.api.material.assign_material(
|
||||
self.file, products=[element], type="IfcMaterialLayerSet"
|
||||
)
|
||||
rel = ifcopenshell.api.material.assign_material(self.file, products=[element], type="IfcMaterialLayerSet")
|
||||
assert subject.get_material(element) == rel.RelatingMaterial
|
||||
|
||||
def test_getting_a_material_profile_set_of_a_product(self):
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel = ifcopenshell.api.material.assign_material(
|
||||
self.file, products=[element], type="IfcMaterialProfileSet"
|
||||
)
|
||||
rel = ifcopenshell.api.material.assign_material(self.file, products=[element], type="IfcMaterialProfileSet")
|
||||
assert subject.get_material(element) == rel.RelatingMaterial
|
||||
|
||||
def test_getting_a_material_layer_set_usage_of_a_product(self):
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel = ifcopenshell.api.material.assign_material(
|
||||
self.file, products=[element], type="IfcMaterialLayerSetUsage"
|
||||
)
|
||||
rel = ifcopenshell.api.material.assign_material(self.file, products=[element], type="IfcMaterialLayerSetUsage")
|
||||
assert subject.get_material(element) == rel.RelatingMaterial
|
||||
|
||||
def test_getting_a_material_profile_set_usage_of_a_product(self):
|
||||
@@ -407,9 +401,7 @@ class TestGetMaterial(test.bootstrap.IFC4):
|
||||
|
||||
def test_getting_a_material_layer_set_indirectly_from_an_assigned_usage(self):
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel = ifcopenshell.api.material.assign_material(
|
||||
self.file, products=[element], type="IfcMaterialLayerSetUsage"
|
||||
)
|
||||
rel = ifcopenshell.api.material.assign_material(self.file, products=[element], type="IfcMaterialLayerSetUsage")
|
||||
assert subject.get_material(element, should_skip_usage=True) == rel.RelatingMaterial.ForLayerSet
|
||||
|
||||
def test_getting_a_material_profile_set_indirectly_from_an_assigned_usage(self):
|
||||
@@ -501,9 +493,7 @@ class TestGetStyles(test.bootstrap.IFC4):
|
||||
self.file, context=body, length=5, height=3, thickness=0.118
|
||||
)
|
||||
|
||||
ifcopenshell.api.geometry.assign_representation(
|
||||
self.file, product=element, representation=representation
|
||||
)
|
||||
ifcopenshell.api.geometry.assign_representation(self.file, product=element, representation=representation)
|
||||
ifcopenshell.api.style.assign_representation_styles(
|
||||
self.file, shape_representation=representation, styles=[style2]
|
||||
)
|
||||
@@ -540,9 +530,7 @@ class TestGetElementsByMaterial(test.bootstrap.IFC4):
|
||||
material_set = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialProfileSet")
|
||||
ifcopenshell.api.material.add_profile(self.file, profile_set=material_set, material=material)
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element_type], material=material_set)
|
||||
ifcopenshell.api.material.assign_material(
|
||||
self.file, products=[element], type="IfcMaterialProfileSetUsage"
|
||||
)
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element], type="IfcMaterialProfileSetUsage")
|
||||
usage = self.file.by_type("IfcMaterialProfileSetUsage")[0]
|
||||
assert subject.get_elements_by_material(self.file, material) == {element, element_type}
|
||||
assert subject.get_elements_by_material(self.file, material_set) == {element, element_type}
|
||||
@@ -551,9 +539,7 @@ class TestGetElementsByMaterial(test.bootstrap.IFC4):
|
||||
def test_getting_elements_of_a_material_constituent_set(self):
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.material.add_material(self.file)
|
||||
material_set = ifcopenshell.api.material.add_material_set(
|
||||
self.file, set_type="IfcMaterialConstituentSet"
|
||||
)
|
||||
material_set = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialConstituentSet")
|
||||
ifcopenshell.api.material.add_constituent(self.file, constituent_set=material_set, material=material)
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element], material=material_set)
|
||||
assert subject.get_elements_by_material(self.file, material) == {element}
|
||||
|
||||
@@ -57,7 +57,7 @@ class TestPsetQto:
|
||||
assert "Pset_FurnitureTypeTable" in names
|
||||
names = self.pset_qto.get_applicable_names("IfcFurnitureType", "TABLE")
|
||||
assert "Pset_FurnitureTypeTable" in names
|
||||
names = self.pset_qto.get_applicable_names("IfcFurnitureType" )
|
||||
names = self.pset_qto.get_applicable_names("IfcFurnitureType")
|
||||
names2 = self.pset_qto.get_applicable_names("IfcFurnitureType", "CUSTOM")
|
||||
assert names == names2
|
||||
|
||||
|
||||
@@ -86,9 +86,7 @@ class TestGetElementValue(test.bootstrap.IFC4):
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.material.add_material(self.file, name="CON01")
|
||||
material2 = ifcopenshell.api.material.add_material(self.file, name="CON02")
|
||||
material_set = ifcopenshell.api.material.add_material_set(
|
||||
self.file, name="FOO", set_type="IfcMaterialLayerSet"
|
||||
)
|
||||
material_set = ifcopenshell.api.material.add_material_set(self.file, name="FOO", set_type="IfcMaterialLayerSet")
|
||||
layer = ifcopenshell.api.material.add_layer(self.file, layer_set=material_set, material=material)
|
||||
layer.Name = "L1"
|
||||
layer = ifcopenshell.api.material.add_layer(self.file, layer_set=material_set, material=material)
|
||||
@@ -113,9 +111,7 @@ class TestGetElementValue(test.bootstrap.IFC4):
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.material.add_material(self.file, name="CON01")
|
||||
material2 = ifcopenshell.api.material.add_material(self.file, name="CON02")
|
||||
material_set = ifcopenshell.api.material.add_material_set(
|
||||
self.file, name="FOO", set_type="IfcMaterialLayerSet"
|
||||
)
|
||||
material_set = ifcopenshell.api.material.add_material_set(self.file, name="FOO", set_type="IfcMaterialLayerSet")
|
||||
layer = ifcopenshell.api.material.add_layer(self.file, layer_set=material_set, material=material)
|
||||
layer.Name = "L1"
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element], material=material_set)
|
||||
|
||||
@@ -151,6 +151,7 @@ class TestConvertFileLengthUnits(test.bootstrap.IFC4):
|
||||
unit_assignment = subject.get_unit_assignment(output)
|
||||
assert len(unit_assignment.Units) == 1
|
||||
|
||||
|
||||
class TestConvertFileLengthUnitsIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_converting_map_conversion_if_there_is_no_map_unit(self):
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
@@ -171,7 +172,9 @@ class TestConvertFileLengthUnitsIFC2X3(test.bootstrap.IFC2X3):
|
||||
ifcopenshell.api.context.add_context(self.file, "Model")
|
||||
ifcopenshell.api.georeference.add_georeferencing(self.file)
|
||||
ifcopenshell.api.georeference.edit_georeferencing(
|
||||
self.file, projected_crs={"MapUnit": subject.get_full_unit_name(meter)}, coordinate_operation={"Eastings": 10, "Scale": 0.001}
|
||||
self.file,
|
||||
projected_crs={"MapUnit": subject.get_full_unit_name(meter)},
|
||||
coordinate_operation={"Eastings": 10, "Scale": 0.001},
|
||||
)
|
||||
ifcopenshell.api.unit.assign_unit(self.file, units=[unit])
|
||||
output = subject.convert_file_length_units(self.file, target_units="METER")
|
||||
|
||||
Reference in New Issue
Block a user