mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 02:47:48 +00:00
Railing/roof/stair/window now use default collection. Continue removing old "active collection" code.
This commit is contained in:
@@ -299,8 +299,6 @@ class BIM_OT_add_railing(bpy.types.Operator, tool.Ifc.Operator):
|
||||
mesh = bpy.data.meshes.new("IfcRailing")
|
||||
obj = bpy.data.objects.new("IfcRailing", mesh)
|
||||
obj.location = spawn_location
|
||||
collection = context.view_layer.active_layer_collection.collection
|
||||
collection.objects.link(obj)
|
||||
|
||||
body_context = ifcopenshell.util.representation.get_context(ifc_file, "Model", "Body", "MODEL_VIEW")
|
||||
blenderbim.core.root.assign_class(
|
||||
|
||||
@@ -515,8 +515,6 @@ class BIM_OT_add_roof(bpy.types.Operator, tool.Ifc.Operator):
|
||||
mesh = bpy.data.meshes.new("IfcRoof")
|
||||
obj = bpy.data.objects.new("IfcRoof", mesh)
|
||||
obj.location = spawn_location
|
||||
collection = context.view_layer.active_layer_collection.collection
|
||||
collection.objects.link(obj)
|
||||
|
||||
body_context = ifcopenshell.util.representation.get_context(ifc_file, "Model", "Body", "MODEL_VIEW")
|
||||
blenderbim.core.root.assign_class(
|
||||
|
||||
@@ -218,8 +218,6 @@ class BIM_OT_add_clever_stair(bpy.types.Operator, tool.Ifc.Operator):
|
||||
mesh = bpy.data.meshes.new("IfcStairFlight")
|
||||
obj = bpy.data.objects.new("StairFlight", mesh)
|
||||
obj.location = spawn_location
|
||||
collection = context.view_layer.active_layer_collection.collection
|
||||
collection.objects.link(obj)
|
||||
|
||||
element = blenderbim.core.root.assign_class(
|
||||
tool.Ifc,
|
||||
|
||||
@@ -402,8 +402,6 @@ class BIM_OT_add_window(bpy.types.Operator, tool.Ifc.Operator):
|
||||
mesh = bpy.data.meshes.new("IfcWindow")
|
||||
obj = bpy.data.objects.new("IfcWindow", mesh)
|
||||
obj.location = spawn_location
|
||||
collection = context.view_layer.active_layer_collection.collection
|
||||
collection.objects.link(obj)
|
||||
|
||||
element = blenderbim.core.root.assign_class(
|
||||
tool.Ifc, tool.Collector, tool.Root, obj=obj, ifc_class="IfcWindow", should_add_representation=False
|
||||
|
||||
@@ -602,7 +602,6 @@ class Project:
|
||||
def run_owner_set_user(cls, user=None): pass
|
||||
def run_root_assign_class(cls, obj=None, ifc_class=None, predefined_type=None, should_add_representation=True, context=None, ifc_representation_class=None): pass
|
||||
def run_unit_assign_scene_units(cls): pass
|
||||
def set_active_spatial_element(cls, obj): pass
|
||||
def set_context(cls, context): pass
|
||||
def set_default_context(cls): pass
|
||||
def set_default_modeling_dimensions(cls): pass
|
||||
|
||||
@@ -120,22 +120,6 @@ class Project(blenderbim.core.tool.Project):
|
||||
def run_unit_assign_scene_units(cls):
|
||||
return blenderbim.core.unit.assign_scene_units(tool.Ifc, tool.Unit)
|
||||
|
||||
@classmethod
|
||||
def set_active_spatial_element(cls, obj):
|
||||
collection = obj.BIMObjectProperties.collection
|
||||
queue = [bpy.context.view_layer.layer_collection]
|
||||
layer_collection = None
|
||||
|
||||
while queue:
|
||||
layer = queue.pop()
|
||||
if layer.collection == collection:
|
||||
layer_collection = layer
|
||||
break
|
||||
queue.extend(list(layer.children))
|
||||
|
||||
if layer_collection:
|
||||
bpy.context.view_layer.active_layer_collection = layer_collection
|
||||
|
||||
@classmethod
|
||||
def set_context(cls, context):
|
||||
blenderbim.bim.handler.refresh_ui_data()
|
||||
|
||||
@@ -92,7 +92,6 @@ class TestCreateProject:
|
||||
project.run_aggregate_assign_object(relating_obj="building", related_obj="storey").should_be_called()
|
||||
|
||||
project.set_context("body").should_be_called()
|
||||
project.set_active_spatial_element("storey").should_be_called()
|
||||
|
||||
project.load_default_thumbnails().should_be_called()
|
||||
project.set_default_context().should_be_called()
|
||||
@@ -125,7 +124,6 @@ class TestCreateProject:
|
||||
project.run_aggregate_assign_object(relating_obj="building", related_obj="storey").should_be_called()
|
||||
|
||||
project.set_context("body").should_be_called()
|
||||
project.set_active_spatial_element("storey").should_be_called()
|
||||
|
||||
project.append_all_types_from_template("template").should_be_called()
|
||||
|
||||
@@ -167,7 +165,6 @@ class TestCreateProject:
|
||||
project.run_aggregate_assign_object(relating_obj="building", related_obj="storey").should_be_called()
|
||||
|
||||
project.set_context("body").should_be_called()
|
||||
project.set_active_spatial_element("storey").should_be_called()
|
||||
|
||||
project.load_default_thumbnails().should_be_called()
|
||||
project.set_default_context().should_be_called()
|
||||
|
||||
@@ -87,21 +87,6 @@ class TestRunUnitAssignSceneUnits(NewFile):
|
||||
pass
|
||||
|
||||
|
||||
class TestSetActiveSpatialElement(NewFile):
|
||||
def test_run(self):
|
||||
obj = bpy.data.objects.new("Foo", None)
|
||||
collection = bpy.data.collections.new("Foo")
|
||||
bpy.context.scene.collection.children.link(collection)
|
||||
collection.objects.link(obj)
|
||||
obj.BIMObjectProperties.collection = collection
|
||||
collection.BIMCollectionProperties.obj = obj
|
||||
|
||||
layer = bpy.context.view_layer.layer_collection.children["Foo"]
|
||||
assert bpy.context.view_layer.active_layer_collection != layer
|
||||
subject.set_active_spatial_element(obj)
|
||||
assert bpy.context.view_layer.active_layer_collection == layer
|
||||
|
||||
|
||||
class TestSetContext(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
|
||||
Reference in New Issue
Block a user