mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-29 11:46:33 +00:00
typing
This commit is contained in:
@@ -40,7 +40,7 @@ from mathutils import Vector, Matrix
|
|||||||
from bpy_extras.object_utils import AddObjectHelper
|
from bpy_extras.object_utils import AddObjectHelper
|
||||||
from . import prop
|
from . import prop
|
||||||
import json
|
import json
|
||||||
from typing import Any, Union, Optional
|
from typing import Any, Union, Optional, assert_never
|
||||||
|
|
||||||
|
|
||||||
class EnableAddType(bpy.types.Operator, tool.Ifc.Operator):
|
class EnableAddType(bpy.types.Operator, tool.Ifc.Operator):
|
||||||
@@ -524,13 +524,17 @@ def ensure_material_assigned(usecase_path: str, ifc_file: ifcopenshell.file, set
|
|||||||
if material_type == "IfcMaterial":
|
if material_type == "IfcMaterial":
|
||||||
assigned_material = ifcopenshell.util.element.get_material(element, should_inherit=False)
|
assigned_material = ifcopenshell.util.element.get_material(element, should_inherit=False)
|
||||||
assert assigned_material # Type checker.
|
assert assigned_material # Type checker.
|
||||||
# 1) Material usages just inherit the style from the type material, so can't override it.
|
# Material usages just inherit the style from the type material, so can't override it.
|
||||||
# 2) If type is Set and no material argument were provided, then Set was just created
|
elif material_type in ("IfcMaterialLayerSetUsage", "IfcMaterialProfileSetUsage"):
|
||||||
|
return
|
||||||
|
# If type is Set and no material argument were provided, then Set was just created
|
||||||
# and not yet have any IfcMaterials.
|
# and not yet have any IfcMaterials.
|
||||||
elif material_type.endswith("Usage") or material_type.endswith("Set"):
|
elif material_type in ("IfcMaterialConstituentSet", "IfcMaterialLayerSet", "IfcMaterialProfileSet"):
|
||||||
return
|
return
|
||||||
elif material_type == "IfcMaterialList":
|
elif material_type == "IfcMaterialList":
|
||||||
assert False, "Current assign_material implementation requires 'material' argument for IfcMaterialList."
|
assert False, "Current assign_material implementation requires 'material' argument for IfcMaterialList."
|
||||||
|
else:
|
||||||
|
assert_never(material_type)
|
||||||
|
|
||||||
for element in elements[:]:
|
for element in elements[:]:
|
||||||
if element.is_a("IfcElementType"):
|
if element.is_a("IfcElementType"):
|
||||||
|
|||||||
@@ -17,17 +17,22 @@
|
|||||||
# 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/>.
|
||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
|
import ifcopenshell.file
|
||||||
import blenderbim.bim.handler
|
import blenderbim.bim.handler
|
||||||
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 Any
|
||||||
|
|
||||||
|
|
||||||
def sync_name(usecase_path, ifc_file, settings):
|
def sync_name(usecase_path: str, ifc_file: ifcopenshell.file, settings: dict[str, Any]) -> None:
|
||||||
if usecase_path == "attribute.edit_attributes":
|
if usecase_path == "attribute.edit_attributes":
|
||||||
element = settings["product"]
|
element = settings["product"]
|
||||||
elif usecase_path == "style.edit_presentation_style":
|
elif usecase_path == "style.edit_presentation_style":
|
||||||
element = settings["style"]
|
element = settings["style"]
|
||||||
|
else:
|
||||||
|
raise Exception(f"Unsupported usecase: '{usecase_path}'.")
|
||||||
|
|
||||||
|
element: ifcopenshell.entity_instance
|
||||||
if "Name" not in settings["attributes"]:
|
if "Name" not in settings["attributes"]:
|
||||||
return
|
return
|
||||||
obj = tool.Ifc.get_object(element)
|
obj = tool.Ifc.get_object(element)
|
||||||
|
|||||||
@@ -512,12 +512,10 @@ def get_types(type: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_in
|
|||||||
|
|
||||||
|
|
||||||
def get_shape_aspects(element: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_instance]:
|
def get_shape_aspects(element: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_instance]:
|
||||||
"""Gets element shape aspects
|
"""Get element's shape aspects.
|
||||||
|
|
||||||
:param element: The element to get the shape aspects of.
|
:param element: IfcProduct or IfcTypeProduct.
|
||||||
:type element: ifcopenshell.entity_instance
|
|
||||||
:return: The associated shape aspects of the element.
|
:return: The associated shape aspects of the element.
|
||||||
:rtype: list[ifcopenshell.entity_instance]
|
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user