mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
typing
This commit is contained in:
@@ -147,5 +147,6 @@ def add_task(
|
||||
relating_object=parent_task,
|
||||
)
|
||||
if file.schema != "IFC2X3" and parent_task.Identification:
|
||||
assert rel
|
||||
task.Identification = parent_task.Identification + "." + str(len(rel.RelatedObjects))
|
||||
return task
|
||||
|
||||
@@ -21,6 +21,7 @@ import ifcopenshell
|
||||
from typing import Optional, Union, Literal, Any
|
||||
from collections.abc import Generator
|
||||
import ifcopenshell.ifcopenshell_wrapper as ifcopenshell_wrapper
|
||||
import ifcopenshell.util.attribute
|
||||
from ifcopenshell.util.doc import get_predefined_type_doc
|
||||
from ifcopenshell.util.element import get_psets
|
||||
from ifcopenshell.util.unit import get_unit_symbol
|
||||
@@ -283,13 +284,13 @@ def get_cost_values(cost_item: ifcopenshell.entity_instance) -> list[dict[str, s
|
||||
|
||||
def get_cost_schedule_types(file: ifcopenshell.file) -> list[dict[str, str]]:
|
||||
schema = ifcopenshell_wrapper.schema_by_name(file.schema_identifier)
|
||||
results = []
|
||||
results: list[dict[str, str]] = []
|
||||
declaration = schema.declaration_by_name("IfcCostSchedule").as_entity()
|
||||
assert declaration
|
||||
version = file.schema_identifier
|
||||
for attribute in declaration.attributes():
|
||||
if attribute.name() == "PredefinedType":
|
||||
for enumeration in attribute.type_of_attribute().declared_type().enumeration_items():
|
||||
for enumeration in ifcopenshell.util.attribute.get_enum_items(attribute):
|
||||
results.append(
|
||||
{
|
||||
"name": enumeration,
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
RUN_FROM_DEV_REPO = False
|
||||
|
||||
import ifcopenshell.ifcopenshell_wrapper as ifcopenshell_wrapper
|
||||
import ifcopenshell.ifcopenshell_wrapper as W
|
||||
import ifcopenshell.api.unit
|
||||
import ifcopenshell.api.project
|
||||
import ifcopenshell.guid
|
||||
@@ -28,6 +28,7 @@ import sys
|
||||
from pathlib import Path
|
||||
from lxml import etree
|
||||
from itertools import chain
|
||||
from typing import cast
|
||||
|
||||
|
||||
if not RUN_FROM_DEV_REPO:
|
||||
@@ -128,11 +129,17 @@ class PsetTemplatesGenerator:
|
||||
self.units = dict()
|
||||
schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(self.ifc_file.schema_identifier)
|
||||
|
||||
self.ifc_derived_unit_enum = (
|
||||
schema.declaration_by_name("IfcDerivedUnitEnum").as_enumeration_type().enumeration_items()
|
||||
)
|
||||
self.ifc_unit_enum = schema.declaration_by_name("IfcUnitEnum").as_enumeration_type().enumeration_items()
|
||||
select_types = schema.declaration_by_name("IfcValue").select_list()
|
||||
derived_unit_enum = schema.declaration_by_name("IfcDerivedUnitEnum").as_enumeration_type()
|
||||
assert derived_unit_enum
|
||||
self.ifc_derived_unit_enum = derived_unit_enum.enumeration_items()
|
||||
|
||||
ifc_unit_enum = schema.declaration_by_name("IfcUnitEnum").as_enumeration_type()
|
||||
assert ifc_unit_enum
|
||||
self.ifc_unit_enum = ifc_unit_enum.enumeration_items()
|
||||
|
||||
value_select = schema.declaration_by_name("IfcValue").as_select_type()
|
||||
assert value_select
|
||||
select_types = cast(tuple[W.select_type, ...], value_select.select_list())
|
||||
self.ifc_value_types = [t.name() for t in chain(*[select_type.select_list() for select_type in select_types])]
|
||||
|
||||
project = self.ifc_entity("IfcProject", Name=project_name, GlobalId=ifcopenshell.guid.new())
|
||||
|
||||
Reference in New Issue
Block a user