This commit is contained in:
Andrej730
2024-10-28 11:23:35 +05:00
parent 86d0139f41
commit bdbe91f043
6 changed files with 25 additions and 21 deletions
@@ -24,7 +24,7 @@ import ifcopenshell.util.doc
import ifcopenshell.util.schema
import bonsai.tool as tool
from bonsai.bim.module.drawing.helper import format_distance
from typing import Any
from typing import Any, Union
def refresh():
@@ -174,7 +174,7 @@ class ObjectMaterialData:
cls.is_loaded = True
@classmethod
def material_class(cls):
def material_class(cls) -> Union[str, None]:
element = tool.Ifc.get_entity(bpy.context.active_object)
cls.material = ifcopenshell.util.element.get_material(element)
if cls.material:
+1 -1
View File
@@ -52,7 +52,7 @@ def purge():
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 = []
version = tool.Ifc.get_schema()
for pset in psets:
@@ -17,6 +17,7 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
import ifcopenshell.util.element
import ifcopenshell.util.geolocation
from typing import Union, Optional
@@ -23,6 +23,8 @@ import uuid
from .file import file
from .guid import compress
from .ifcopenshell_wrapper import version
from typing import Optional
# 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/
@@ -68,17 +70,17 @@ DEFAULTS = {
def create(
filename=None,
timestring=None,
organization=None,
creator=None,
schema_identifier=None,
application_version=None,
timestamp=None,
application=None,
project_globalid=None,
project_name=None,
):
filename: Optional[str] = None,
timestring: Optional[str] = None,
organization: Optional[str] = None,
creator: Optional[str] = None,
schema_identifier: Optional[str] = None,
application_version: Optional[str] = None,
timestamp: Optional[str] = None,
application: Optional[str] = None,
project_globalid: Optional[str] = None,
project_name: Optional[str] = None,
) -> file:
d = dict(locals())
def _():
+3 -2
View File
@@ -185,8 +185,8 @@ class IFC_Sv_write_file(bpy.types.Operator):
def poll(cls, context):
return any("IFC" in n for n in context.space_data.edit_tree.nodes.keys())
def ensure_hirarchy(self, file):
elements_in_buildings = set()
def ensure_hirarchy(self, file: ifcopenshell.file) -> None:
elements_in_buildings: set[ifcopenshell.entity_instance] = set()
if len(file.by_type("IfcBuilding")) == 0:
my_building = ifcopenshell.api.run("root.create_entity", file, ifc_class="IfcBuilding", name="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):
if context.space_data.edit_tree and any("IFC" in n for n in context.space_data.edit_tree.nodes.keys()):
return True
return False
def draw(self, context):
ng = context.space_data.node_tree
+5 -5
View File
@@ -21,11 +21,12 @@ import ifcopenshell
import ifcopenshell.api
import ifcopenshell.util.representation
from ifcopenshell import template
from typing import Union
class SvIfcStore:
path = ""
file = None
file: Union[ifcopenshell.file, None] = None
schema = None
cache = None
cache_path = None
@@ -47,7 +48,7 @@ class SvIfcStore:
schema_identifiers = ["IFC4", "IFC2X3"]
@staticmethod
def purge():
def purge() -> None:
SvIfcStore.path = ""
SvIfcStore.file = None
SvIfcStore.schema = None
@@ -67,8 +68,7 @@ class SvIfcStore:
SvIfcStore.schema_identifiers = ["IFC4", "IFC2X3"]
@staticmethod
def create_boilerplate():
def create_boilerplate() -> ifcopenshell.file:
file = template.create(
filename="IfcSverchokDemoFile",
organization=None,
@@ -93,7 +93,7 @@ class SvIfcStore:
return SvIfcStore.file
@staticmethod
def get_file():
def get_file() -> ifcopenshell.file:
if SvIfcStore.file is None:
SvIfcStore.create_boilerplate()
return SvIfcStore.file