mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
The storey is now the default container when starting a project for convenience.
This commit is contained in:
@@ -58,6 +58,7 @@ def create_project(ifc, project, schema=None, template=None):
|
||||
project.run_aggregate_assign_object(relating_obj=building, related_obj=storey)
|
||||
|
||||
project.set_context(body)
|
||||
project.set_active_spatial_element(storey)
|
||||
|
||||
if template:
|
||||
project.append_all_types_from_template(template)
|
||||
|
||||
@@ -324,6 +324,7 @@ 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
|
||||
|
||||
|
||||
|
||||
@@ -305,9 +305,9 @@ class Geometry(blenderbim.core.tool.Geometry):
|
||||
for slot in obj.material_slots:
|
||||
if slot.material and slot.material.use_nodes:
|
||||
for node in slot.material.node_tree.nodes:
|
||||
if node.type == "TEX_COORD" and node.outputs['UV'].links:
|
||||
if node.type == "TEX_COORD" and node.outputs["UV"].links:
|
||||
return True
|
||||
elif node.type == "UVMAP" and node.outputs['UV'].links and node.uv_map:
|
||||
elif node.type == "UVMAP" and node.outputs["UV"].links and node.uv_map:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
@@ -94,6 +94,22 @@ 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.users_collection[0]
|
||||
queue = [bpy.context.view_layer.layer_collection]
|
||||
layer_collection = None
|
||||
|
||||
while queue:
|
||||
layer = queue.pop()
|
||||
if layer.name == collection.name:
|
||||
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()
|
||||
|
||||
@@ -63,6 +63,7 @@ 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()
|
||||
|
||||
subject.create_project(ifc, project, schema="IFC4", template=None)
|
||||
|
||||
@@ -103,6 +104,7 @@ 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()
|
||||
|
||||
@@ -152,5 +154,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()
|
||||
|
||||
subject.create_project(ifc, project, schema="IFC2X3", template=None)
|
||||
|
||||
@@ -82,6 +82,18 @@ 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)
|
||||
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