mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 06:58:56 +00:00
typing
This commit is contained in:
@@ -24,7 +24,7 @@ import ifcopenshell.util.doc
|
|||||||
import ifcopenshell.util.schema
|
import ifcopenshell.util.schema
|
||||||
import bonsai.tool as tool
|
import bonsai.tool as tool
|
||||||
from bonsai.bim.module.drawing.helper import format_distance
|
from bonsai.bim.module.drawing.helper import format_distance
|
||||||
from typing import Any
|
from typing import Any, Union
|
||||||
|
|
||||||
|
|
||||||
def refresh():
|
def refresh():
|
||||||
@@ -174,7 +174,7 @@ class ObjectMaterialData:
|
|||||||
cls.is_loaded = True
|
cls.is_loaded = True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def material_class(cls):
|
def material_class(cls) -> Union[str, None]:
|
||||||
element = tool.Ifc.get_entity(bpy.context.active_object)
|
element = tool.Ifc.get_entity(bpy.context.active_object)
|
||||||
cls.material = ifcopenshell.util.element.get_material(element)
|
cls.material = ifcopenshell.util.element.get_material(element)
|
||||||
if cls.material:
|
if cls.material:
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ def purge():
|
|||||||
qtonames = {}
|
qtonames = {}
|
||||||
|
|
||||||
|
|
||||||
def blender_formatted_enum_from_psets(psets):
|
def blender_formatted_enum_from_psets(psets: list[ifcopenshell.entity_instance]) -> list[tuple[str, str, str]]:
|
||||||
enum_items = []
|
enum_items = []
|
||||||
version = tool.Ifc.get_schema()
|
version = tool.Ifc.get_schema()
|
||||||
for pset in psets:
|
for pset in psets:
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
|
import ifcopenshell.util.element
|
||||||
import ifcopenshell.util.geolocation
|
import ifcopenshell.util.geolocation
|
||||||
from typing import Union, Optional
|
from typing import Union, Optional
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ import uuid
|
|||||||
from .file import file
|
from .file import file
|
||||||
from .guid import compress
|
from .guid import compress
|
||||||
from .ifcopenshell_wrapper import version
|
from .ifcopenshell_wrapper import version
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
# A quick way to setup an 'empty' IFC file, taken from:
|
# A quick way to setup an 'empty' IFC file, taken from:
|
||||||
# http://academy.ifcopenshell.org/creating-a-simple-wall-with-property-set-and-quantity-information/
|
# http://academy.ifcopenshell.org/creating-a-simple-wall-with-property-set-and-quantity-information/
|
||||||
@@ -68,17 +70,17 @@ DEFAULTS = {
|
|||||||
|
|
||||||
|
|
||||||
def create(
|
def create(
|
||||||
filename=None,
|
filename: Optional[str] = None,
|
||||||
timestring=None,
|
timestring: Optional[str] = None,
|
||||||
organization=None,
|
organization: Optional[str] = None,
|
||||||
creator=None,
|
creator: Optional[str] = None,
|
||||||
schema_identifier=None,
|
schema_identifier: Optional[str] = None,
|
||||||
application_version=None,
|
application_version: Optional[str] = None,
|
||||||
timestamp=None,
|
timestamp: Optional[str] = None,
|
||||||
application=None,
|
application: Optional[str] = None,
|
||||||
project_globalid=None,
|
project_globalid: Optional[str] = None,
|
||||||
project_name=None,
|
project_name: Optional[str] = None,
|
||||||
):
|
) -> file:
|
||||||
d = dict(locals())
|
d = dict(locals())
|
||||||
|
|
||||||
def _():
|
def _():
|
||||||
|
|||||||
@@ -185,8 +185,8 @@ class IFC_Sv_write_file(bpy.types.Operator):
|
|||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return any("IFC" in n for n in context.space_data.edit_tree.nodes.keys())
|
return any("IFC" in n for n in context.space_data.edit_tree.nodes.keys())
|
||||||
|
|
||||||
def ensure_hirarchy(self, file):
|
def ensure_hirarchy(self, file: ifcopenshell.file) -> None:
|
||||||
elements_in_buildings = set()
|
elements_in_buildings: set[ifcopenshell.entity_instance] = set()
|
||||||
if len(file.by_type("IfcBuilding")) == 0:
|
if len(file.by_type("IfcBuilding")) == 0:
|
||||||
my_building = ifcopenshell.api.run("root.create_entity", file, ifc_class="IfcBuilding", name="My Building")
|
my_building = ifcopenshell.api.run("root.create_entity", file, ifc_class="IfcBuilding", name="My Building")
|
||||||
elements = ifcopenshell.util.element.get_decomposition(my_building)
|
elements = ifcopenshell.util.element.get_decomposition(my_building)
|
||||||
@@ -269,6 +269,7 @@ class IFC_PT_write_file_panel(bpy.types.Panel):
|
|||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
if context.space_data.edit_tree and any("IFC" in n for n in context.space_data.edit_tree.nodes.keys()):
|
if context.space_data.edit_tree and any("IFC" in n for n in context.space_data.edit_tree.nodes.keys()):
|
||||||
return True
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
ng = context.space_data.node_tree
|
ng = context.space_data.node_tree
|
||||||
|
|||||||
@@ -21,11 +21,12 @@ import ifcopenshell
|
|||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
import ifcopenshell.util.representation
|
import ifcopenshell.util.representation
|
||||||
from ifcopenshell import template
|
from ifcopenshell import template
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
|
||||||
class SvIfcStore:
|
class SvIfcStore:
|
||||||
path = ""
|
path = ""
|
||||||
file = None
|
file: Union[ifcopenshell.file, None] = None
|
||||||
schema = None
|
schema = None
|
||||||
cache = None
|
cache = None
|
||||||
cache_path = None
|
cache_path = None
|
||||||
@@ -47,7 +48,7 @@ class SvIfcStore:
|
|||||||
schema_identifiers = ["IFC4", "IFC2X3"]
|
schema_identifiers = ["IFC4", "IFC2X3"]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def purge():
|
def purge() -> None:
|
||||||
SvIfcStore.path = ""
|
SvIfcStore.path = ""
|
||||||
SvIfcStore.file = None
|
SvIfcStore.file = None
|
||||||
SvIfcStore.schema = None
|
SvIfcStore.schema = None
|
||||||
@@ -67,8 +68,7 @@ class SvIfcStore:
|
|||||||
SvIfcStore.schema_identifiers = ["IFC4", "IFC2X3"]
|
SvIfcStore.schema_identifiers = ["IFC4", "IFC2X3"]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_boilerplate():
|
def create_boilerplate() -> ifcopenshell.file:
|
||||||
|
|
||||||
file = template.create(
|
file = template.create(
|
||||||
filename="IfcSverchokDemoFile",
|
filename="IfcSverchokDemoFile",
|
||||||
organization=None,
|
organization=None,
|
||||||
@@ -93,7 +93,7 @@ class SvIfcStore:
|
|||||||
return SvIfcStore.file
|
return SvIfcStore.file
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_file():
|
def get_file() -> ifcopenshell.file:
|
||||||
if SvIfcStore.file is None:
|
if SvIfcStore.file is None:
|
||||||
SvIfcStore.create_boilerplate()
|
SvIfcStore.create_boilerplate()
|
||||||
return SvIfcStore.file
|
return SvIfcStore.file
|
||||||
|
|||||||
Reference in New Issue
Block a user