mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 18:57:17 +00:00
typing
This commit is contained in:
@@ -19,7 +19,6 @@
|
|||||||
import bpy
|
import bpy
|
||||||
import mathutils
|
import mathutils
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from functools import reduce
|
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
import ifcopenshell.util.system
|
import ifcopenshell.util.system
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ def disable_editing_sheets(drawing: tool.Drawing) -> None:
|
|||||||
drawing.disable_editing_sheets()
|
drawing.disable_editing_sheets()
|
||||||
|
|
||||||
|
|
||||||
def add_sheet(ifc: tool.Ifc, drawing, titleblock: ifcopenshell.entity_instance) -> None:
|
def add_sheet(ifc: tool.Ifc, drawing: tool.Drawing, titleblock: ifcopenshell.entity_instance) -> None:
|
||||||
sheet = ifc.run("document.add_information")
|
sheet = ifc.run("document.add_information")
|
||||||
layout = ifc.run("document.add_reference", information=sheet)
|
layout = ifc.run("document.add_reference", information=sheet)
|
||||||
titleblock_reference = ifc.run("document.add_reference", information=sheet)
|
titleblock_reference = ifc.run("document.add_reference", information=sheet)
|
||||||
@@ -127,7 +127,9 @@ def remove_sheet(ifc: tool.Ifc, drawing: tool.Drawing, sheet: ifcopenshell.entit
|
|||||||
drawing.import_sheets()
|
drawing.import_sheets()
|
||||||
|
|
||||||
|
|
||||||
def rename_sheet(ifc: tool.Ifc, drawing, sheet: ifcopenshell.entity_instance, identification: str, name: str) -> None:
|
def rename_sheet(
|
||||||
|
ifc: tool.Ifc, drawing: tool.Drawing, sheet: ifcopenshell.entity_instance, identification: str, name: str
|
||||||
|
) -> None:
|
||||||
if ifc.get_schema() == "IFC2X3":
|
if ifc.get_schema() == "IFC2X3":
|
||||||
attributes = {"DocumentId": identification, "Name": name}
|
attributes = {"DocumentId": identification, "Name": name}
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import numpy as np
|
|||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
import ifcopenshell.ifcopenshell_wrapper as ifcopenshell_wrapper
|
import ifcopenshell.ifcopenshell_wrapper as ifcopenshell_wrapper
|
||||||
import ifcopenshell.util.element
|
import ifcopenshell.util.element
|
||||||
|
import ifcopenshell.util.schema
|
||||||
import bonsai.core.tool
|
import bonsai.core.tool
|
||||||
import bonsai.bim.handler
|
import bonsai.bim.handler
|
||||||
import bonsai.tool as tool
|
import bonsai.tool as tool
|
||||||
@@ -60,7 +61,7 @@ class Ifc(bonsai.core.tool.Ifc):
|
|||||||
return IfcStore.path
|
return IfcStore.path
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_schema(cls) -> str:
|
def get_schema(cls) -> ifcopenshell.util.schema.IFC_SCHEMA:
|
||||||
if IfcStore.get_file():
|
if IfcStore.get_file():
|
||||||
return IfcStore.get_file().schema
|
return IfcStore.get_file().schema
|
||||||
|
|
||||||
|
|||||||
@@ -24,11 +24,14 @@ import zipfile
|
|||||||
import functools
|
import functools
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional, Any, Union, Callable, Generator, Literal
|
from typing import Optional, Any, Union, Callable, Generator, Literal, TYPE_CHECKING
|
||||||
|
|
||||||
from . import ifcopenshell_wrapper
|
from . import ifcopenshell_wrapper
|
||||||
from .entity_instance import entity_instance
|
from .entity_instance import entity_instance
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
import ifcopenshell.util.schema
|
||||||
|
|
||||||
|
|
||||||
class Transaction:
|
class Transaction:
|
||||||
def __init__(self, ifc_file):
|
def __init__(self, ifc_file):
|
||||||
@@ -406,7 +409,7 @@ class file:
|
|||||||
return e
|
return e
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def schema(self) -> Literal["IFC2X3", "IFC4", "IFC4X3"]:
|
def schema(self) -> ifcopenshell.util.schema.IFC_SCHEMA:
|
||||||
"""General IFC schema version: IFC2X3, IFC4, IFC4X3."""
|
"""General IFC schema version: IFC2X3, IFC4, IFC4X3."""
|
||||||
prefixes = ("IFC", "X", "_ADD", "_TC")
|
prefixes = ("IFC", "X", "_ADD", "_TC")
|
||||||
reg = "".join(f"(?P<{s}>{s}\\d+)?" for s in prefixes)
|
reg = "".join(f"(?P<{s}>{s}\\d+)?" for s in prefixes)
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ IFC4x3_SPEC_URL_TEMPLATE = "https://ifc43-docs.standards.buildingsmart.org/IFC/R
|
|||||||
# child -> description
|
# child -> description
|
||||||
# note: in IFC4x3 there is no children[] for properties
|
# note: in IFC4x3 there is no children[] for properties
|
||||||
|
|
||||||
SUPPORTED_SCHEMA = Literal["IFC2X3", "IFC4", "IFC4X3"]
|
SUPPORTED_SCHEMA = ifcopenshell.util.schema.IFC_SCHEMA
|
||||||
SCHEMA_FILES: dict[SUPPORTED_SCHEMA, dict] = {
|
SCHEMA_FILES: dict[SUPPORTED_SCHEMA, dict] = {
|
||||||
"IFC2X3": {
|
"IFC2X3": {
|
||||||
"entities": BASE_MODULE_PATH / "schema/ifc2x3_entities.json",
|
"entities": BASE_MODULE_PATH / "schema/ifc2x3_entities.json",
|
||||||
|
|||||||
@@ -22,11 +22,12 @@ import time
|
|||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import ifcopenshell.util.attribute
|
import ifcopenshell.util.attribute
|
||||||
import ifcopenshell.ifcopenshell_wrapper as ifcopenshell_wrapper
|
import ifcopenshell.ifcopenshell_wrapper as ifcopenshell_wrapper
|
||||||
from typing import Union, Any
|
from typing import Union, Any, Literal
|
||||||
|
|
||||||
# This is highly experimental and incomplete, however, it may work for simple datasets.
|
# This is highly experimental and incomplete, however, it may work for simple datasets.
|
||||||
|
|
||||||
cwd = os.path.dirname(os.path.realpath(__file__))
|
cwd = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
IFC_SCHEMA = Literal["IFC2X3", "IFC4", "IFC4X3"]
|
||||||
|
|
||||||
|
|
||||||
def get_fallback_schema(version: str) -> str:
|
def get_fallback_schema(version: str) -> str:
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ from typing import List
|
|||||||
|
|
||||||
cwd = os.path.dirname(os.path.realpath(__file__))
|
cwd = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
entity_to_type_map = {}
|
entity_to_type_map: dict[ifcopenshell.util.schema.IFC_SCHEMA, dict[str, list[str]]] = {}
|
||||||
type_to_entity_map = {}
|
type_to_entity_map: dict[ifcopenshell.util.schema.IFC_SCHEMA, dict[str, list[str]]] = {}
|
||||||
|
|
||||||
mapped_schemas = {
|
mapped_schemas = {
|
||||||
"IFC2X3": "entity_to_type_map_2x3.json",
|
"IFC2X3": "entity_to_type_map_2x3.json",
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class Patcher:
|
|||||||
src: str,
|
src: str,
|
||||||
file: ifcopenshell.file,
|
file: ifcopenshell.file,
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
schema: typing.Literal["IFC2X3", "IFC4", "IFC4X3"] = "IFC4",
|
schema: ifcopenshell.util.schema.IFC_SCHEMA = "IFC4",
|
||||||
):
|
):
|
||||||
"""Migrate from one IFC version to another
|
"""Migrate from one IFC version to another
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user