mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 22:12:32 +00:00
typing
This commit is contained in:
@@ -130,7 +130,10 @@ class PortData:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load(cls):
|
def load(cls):
|
||||||
element = tool.Ifc.get_entity(bpy.context.active_object)
|
obj = bpy.context.active_object
|
||||||
|
assert obj
|
||||||
|
element = tool.Ifc.get_entity(obj)
|
||||||
|
assert element
|
||||||
cls.element = element
|
cls.element = element
|
||||||
is_port = cls.is_port()
|
is_port = cls.is_port()
|
||||||
cls.data = {
|
cls.data = {
|
||||||
@@ -145,19 +148,19 @@ class PortData:
|
|||||||
cls.is_loaded = True
|
cls.is_loaded = True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def total_ports(cls):
|
def total_ports(cls) -> int:
|
||||||
return len(ifcopenshell.util.system.get_ports(cls.element))
|
return len(ifcopenshell.util.system.get_ports(cls.element))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def is_port(cls):
|
def is_port(cls) -> bool:
|
||||||
return cls.element and cls.element.is_a("IfcDistributionPort")
|
return bool(cls.element and cls.element.is_a("IfcDistributionPort"))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def port_relating_object_name(cls):
|
def port_relating_object_name(cls) -> str:
|
||||||
return tool.Ifc.get_object(tool.System.get_port_relating_element(cls.element)).name
|
return tool.Ifc.get_object(tool.System.get_port_relating_element(cls.element)).name
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def port_connected_object_name(cls):
|
def port_connected_object_name(cls) -> Union[str, None]:
|
||||||
connected_port = tool.System.get_connected_port(cls.element)
|
connected_port = tool.System.get_connected_port(cls.element)
|
||||||
if not connected_port:
|
if not connected_port:
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -30,13 +30,21 @@ cwd = os.path.dirname(os.path.realpath(__file__))
|
|||||||
IFC_SCHEMA = Literal["IFC2X3", "IFC4", "IFC4X3"]
|
IFC_SCHEMA = Literal["IFC2X3", "IFC4", "IFC4X3"]
|
||||||
|
|
||||||
|
|
||||||
def get_fallback_schema(version: str) -> str:
|
def get_fallback_schema(version: str) -> IFC_SCHEMA:
|
||||||
"""fallback to the schema version we do have docs and mapping for,
|
"""Fallback to the schema version we do have docs and mapping for.
|
||||||
needed to support IFC versions like 4X3_RC1, 4X1 etc"""
|
|
||||||
|
Needed to support IFC versions like 4X3_RC1, 4X1 etc.
|
||||||
|
|
||||||
|
:param version: Typically a string from ``ifcopenshell.file.schema_identifier``, e.g. IFC4X3_ADD2
|
||||||
|
"""
|
||||||
if version.startswith("IFC4X3"):
|
if version.startswith("IFC4X3"):
|
||||||
version = "IFC4X3"
|
version = "IFC4X3"
|
||||||
elif version.startswith("IFC4"):
|
elif version.startswith("IFC4"):
|
||||||
version = "IFC4"
|
version = "IFC4"
|
||||||
|
elif version.startswith("IFC2X3"):
|
||||||
|
version = "IFC2X3"
|
||||||
|
else:
|
||||||
|
assert False, f"Unexpected schema version: {version}."
|
||||||
return version
|
return version
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user