mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 12:07:59 +00:00
typing
This commit is contained in:
@@ -29,6 +29,7 @@ from mathutils import geometry
|
|||||||
from mathutils import Vector
|
from mathutils import Vector
|
||||||
import blenderbim.tool as tool
|
import blenderbim.tool as tool
|
||||||
from blenderbim.bim.ifc import IfcStore
|
from blenderbim.bim.ifc import IfcStore
|
||||||
|
from typing import Optional, Callable, Any
|
||||||
|
|
||||||
|
|
||||||
def draw_attributes(props, layout, copy_operator=None, popup_active_attribute=None):
|
def draw_attributes(props, layout, copy_operator=None, popup_active_attribute=None):
|
||||||
@@ -182,7 +183,7 @@ def add_attribute_description(attribute_blender, attribute_ifc=None):
|
|||||||
attribute_blender.description = description
|
attribute_blender.description = description
|
||||||
|
|
||||||
|
|
||||||
def export_attributes(props, callback=None):
|
def export_attributes(props, callback: Optional[Callable] = None) -> dict[str, Any]:
|
||||||
attributes = {}
|
attributes = {}
|
||||||
for prop in props:
|
for prop in props:
|
||||||
is_handled_by_callback = callback(attributes, prop) if callback else False
|
is_handled_by_callback = callback(attributes, prop) if callback else False
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ from blenderbim.bim.module.drawing.prop import get_diagram_scales, BOX_ALIGNMENT
|
|||||||
from lxml import etree
|
from lxml import etree
|
||||||
from mathutils import Vector, Matrix
|
from mathutils import Vector, Matrix
|
||||||
from fractions import Fraction
|
from fractions import Fraction
|
||||||
from typing import Optional, Union, Iterable
|
from typing import Optional, Union, Iterable, Any
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
@@ -342,7 +342,7 @@ class Drawing(blenderbim.core.tool.Drawing):
|
|||||||
return identification
|
return identification
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def export_text_literal_attributes(cls, obj):
|
def export_text_literal_attributes(cls, obj: bpy.types.Object) -> list[dict[str, Any]]:
|
||||||
literals = []
|
literals = []
|
||||||
for literal_props in obj.BIMTextProperties.literals:
|
for literal_props in obj.BIMTextProperties.literals:
|
||||||
literal_data = blenderbim.bim.helper.export_attributes(literal_props.attributes)
|
literal_data = blenderbim.bim.helper.export_attributes(literal_props.attributes)
|
||||||
@@ -350,7 +350,9 @@ class Drawing(blenderbim.core.tool.Drawing):
|
|||||||
return literals
|
return literals
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_annotation_context(cls, target_view, object_type=None):
|
def create_annotation_context(
|
||||||
|
cls, target_view: str, object_type: Optional[str] = None
|
||||||
|
) -> ifcopenshell.entity_instance:
|
||||||
# checking PLAN target view and annotation type that doesn't require 3d
|
# checking PLAN target view and annotation type that doesn't require 3d
|
||||||
if target_view in ("PLAN_VIEW", "REFLECTED_PLAN_VIEW") and object_type not in (
|
if target_view in ("PLAN_VIEW", "REFLECTED_PLAN_VIEW") and object_type not in (
|
||||||
"FALL",
|
"FALL",
|
||||||
@@ -596,7 +598,7 @@ class Drawing(blenderbim.core.tool.Drawing):
|
|||||||
return ifc_literal
|
return ifc_literal
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_assigned_product(cls, element):
|
def get_assigned_product(cls, element: ifcopenshell.entity_instance) -> Union[ifcopenshell.entity_instance, None]:
|
||||||
for rel in element.HasAssignments:
|
for rel in element.HasAssignments:
|
||||||
if rel.is_a("IfcRelAssignsToProduct"):
|
if rel.is_a("IfcRelAssignsToProduct"):
|
||||||
return rel.RelatingProduct
|
return rel.RelatingProduct
|
||||||
@@ -1222,7 +1224,9 @@ class Drawing(blenderbim.core.tool.Drawing):
|
|||||||
mat.translation += annotation_offset
|
mat.translation += annotation_offset
|
||||||
return mat
|
return mat
|
||||||
|
|
||||||
def clip_to_camera_boundary(mesh: bpy.types.Mesh, bounds: tuple[float, float, float, float, float, float]) -> Union[bpy.types.Mesh, None]:
|
def clip_to_camera_boundary(
|
||||||
|
mesh: bpy.types.Mesh, bounds: tuple[float, float, float, float, float, float]
|
||||||
|
) -> Union[bpy.types.Mesh, None]:
|
||||||
mesh.verts.ensure_lookup_table()
|
mesh.verts.ensure_lookup_table()
|
||||||
points = [v.co for v in mesh.verts[0:2]]
|
points = [v.co for v in mesh.verts[0:2]]
|
||||||
points = helper.clip_segment(bounds, points)
|
points = helper.clip_segment(bounds, points)
|
||||||
@@ -1461,7 +1465,7 @@ class Drawing(blenderbim.core.tool.Drawing):
|
|||||||
return bool(a_tree.overlap(b_tree))
|
return bool(a_tree.overlap(b_tree))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def replace_text_literal_variables(cls, text, product):
|
def replace_text_literal_variables(cls, text: str, product: Optional[ifcopenshell.entity_instance] = None) -> str:
|
||||||
if not product:
|
if not product:
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import bpy
|
|||||||
import bmesh
|
import bmesh
|
||||||
import shapely
|
import shapely
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
|
import ifcopenshell.util.element
|
||||||
import blenderbim.core.type
|
import blenderbim.core.type
|
||||||
import blenderbim.core.tool
|
import blenderbim.core.tool
|
||||||
import blenderbim.core.root
|
import blenderbim.core.root
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
|
import ifcopenshell.api
|
||||||
|
import ifcopenshell.util.element
|
||||||
import blenderbim.core.tool
|
import blenderbim.core.tool
|
||||||
import blenderbim.tool as tool
|
import blenderbim.tool as tool
|
||||||
from blenderbim.tool.collector import Collector as subject
|
from blenderbim.tool.collector import Collector as subject
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ import ifcopenshell.api
|
|||||||
|
|
||||||
|
|
||||||
class Usecase:
|
class Usecase:
|
||||||
def __init__(self, file, products=None, group=None):
|
def __init__(
|
||||||
|
self, file: ifcopenshell.file, products: list[ifcopenshell.entity_instance], group: ifcopenshell.entity_instance
|
||||||
|
):
|
||||||
"""Assigns products to a group
|
"""Assigns products to a group
|
||||||
|
|
||||||
If a product is already assigned to the group, it will not be assigned
|
If a product is already assigned to the group, it will not be assigned
|
||||||
@@ -48,7 +50,7 @@ class Usecase:
|
|||||||
"group": group,
|
"group": group,
|
||||||
}
|
}
|
||||||
|
|
||||||
def execute(self):
|
def execute(self) -> ifcopenshell.entity_instance:
|
||||||
if not self.settings["group"].IsGroupedBy:
|
if not self.settings["group"].IsGroupedBy:
|
||||||
return self.file.create_entity(
|
return self.file.create_entity(
|
||||||
"IfcRelAssignsToGroup",
|
"IfcRelAssignsToGroup",
|
||||||
@@ -65,3 +67,4 @@ class Usecase:
|
|||||||
related_objects.add(obj)
|
related_objects.add(obj)
|
||||||
rel.RelatedObjects = list(related_objects)
|
rel.RelatedObjects = list(related_objects)
|
||||||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel})
|
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel})
|
||||||
|
return rel
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ class GetElementTransformer(lark.Transformer):
|
|||||||
return args[1:-1].replace("\\", "")
|
return args[1:-1].replace("\\", "")
|
||||||
|
|
||||||
|
|
||||||
def format(query):
|
def format(query: str) -> str:
|
||||||
return FormatTransformer().transform(format_grammar.parse(query))
|
return FormatTransformer().transform(format_grammar.parse(query))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -117,6 +117,8 @@ reload_event = False
|
|||||||
import bpy
|
import bpy
|
||||||
from os.path import splitext
|
from os.path import splitext
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
|
import ifcopenshell.api
|
||||||
|
import ifcopenshell.util.element
|
||||||
from ifcsverchok.ifcstore import SvIfcStore
|
from ifcsverchok.ifcstore import SvIfcStore
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ import bpy
|
|||||||
from itertools import chain
|
from itertools import chain
|
||||||
|
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
|
import ifcopenshell.api
|
||||||
|
import ifcopenshell.util.element
|
||||||
import ifcsverchok.helper
|
import ifcsverchok.helper
|
||||||
from ifcsverchok.ifcstore import SvIfcStore
|
from ifcsverchok.ifcstore import SvIfcStore
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
from os.path import abspath, splitext
|
from os.path import abspath, splitext
|
||||||
import bpy
|
import bpy
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
|
import ifcopenshell.api
|
||||||
|
import ifcopenshell.util.element
|
||||||
import ifcsverchok.helper
|
import ifcsverchok.helper
|
||||||
from ifcsverchok.ifcstore import SvIfcStore
|
from ifcsverchok.ifcstore import SvIfcStore
|
||||||
from bpy.props import StringProperty, BoolProperty
|
from bpy.props import StringProperty, BoolProperty
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import uuid
|
|||||||
import pytest
|
import pytest
|
||||||
import functools
|
import functools
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
|
import ifcopenshell.api
|
||||||
import ifctester
|
import ifctester
|
||||||
import test_facet
|
import test_facet
|
||||||
import test_ids
|
import test_ids
|
||||||
|
|||||||
Reference in New Issue
Block a user