mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +00:00
use tool module instead of local function to activate object
This commit is contained in:
@@ -37,12 +37,6 @@ from . import prop
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
||||||
def select_and_activate_single_object(context, obj):
|
|
||||||
bpy.ops.object.select_all(action="DESELECT")
|
|
||||||
context.view_layer.objects.active = obj
|
|
||||||
obj.select_set(True)
|
|
||||||
|
|
||||||
|
|
||||||
class AddEmptyType(bpy.types.Operator, AddObjectHelper):
|
class AddEmptyType(bpy.types.Operator, AddObjectHelper):
|
||||||
bl_idname = "bim.add_empty_type"
|
bl_idname = "bim.add_empty_type"
|
||||||
bl_label = "Add Empty Type"
|
bl_label = "Add Empty Type"
|
||||||
@@ -52,7 +46,7 @@ class AddEmptyType(bpy.types.Operator, AddObjectHelper):
|
|||||||
obj = bpy.data.objects.new("TYPEX", None)
|
obj = bpy.data.objects.new("TYPEX", None)
|
||||||
context.scene.collection.objects.link(obj)
|
context.scene.collection.objects.link(obj)
|
||||||
context.scene.BIMRootProperties.ifc_product = "IfcElementType"
|
context.scene.BIMRootProperties.ifc_product = "IfcElementType"
|
||||||
select_and_activate_single_object(context, obj)
|
tool.Blender.select_and_activate_single_object(context, obj)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
@@ -97,7 +91,7 @@ class AddConstrTypeInstance(bpy.types.Operator):
|
|||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
elif material and material.is_a("IfcMaterialLayerSet"):
|
elif material and material.is_a("IfcMaterialLayerSet"):
|
||||||
if self.generate_layered_element(ifc_class, relating_type):
|
if self.generate_layered_element(ifc_class, relating_type):
|
||||||
select_and_activate_single_object(context, context.selected_objects[-1])
|
tool.Blender.select_and_activate_single_object(context, context.selected_objects[-1])
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
if relating_type.is_a("IfcFlowSegmentType") and not relating_type.RepresentationMaps:
|
if relating_type.is_a("IfcFlowSegmentType") and not relating_type.RepresentationMaps:
|
||||||
if mep.MepGenerator(relating_type).generate():
|
if mep.MepGenerator(relating_type).generate():
|
||||||
@@ -179,7 +173,7 @@ class AddConstrTypeInstance(bpy.types.Operator):
|
|||||||
if ifc_class == "IfcDoorType" and len(context.selected_objects) >= 1:
|
if ifc_class == "IfcDoorType" and len(context.selected_objects) >= 1:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
select_and_activate_single_object(context, obj)
|
tool.Blender.select_and_activate_single_object(context, obj)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
Reference in New Issue
Block a user