mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 07:28:38 +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.run_aggregate_assign_object(relating_obj=building, related_obj=storey)
|
||||||
|
|
||||||
project.set_context(body)
|
project.set_context(body)
|
||||||
|
project.set_active_spatial_element(storey)
|
||||||
|
|
||||||
if template:
|
if template:
|
||||||
project.append_all_types_from_template(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_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_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 run_unit_assign_scene_units(cls): pass
|
||||||
|
def set_active_spatial_element(cls, obj): pass
|
||||||
def set_context(cls, context): pass
|
def set_context(cls, context): pass
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -305,9 +305,9 @@ class Geometry(blenderbim.core.tool.Geometry):
|
|||||||
for slot in obj.material_slots:
|
for slot in obj.material_slots:
|
||||||
if slot.material and slot.material.use_nodes:
|
if slot.material and slot.material.use_nodes:
|
||||||
for node in slot.material.node_tree.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
|
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 True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
@@ -94,6 +94,22 @@ class Project(blenderbim.core.tool.Project):
|
|||||||
def run_unit_assign_scene_units(cls):
|
def run_unit_assign_scene_units(cls):
|
||||||
return blenderbim.core.unit.assign_scene_units(tool.Ifc, tool.Unit)
|
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
|
@classmethod
|
||||||
def set_context(cls, context):
|
def set_context(cls, context):
|
||||||
blenderbim.bim.handler.refresh_ui_data()
|
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.run_aggregate_assign_object(relating_obj="building", related_obj="storey").should_be_called()
|
||||||
|
|
||||||
project.set_context("body").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)
|
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.run_aggregate_assign_object(relating_obj="building", related_obj="storey").should_be_called()
|
||||||
|
|
||||||
project.set_context("body").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()
|
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.run_aggregate_assign_object(relating_obj="building", related_obj="storey").should_be_called()
|
||||||
|
|
||||||
project.set_context("body").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)
|
subject.create_project(ifc, project, schema="IFC2X3", template=None)
|
||||||
|
|||||||
@@ -82,6 +82,18 @@ class TestRunUnitAssignSceneUnits(NewFile):
|
|||||||
pass
|
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):
|
class TestSetContext(NewFile):
|
||||||
def test_run(self):
|
def test_run(self):
|
||||||
ifc = ifcopenshell.file()
|
ifc = ifcopenshell.file()
|
||||||
|
|||||||
Reference in New Issue
Block a user