mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-28 15:53:00 +00:00
typing
This commit is contained in:
@@ -1070,11 +1070,20 @@ class OverrideDuplicateMove(bpy.types.Operator):
|
|||||||
tool.Root.reload_item_decorator()
|
tool.Root.reload_item_decorator()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def process_arrays(self, context):
|
def process_arrays(
|
||||||
|
self, context: bpy.types.Context
|
||||||
|
) -> tuple[dict[bpy.types.Object, Any], set[ifcopenshell.entity_instance]]:
|
||||||
|
""" "Process arrays for currently selected objects.
|
||||||
|
|
||||||
|
:return: A tuple of two elements:\n
|
||||||
|
- dictionary of objects and their array data. Those objects are safe to duplicate and regenerate arrays using the data.\n
|
||||||
|
- set of array children objects. Those objects can be ignored during duplication, they will be recreated automatically
|
||||||
|
when arrays are regenerated for objects from the dictionary.
|
||||||
|
"""
|
||||||
selected_objects = set(context.selected_objects)
|
selected_objects = set(context.selected_objects)
|
||||||
array_parents = set()
|
array_parents = set()
|
||||||
arrays_to_create = dict()
|
arrays_to_create: dict[bpy.types.Object, Any] = dict()
|
||||||
array_children = set() # will be ignored during the duplication
|
array_children: set[ifcopenshell.entity_instance] = set() # will be ignored during the duplication
|
||||||
|
|
||||||
for obj in context.selected_objects:
|
for obj in context.selected_objects:
|
||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ def add_pset(
|
|||||||
|
|
||||||
def enable_pset_editing(
|
def enable_pset_editing(
|
||||||
pset_tool: tool.Pset,
|
pset_tool: tool.Pset,
|
||||||
pset: ifcopenshell.entity_instance,
|
pset: Union[ifcopenshell.entity_instance, None],
|
||||||
pset_name: str,
|
pset_name: str,
|
||||||
pset_type: tool.Pset.PSET_TYPE,
|
pset_type: tool.Pset.PSET_TYPE,
|
||||||
obj_name: str,
|
obj_name: str,
|
||||||
|
|||||||
@@ -675,13 +675,14 @@ class Model(bonsai.core.tool.Model):
|
|||||||
|
|
||||||
# remove constraints
|
# remove constraints
|
||||||
obj = tool.Ifc.get_object(element)
|
obj = tool.Ifc.get_object(element)
|
||||||
|
assert isinstance(obj, bpy.types.Object)
|
||||||
if not array_pset_data: # skip array parents
|
if not array_pset_data: # skip array parents
|
||||||
constraint = next((c for c in obj.constraints if c.type == "CHILD_OF"), None)
|
constraint = next((c for c in obj.constraints if c.type == "CHILD_OF"), None)
|
||||||
if constraint:
|
if constraint:
|
||||||
matrix = obj.matrix_world.copy()
|
matrix = obj.matrix_world.copy()
|
||||||
obj.constraints.remove(constraint)
|
obj.constraints.remove(constraint)
|
||||||
# keep the matrix before the constraint
|
# Keep the matrix before removing the constraint,
|
||||||
# otherwise object will jump to some previous position
|
# otherwise object will jump to some previous position.
|
||||||
obj.matrix_world = matrix
|
obj.matrix_world = matrix
|
||||||
tool.Blender.lock_transform(obj, False)
|
tool.Blender.lock_transform(obj, False)
|
||||||
|
|
||||||
|
|||||||
@@ -410,7 +410,12 @@ class Usecase:
|
|||||||
|
|
||||||
raise TypeError(f"'{self.settings['pset']}' is not a valid pset")
|
raise TypeError(f"'{self.settings['pset']}' is not a valid pset")
|
||||||
|
|
||||||
def get_primary_measure_type(self, name, old_value=None, new_value=None):
|
def get_primary_measure_type(
|
||||||
|
self,
|
||||||
|
name: str,
|
||||||
|
old_value: Optional[ifcopenshell.entity_instance] = None,
|
||||||
|
new_value: Optional[Union[ifcopenshell.entity_instance, str, float, bool, int]] = None,
|
||||||
|
) -> Union[str, None]:
|
||||||
if old_value:
|
if old_value:
|
||||||
return old_value.is_a()
|
return old_value.is_a()
|
||||||
if self.pset_template:
|
if self.pset_template:
|
||||||
@@ -418,7 +423,7 @@ class Usecase:
|
|||||||
if prop_template.Name != name:
|
if prop_template.Name != name:
|
||||||
continue
|
continue
|
||||||
return prop_template.PrimaryMeasureType or "IfcLabel"
|
return prop_template.PrimaryMeasureType or "IfcLabel"
|
||||||
if new_value and hasattr(new_value, "is_a"):
|
if isinstance(new_value, ifcopenshell.entity_instance):
|
||||||
return new_value.is_a()
|
return new_value.is_a()
|
||||||
elif new_value is not None:
|
elif new_value is not None:
|
||||||
if isinstance(new_value, str):
|
if isinstance(new_value, str):
|
||||||
|
|||||||
Reference in New Issue
Block a user