mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 14:31:39 +00:00
typing
This commit is contained in:
@@ -16,14 +16,17 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import bpy
|
import bpy
|
||||||
import bmesh
|
import bmesh
|
||||||
import ifcopenshell.geom
|
import ifcopenshell.geom
|
||||||
import ifcopenshell.util.element
|
import ifcopenshell.util.element
|
||||||
|
import ifcopenshell.util.unit
|
||||||
import blenderbim.core.tool
|
import blenderbim.core.tool
|
||||||
import blenderbim.tool as tool
|
import blenderbim.tool as tool
|
||||||
|
import blenderbim.bim.import_ifc
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import numpy.typing as npt
|
import numpy.typing as npt
|
||||||
from mathutils import Vector, Matrix
|
from mathutils import Vector, Matrix
|
||||||
@@ -42,14 +45,14 @@ OBJECT_DATA_TYPE = Union[bpy.types.Mesh, bpy.types.Curve]
|
|||||||
|
|
||||||
class Loader(blenderbim.core.tool.Loader):
|
class Loader(blenderbim.core.tool.Loader):
|
||||||
unit_scale: float = 1
|
unit_scale: float = 1
|
||||||
settings = None
|
settings: blenderbim.bim.import_ifc.IfcImportSettings = None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def set_unit_scale(cls, unit_scale: float) -> None:
|
def set_unit_scale(cls, unit_scale: float) -> None:
|
||||||
cls.unit_scale = unit_scale
|
cls.unit_scale = unit_scale
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def set_settings(cls, settings) -> None:
|
def set_settings(cls, settings: blenderbim.bim.import_ifc.IfcImportSettings) -> None:
|
||||||
cls.settings = settings
|
cls.settings = settings
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -469,7 +472,7 @@ class Loader(blenderbim.core.tool.Loader):
|
|||||||
blender_material.node_tree.links.new(coord.outputs["UV"], node.inputs["Vector"])
|
blender_material.node_tree.links.new(coord.outputs["UV"], node.inputs["Vector"])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load_indexed_texture_map(cls, coordinates, mesh):
|
def load_indexed_texture_map(cls, coordinates: ifcopenshell.entity_instance, mesh: bpy.types.Mesh) -> None:
|
||||||
# Get a BMesh representation
|
# Get a BMesh representation
|
||||||
bm = bmesh.new()
|
bm = bmesh.new()
|
||||||
bm.from_mesh(mesh)
|
bm.from_mesh(mesh)
|
||||||
|
|||||||
@@ -18,13 +18,22 @@
|
|||||||
|
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional, Literal
|
||||||
|
|
||||||
|
|
||||||
|
SURFACE_STYLE_TYPES = Literal[
|
||||||
|
"IfcExternallyDefinedSurfaceStyle",
|
||||||
|
"IfcSurfaceStyleLighting",
|
||||||
|
"IfcSurfaceStyleRefraction",
|
||||||
|
"IfcSurfaceStyleShading",
|
||||||
|
"IfcSurfaceStyleWithTextures",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def add_surface_style(
|
def add_surface_style(
|
||||||
file: ifcopenshell.file,
|
file: ifcopenshell.file,
|
||||||
style: ifcopenshell.entity_instance,
|
style: ifcopenshell.entity_instance,
|
||||||
ifc_class: str = "IfcSurfaceStyleShading",
|
ifc_class: SURFACE_STYLE_TYPES = "IfcSurfaceStyleShading",
|
||||||
attributes: Optional[dict[str, Any]] = None,
|
attributes: Optional[dict[str, Any]] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Adds a new presentation item to a surface style
|
"""Adds a new presentation item to a surface style
|
||||||
|
|||||||
@@ -1076,13 +1076,13 @@ class ShapeBuilder:
|
|||||||
)
|
)
|
||||||
return points, segments, transition_arc
|
return points, segments, transition_arc
|
||||||
|
|
||||||
def polygonal_face_set(self, points: list[Vector], faces: list[[list[int]]]) -> ifcopenshell.entity_instance:
|
def polygonal_face_set(self, points: list[Vector], faces: list[list[int]]) -> ifcopenshell.entity_instance:
|
||||||
"""
|
"""
|
||||||
> `points` - list of points
|
Generate an IfcPolygonalFaceSet.
|
||||||
|
|
||||||
> `faces` - list of faces consisted of point indices (points indices starting from 0)
|
:param points: rectangle size, could be either 2d or 3d, defaults to `(1,1)`
|
||||||
|
:param faces: list of faces consisted of point indices (points indices starting from 0)
|
||||||
< IfcPolygonalFaceSet
|
:return: IfcPolygonalFaceSet
|
||||||
"""
|
"""
|
||||||
|
|
||||||
ifc_points = self.file.createIfcCartesianPointList3D(points)
|
ifc_points = self.file.createIfcCartesianPointList3D(points)
|
||||||
|
|||||||
Reference in New Issue
Block a user