mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
typing
This commit is contained in:
@@ -294,20 +294,20 @@ class ObjectMaterialData:
|
||||
return sum([l.LayerThickness for l in layers or []])
|
||||
|
||||
@classmethod
|
||||
def set_item_name(cls):
|
||||
results = []
|
||||
def set_item_name(cls) -> Union[str, None]:
|
||||
if cls.material:
|
||||
if "Constituent" in cls.material.is_a():
|
||||
material_class = cls.material.is_a()
|
||||
if "Constituent" in material_class:
|
||||
return "constituent"
|
||||
elif "Layer" in cls.material.is_a():
|
||||
elif "Layer" in material_class:
|
||||
return "layer"
|
||||
elif "Profile" in cls.material.is_a():
|
||||
elif "Profile" in material_class:
|
||||
return "profile"
|
||||
elif "List" in cls.material.is_a():
|
||||
elif "List" in material_class:
|
||||
return "list_item"
|
||||
|
||||
@classmethod
|
||||
def material_name(cls):
|
||||
def material_name(cls) -> Union[str, None]:
|
||||
material = cls.material
|
||||
if material:
|
||||
return getattr(material, "Name", None) or "Unnamed"
|
||||
|
||||
@@ -27,6 +27,7 @@ import ifcopenshell.util.representation
|
||||
import ifcopenshell.util.unit
|
||||
from pathlib import Path
|
||||
from mathutils import Vector
|
||||
from typing import Any, Union
|
||||
|
||||
|
||||
# TODO: is this still relevant or can it be deleted?
|
||||
@@ -717,6 +718,8 @@ class EditSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_label = "Edit Surface Style"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
surface_style: Union[ifcopenshell.entity_instance, None]
|
||||
|
||||
def _execute(self, context):
|
||||
self.props = bpy.context.scene.BIMStylesProperties
|
||||
self.style = tool.Ifc.get().by_id(self.props.is_editing_style)
|
||||
@@ -741,6 +744,8 @@ class EditSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
def edit_existing_style(self):
|
||||
material = tool.Ifc.get_object(self.style)
|
||||
assert self.surface_style
|
||||
|
||||
if self.surface_style.is_a() == "IfcSurfaceStyleShading":
|
||||
ifcopenshell.api.run(
|
||||
"style.edit_surface_style",
|
||||
@@ -876,7 +881,7 @@ class EditSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
# TODO: support RepeatS/RepeatT params in UI:
|
||||
# add it to prop.Texture and Style.get_texture_style_data_from_props
|
||||
def get_texture_attributes(self):
|
||||
def get_texture_attributes(self) -> list[dict[str, Any]]:
|
||||
textures = []
|
||||
for texture in self.props.textures:
|
||||
texture_data = {
|
||||
|
||||
@@ -577,7 +577,11 @@ class Cost(bonsai.core.tool.Cost):
|
||||
|
||||
@classmethod
|
||||
def create_new_cost_item_li(
|
||||
cls, props_collection, cost_item: ifcopenshell.entity_instance, level_index: int, type: str = "cost_rate"
|
||||
cls,
|
||||
props_collection,
|
||||
cost_item: ifcopenshell.entity_instance,
|
||||
level_index: int,
|
||||
type: Literal["cost", "cost_rate"] = "cost_rate",
|
||||
) -> None:
|
||||
new = props_collection.add()
|
||||
new.ifc_definition_id = cost_item.id()
|
||||
|
||||
@@ -108,7 +108,10 @@ class Loader(bonsai.core.tool.Loader):
|
||||
mesh.BIMMeshProperties.ifc_definition_id = int(geometry.id.split("-")[0])
|
||||
|
||||
@classmethod
|
||||
def create_surface_style_shading(cls, blender_material, surface_style):
|
||||
def create_surface_style_shading(
|
||||
cls, blender_material: bpy.types.Material, surface_style: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
# Shading style is simple and use no node graph.
|
||||
surface_style = cls.surface_style_to_dict(surface_style)
|
||||
alpha = 1.0
|
||||
# Transparency was added in IFC4
|
||||
@@ -118,7 +121,7 @@ class Loader(bonsai.core.tool.Loader):
|
||||
blender_material.use_nodes = False
|
||||
|
||||
@classmethod
|
||||
def restart_material_node_tree(cls, blender_material):
|
||||
def restart_material_node_tree(cls, blender_material: bpy.types.Material) -> None:
|
||||
nodes = blender_material.node_tree.nodes
|
||||
links = blender_material.node_tree.links
|
||||
for n in nodes[:]:
|
||||
@@ -286,7 +289,7 @@ class Loader(bonsai.core.tool.Loader):
|
||||
|
||||
image_url = None
|
||||
|
||||
def get_image():
|
||||
def get_image() -> Union[bpy.types.Image, None]:
|
||||
# TODO: orphaned textures after shader recreated?
|
||||
if texture["type"] == "IfcImageTexture":
|
||||
original_image_url = texture["URLReference"]
|
||||
|
||||
@@ -21,6 +21,7 @@ import ifcopenshell.api.cost
|
||||
import ifcopenshell.util.cost
|
||||
import ifcopenshell.util.unit
|
||||
import ifcopenshell.util.element
|
||||
from typing import Any
|
||||
|
||||
|
||||
def edit_cost_value_formula(file: ifcopenshell.file, cost_value: ifcopenshell.entity_instance, formula: str) -> None:
|
||||
@@ -57,6 +58,9 @@ def edit_cost_value_formula(file: ifcopenshell.file, cost_value: ifcopenshell.en
|
||||
|
||||
|
||||
class Usecase:
|
||||
file: ifcopenshell.file
|
||||
settings: dict[str, Any]
|
||||
|
||||
def execute(self):
|
||||
try:
|
||||
data = ifcopenshell.util.cost.unserialise_cost_value(self.settings["formula"], self.settings["cost_value"])
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
from __future__ import annotations
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
from typing import TYPE_CHECKING, Optional, Any
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import bpy
|
||||
@@ -67,6 +67,9 @@ def add_surface_textures(
|
||||
|
||||
|
||||
class Usecase:
|
||||
file: ifcopenshell.file
|
||||
settings: dict[str, Any]
|
||||
|
||||
def execute(self):
|
||||
if self.file.schema == "IFC2X3":
|
||||
# TODO: research how compatible IFC2X3 and IFC4 textures are
|
||||
|
||||
Reference in New Issue
Block a user