mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
Fix regression where adding a new occurrence should not change your active context back to body if you've switched it.
This commit is contained in:
@@ -326,6 +326,12 @@ class AddConstrTypeInstance(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
instance_class = ifcopenshell.util.type.get_applicable_entities(ifc_class, tool.Ifc.get().schema)[0]
|
instance_class = ifcopenshell.util.type.get_applicable_entities(ifc_class, tool.Ifc.get().schema)[0]
|
||||||
material = ifcopenshell.util.element.get_material(relating_type)
|
material = ifcopenshell.util.element.get_material(relating_type)
|
||||||
|
|
||||||
|
existing_context = None
|
||||||
|
for existing_occurrence in ifcopenshell.util.element.get_types(relating_type):
|
||||||
|
if existing_obj := tool.Ifc.get_object(existing_occurrence):
|
||||||
|
existing_context = tool.Geometry.get_active_representation_context(existing_obj)
|
||||||
|
break
|
||||||
|
|
||||||
if material and material.is_a("IfcMaterialProfileSet"):
|
if material and material.is_a("IfcMaterialProfileSet"):
|
||||||
if obj := profile.DumbProfileGenerator(relating_type).generate():
|
if obj := profile.DumbProfileGenerator(relating_type).generate():
|
||||||
tool.Blender.select_and_activate_single_object(context, obj)
|
tool.Blender.select_and_activate_single_object(context, obj)
|
||||||
@@ -415,7 +421,10 @@ class AddConstrTypeInstance(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
bonsai.core.type.assign_type(tool.Ifc, tool.Type, element=element, type=relating_type)
|
bonsai.core.type.assign_type(tool.Ifc, tool.Type, element=element, type=relating_type)
|
||||||
|
|
||||||
representation = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
|
if existing_context:
|
||||||
|
representation = ifcopenshell.util.representation.get_representation(element, existing_context)
|
||||||
|
else:
|
||||||
|
representation = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
|
||||||
if not representation and element.Representation:
|
if not representation and element.Representation:
|
||||||
representation = element.Representation.Representations[0]
|
representation = element.Representation.Representations[0]
|
||||||
|
|
||||||
|
|||||||
@@ -733,8 +733,9 @@ def the_object_name_has_a_representation_type_of_context(name, type, context):
|
|||||||
element = ifc.by_id(the_object_name_exists(name).BIMObjectProperties.ifc_definition_id)
|
element = ifc.by_id(the_object_name_exists(name).BIMObjectProperties.ifc_definition_id)
|
||||||
context, subcontext, target_view = context.split("/")
|
context, subcontext, target_view = context.split("/")
|
||||||
rep = ifcopenshell.util.representation.get_representation(element, context, subcontext or None, target_view or None)
|
rep = ifcopenshell.util.representation.get_representation(element, context, subcontext or None, target_view or None)
|
||||||
|
rep =ifcopenshell.util.representation.resolve_representation(rep)
|
||||||
assert rep
|
assert rep
|
||||||
assert rep.RepresentationType == type
|
assert rep.RepresentationType == type, f"The object {name} does not have a {type} representation"
|
||||||
|
|
||||||
|
|
||||||
@given(parsers.parse('the object "{name}" data is a "{type}" representation of "{context}"'))
|
@given(parsers.parse('the object "{name}" data is a "{type}" representation of "{context}"'))
|
||||||
@@ -744,7 +745,7 @@ def the_object_name_data_is_a_type_representation_of_context(name, type, context
|
|||||||
context, subcontext, target_view = context.split("/")
|
context, subcontext, target_view = context.split("/")
|
||||||
rep = ifc.by_id(the_object_name_exists(name).data.BIMMeshProperties.ifc_definition_id)
|
rep = ifc.by_id(the_object_name_exists(name).data.BIMMeshProperties.ifc_definition_id)
|
||||||
assert rep
|
assert rep
|
||||||
assert rep.RepresentationType == type
|
assert rep.RepresentationType == type, f"The object {name} is not a {type} representation"
|
||||||
assert rep.ContextOfItems.ContextType == context
|
assert rep.ContextOfItems.ContextType == context
|
||||||
assert rep.ContextOfItems.ContextIdentifier == subcontext
|
assert rep.ContextOfItems.ContextIdentifier == subcontext
|
||||||
assert rep.ContextOfItems.TargetView == target_view
|
assert rep.ContextOfItems.TargetView == target_view
|
||||||
|
|||||||
Reference in New Issue
Block a user