This commit is contained in:
Andrej730
2025-07-08 12:55:49 +05:00
parent 525ef2b77b
commit d08756d1b4
9 changed files with 87 additions and 34 deletions
@@ -143,6 +143,7 @@ class Usecase:
else:
vx = vz.cross(X_AXIS)
vy = vx.cross(vz)
assert isinstance(vy, Vector)
tM = Matrix(
[[vx.x, vy.x, vz.x, co.x], [vx.y, vy.y, vz.y, co.y], [vx.z, vy.z, vz.z, co.z], [0, 0, 0, 1]]
).inverted()
@@ -568,6 +568,8 @@ class entity_instance:
) -> dict[str, Any]:
"""Return a dictionary of the entity_instance's properties (Python and IFC) and their values.
Resulting dictionary keys: 'id', 'type', all entity attribute names.
:param include_identifier: Whether or not to include the STEP numerical identifier
:param recursive: Whether or not to convert referenced IFC elements into dictionaries too. All attributes also apply recursively
:param return_type: The return data type to be casted into
@@ -584,7 +584,7 @@ class aggregation_type(parameter_type):
bag_type: Any
list_type: Any
set_type: Any
def as_aggregation_type(self): ...
def as_aggregation_type(self) -> aggregation_type: ...
def bound1(self): ...
def bound2(self): ...
def type_of_aggregation(self): ...
@@ -1120,8 +1120,8 @@ class matrix4(item):
class named_type(parameter_type):
def _is(self, *args): ...
def as_named_type(self): ...
def declared_type(self): ...
def as_named_type(self) -> named_type: ...
def declared_type(self) -> declaration: ...
class node(item):
def calc_hash(self): ...
@@ -1146,10 +1146,16 @@ class offset_function(function_item):
def start(self): ...
class parameter_type:
def _is(self, *args): ...
def as_aggregation_type(self): ...
def as_named_type(self): ...
def as_simple_type(self): ...
def _is(self, *args: Union[str, declaration]) -> bool:
"""
:param args: IFC class name or declaration to check.
Argument accepts only 1 value.
"""
...
def as_aggregation_type(self) -> Union[aggregation_type, None]: ...
def as_named_type(self) -> Union[named_type, None]: ...
def as_simple_type(self) -> Union[simple_type, None]: ...
class piecewise_function(function_item):
def calc_hash(self): ...
@@ -1268,7 +1274,7 @@ class simple_type(parameter_type):
real_type: Any
string_type: Any
datatype_COUNT: Any
def as_simple_type(self): ...
def as_simple_type(self) -> simple_type: ...
def declared_type(self): ...
class solid:
@@ -17,13 +17,22 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell.ifcopenshell_wrapper as ifcopenshell_wrapper
from typing import Union
from typing import Union, Literal
PrimitiveType = Literal["entity", "string", "float", "integer", "boolean", "enum", "binary"]
ComplexPrimitiveType = Literal["list", "array", "set"]
PrimitiveTypeOutput = Union[
PrimitiveType,
tuple[ComplexPrimitiveType, "PrimitiveTypeOutput"],
tuple[Literal["select"], tuple["PrimitiveTypeOutput", ...]],
None,
]
def get_primitive_type(
attribute_or_data_type: Union[ifcopenshell_wrapper.attribute, ifcopenshell_wrapper.parameter_type],
) -> Union[str, tuple[str, list[str]]]:
if hasattr(attribute_or_data_type, "type_of_attribute"):
) -> PrimitiveTypeOutput:
if isinstance(attribute_or_data_type, ifcopenshell_wrapper.attribute):
data_type = str(attribute_or_data_type.type_of_attribute())
else:
data_type = str(attribute_or_data_type)
@@ -56,8 +65,16 @@ def get_primitive_type(
def get_enum_items(attribute: ifcopenshell_wrapper.attribute) -> tuple[str, ...]:
return attribute.type_of_attribute().declared_type().enumeration_items()
named_type = attribute.type_of_attribute().as_named_type()
assert named_type
enumeration = named_type.declared_type().as_enumeration_type()
assert enumeration
return enumeration.enumeration_items()
def get_select_items(attribute: ifcopenshell_wrapper.attribute) -> tuple[ifcopenshell_wrapper.entity, ...]:
return attribute.type_of_attribute().declared_type().select_list()
def get_select_items(attribute: ifcopenshell_wrapper.attribute) -> tuple[ifcopenshell_wrapper.declaration, ...]:
named_type = attribute.type_of_attribute().as_named_type()
assert named_type
select_type = named_type.declared_type().as_select_type()
assert select_type
return select_type.select_list()