mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
typing
This commit is contained in:
@@ -36,7 +36,7 @@ import bmesh
|
||||
import mathutils.geometry
|
||||
from mathutils import Vector, Matrix, geometry
|
||||
import itertools
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Union
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from bonsai.bim.module.cad.prop import BIMCadProperties
|
||||
@@ -170,7 +170,9 @@ class Cad:
|
||||
return geometry.intersect_line_plane(v1, v2, plane_co, plane_no)
|
||||
|
||||
@classmethod
|
||||
def intersect_edges(cls, edge1, edge2):
|
||||
def intersect_edges(
|
||||
cls, edge1: tuple[Vector, Vector], edge2: tuple[Vector, Vector]
|
||||
) -> Union[tuple[Vector, Vector], None]:
|
||||
"""
|
||||
> takes 2 tuples, each tuple contains 2 vectors
|
||||
- prepares input for sending to intersect_line_line
|
||||
|
||||
@@ -17,13 +17,17 @@
|
||||
# along with IfcSverchok. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import bpy
|
||||
import ifcopenshell
|
||||
from sverchok.data_structure import zip_long_repeat
|
||||
from typing import Any
|
||||
|
||||
ifc_files = {}
|
||||
ifc_files: dict[str, ifcopenshell.file] = {}
|
||||
|
||||
|
||||
class SvIfcCore:
|
||||
def process(self):
|
||||
sv_input_names: list[str]
|
||||
|
||||
def process(self) -> None:
|
||||
sv_inputs_nested = []
|
||||
for name in self.sv_input_names:
|
||||
sv_inputs_nested.append(self.inputs[name].sv_get())
|
||||
@@ -31,3 +35,6 @@ class SvIfcCore:
|
||||
for sv_input in zip_long_repeat(*sv_input_nested):
|
||||
sv_input = list(sv_input)
|
||||
self.process_ifc(*sv_input)
|
||||
|
||||
def process_ifc(self, *args: Any, **kwargs: Any) -> None:
|
||||
raise NotImplementedError
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
import bpy
|
||||
from mathutils import Matrix
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcsverchok.helper
|
||||
from ifcsverchok.ifcstore import SvIfcStore
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ class SvIfcCreateFileRefresh(bpy.types.Operator):
|
||||
has_baked: bpy.props.BoolProperty(name="Has Baked", default=False)
|
||||
|
||||
def execute(self, context):
|
||||
node: SvIfcCreateFile
|
||||
node = bpy.data.node_groups[self.tree_name].nodes[self.node_name]
|
||||
node.process()
|
||||
return {"FINISHED"}
|
||||
@@ -55,7 +56,7 @@ class SvIfcCreateFile(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.S
|
||||
self.sv_input_names = ["schema"]
|
||||
super().process()
|
||||
|
||||
def process_ifc(self, schema):
|
||||
def process_ifc(self, schema: str) -> None:
|
||||
guid = ifcopenshell.guid.new()
|
||||
ifcsverchok.helper.ifc_files[guid] = ifcopenshell.file(schema=schema)
|
||||
self.outputs["file"].sv_set([[ifcsverchok.helper.ifc_files[guid]]])
|
||||
|
||||
@@ -52,7 +52,7 @@ class SvIfcCreateProject(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helpe
|
||||
project_name = self.inputs["project_name"].sv_get()[0][0]
|
||||
self.process_ifc(file, project_name)
|
||||
|
||||
def process_ifc(self, file, project_name):
|
||||
def process_ifc(self, file: ifcopenshell.file, project_name: str) -> None:
|
||||
# create project
|
||||
project = ifcopenshell.api.run("root.create_entity", file, ifc_class="IfcProject", name=str(project_name))
|
||||
lengthunit = ifcopenshell.api.run("unit.add_si_unit", file, unit_type="LENGTHUNIT")
|
||||
|
||||
Reference in New Issue
Block a user