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