mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-14 11:24:19 +00:00
ty: detect unresolved references
This commit is contained in:
@@ -112,6 +112,8 @@ def sum_child_root_elements(root_element: ifcopenshell.entity_instance, category
|
||||
values = new_child_root_element.CostValues
|
||||
elif root_element.is_a("IfcConstructionResource"):
|
||||
values = child_root_element.BaseCosts
|
||||
else:
|
||||
assert False, root_element
|
||||
for child_cost_value in values or []:
|
||||
if category_filter and child_cost_value.Category != category_filter:
|
||||
continue
|
||||
|
||||
@@ -329,6 +329,8 @@ def get_quantity(
|
||||
data["properties"] = get_quantities(quantity.HasQuantities, verbose=verbose)
|
||||
del data["HasQuantities"]
|
||||
result = data
|
||||
else:
|
||||
assert False, quantity
|
||||
if verbose:
|
||||
result = {"id": quantity.id(), "class": quantity.is_a(), "value": result}
|
||||
return result
|
||||
@@ -385,6 +387,7 @@ def get_property(
|
||||
if prop.Name != name:
|
||||
continue
|
||||
is_single_value = False # For now we pass value type only for single values.
|
||||
result_type = None
|
||||
if prop.is_a("IfcPropertySingleValue"):
|
||||
# 2 IfcPropertySingleValue.NominalValue
|
||||
result = v.wrappedValue if (v := prop[2]) else None
|
||||
@@ -407,6 +410,8 @@ def get_property(
|
||||
data["properties"] = get_properties(prop.HasProperties, verbose=verbose)
|
||||
del data["HasProperties"]
|
||||
result = data
|
||||
else:
|
||||
assert False, prop
|
||||
if verbose:
|
||||
result = {"id": prop.id(), "class": prop.is_a(), "value": result}
|
||||
if is_single_value:
|
||||
|
||||
@@ -260,6 +260,8 @@ def get_helmert_transformation_parameters(ifc_file: ifcopenshell.file) -> Option
|
||||
xaa = 1.0
|
||||
xao = 0.0
|
||||
scale = factor_x = factor_y = factor_z = 1
|
||||
else:
|
||||
assert False, conversion
|
||||
|
||||
if not xaa and not xao:
|
||||
xaa = 1.0
|
||||
|
||||
@@ -18,18 +18,16 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
try:
|
||||
from lark import Lark, Transformer
|
||||
from lark.exceptions import UnexpectedCharacters, UnexpectedEOF, UnexpectedToken
|
||||
|
||||
LARK_AVAILABLE = True
|
||||
except ImportError:
|
||||
LARK_AVAILABLE = False
|
||||
|
||||
import importlib.util
|
||||
import re
|
||||
from typing import Union
|
||||
|
||||
LARK_AVAILABLE = importlib.util.find_spec("lark") is not None
|
||||
|
||||
if LARK_AVAILABLE:
|
||||
from lark import Lark, Transformer
|
||||
from lark.exceptions import UnexpectedCharacters, UnexpectedEOF, UnexpectedToken
|
||||
|
||||
mvd_grammar = r"""
|
||||
start: entry+
|
||||
|
||||
@@ -92,9 +90,9 @@ if LARK_AVAILABLE:
|
||||
self.store_text_attribute(args, "options")
|
||||
|
||||
def dynamic_option(self, args):
|
||||
original_keyword = str(args[0])
|
||||
key = original_keyword.lower()
|
||||
try:
|
||||
original_keyword = str(args[0])
|
||||
key = original_keyword.lower()
|
||||
raw_text = args[1].children[0].value
|
||||
parsed_value = parse_semicolon_separated_kv(raw_text)
|
||||
self._dynamic[key] = (parsed_value, original_keyword)
|
||||
|
||||
@@ -89,6 +89,9 @@ def get_axis2placement(placement: ifcopenshell.entity_instance) -> MatrixType:
|
||||
x = np.array((1, 0, 0))
|
||||
o = placement.Location.Coordinates
|
||||
|
||||
else:
|
||||
assert False, placement
|
||||
|
||||
return a2p(o, z, x)
|
||||
|
||||
|
||||
|
||||
@@ -584,6 +584,7 @@ class Migrator:
|
||||
# NOTE: `attribute` is an attribute in new file schema
|
||||
# print("Migrating attribute", element, new_element, attribute.name())
|
||||
old_file = element.wrapped_data.file
|
||||
value = ...
|
||||
if hasattr(element, attribute.name()):
|
||||
value = getattr(element, attribute.name())
|
||||
# print("Attribute names matched", value)
|
||||
@@ -622,9 +623,7 @@ class Migrator:
|
||||
except: # We tried our best
|
||||
return
|
||||
|
||||
try:
|
||||
value
|
||||
except UnboundLocalError:
|
||||
if value is ...:
|
||||
print(
|
||||
f"Couldn't match attribute {attribute.name()} by name to migrate from {element} "
|
||||
f"to {new_element} and there is no special mapping to handle migration "
|
||||
|
||||
@@ -1279,6 +1279,8 @@ class FacetTransformer(lark.Transformer):
|
||||
result = bool(value.match(element_value)) if element_value is not None else False
|
||||
elif value in (None, True, False):
|
||||
result = element_value is value
|
||||
else:
|
||||
assert False, value
|
||||
|
||||
if comparison.startswith("!"):
|
||||
return not result
|
||||
|
||||
@@ -210,6 +210,8 @@ def np_rotation_matrix(
|
||||
matrix = np.array([[cos_theta, 0, sin_theta], [0, 1, 0], [-sin_theta, 0, cos_theta]])
|
||||
elif axis == "Z":
|
||||
matrix = np.array([[cos_theta, -sin_theta, 0], [sin_theta, cos_theta, 0], [0, 0, 1]])
|
||||
else:
|
||||
assert False, axis
|
||||
else:
|
||||
# Assume axis is a vector.
|
||||
axis = axis / np.linalg.norm(axis)
|
||||
|
||||
Reference in New Issue
Block a user