mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-17 10:59:17 +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 . import prop
|
||||
import json
|
||||
from typing import Any, Union, Optional
|
||||
from typing import Any, Union, Optional, assert_never
|
||||
|
||||
|
||||
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":
|
||||
assigned_material = ifcopenshell.util.element.get_material(element, should_inherit=False)
|
||||
assert assigned_material # Type checker.
|
||||
# 1) 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
|
||||
# Material usages just inherit the style from the type material, so can't override it.
|
||||
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.
|
||||
elif material_type.endswith("Usage") or material_type.endswith("Set"):
|
||||
elif material_type in ("IfcMaterialConstituentSet", "IfcMaterialLayerSet", "IfcMaterialProfileSet"):
|
||||
return
|
||||
elif material_type == "IfcMaterialList":
|
||||
assert False, "Current assign_material implementation requires 'material' argument for IfcMaterialList."
|
||||
else:
|
||||
assert_never(material_type)
|
||||
|
||||
for element in elements[:]:
|
||||
if element.is_a("IfcElementType"):
|
||||
|
||||
@@ -17,17 +17,22 @@
|
||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import bpy
|
||||
import ifcopenshell.file
|
||||
import blenderbim.bim.handler
|
||||
import blenderbim.tool as tool
|
||||
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":
|
||||
element = settings["product"]
|
||||
elif usecase_path == "style.edit_presentation_style":
|
||||
element = settings["style"]
|
||||
else:
|
||||
raise Exception(f"Unsupported usecase: '{usecase_path}'.")
|
||||
|
||||
element: ifcopenshell.entity_instance
|
||||
if "Name" not in settings["attributes"]:
|
||||
return
|
||||
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]:
|
||||
"""Gets element shape aspects
|
||||
"""Get element's shape aspects.
|
||||
|
||||
:param element: The element to get the shape aspects of.
|
||||
:type element: ifcopenshell.entity_instance
|
||||
:param element: IfcProduct or IfcTypeProduct.
|
||||
:return: The associated shape aspects of the element.
|
||||
:rtype: list[ifcopenshell.entity_instance]
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user