See #2520. You can now duplicate drawings.

This commit is contained in:
Dion Moult
2023-02-08 12:29:40 +11:00
parent 4e308a6e31
commit 88bddb9531
12 changed files with 117 additions and 13 deletions
@@ -1,6 +1,18 @@
@drawing
Feature: Drawing
Scenario: Duplicate drawing
Given an empty IFC project
And I add a cube
And the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
And I press "bim.assign_class"
And the variable "wall1" is "IfcStore.get_file().by_type('IfcWall')[-1].id()"
And I press "bim.add_drawing"
And the variable "drawing" is "IfcStore.get_file().by_type('IfcAnnotation')[0].id()"
When I press "bim.duplicate_drawing(drawing={drawing})"
Then nothing happens
Scenario: Create drawing
Given an empty IFC project
And I add a cube
@@ -12,7 +24,7 @@ Scenario: Create drawing
And the variable "drawing" is "IfcStore.get_file().by_type('IfcAnnotation')[0].id()"
And I set "scene.DocProperties.active_drawing_index" to "0"
And I press "bim.activate_view(drawing={drawing})"
And I press "bim.create_drawing"
When I press "bim.create_drawing"
Then nothing happens
Scenario: Create drawing after deleting a duplicated object
@@ -33,5 +45,5 @@ Scenario: Create drawing after deleting a duplicated object
And I press "bim.create_drawing"
And the object "IfcWall/Cube" is selected
And I press "object.delete(use_global=False)"
And I press "bim.create_drawing"
Then nothing happens
When I press "bim.create_drawing"
Then nothing happens
+18
View File
@@ -243,6 +243,24 @@ class TestAddDrawing:
subject.add_drawing(ifc, collector, drawing, target_view="target_view", location_hint="location_hint")
class TestDuplicateDrawing:
def test_run(self, ifc, drawing):
drawing.get_name("drawing").should_be_called().will_return("name")
drawing.ensure_unique_drawing_name("name").should_be_called().will_return("unique_name")
ifc.run("root.copy_class", product="drawing").should_be_called().will_return("new_drawing")
drawing.copy_drawing_representation("drawing", "new_drawing").should_be_called()
drawing.set_name("new_drawing", "unique_name").should_be_called()
drawing.get_drawing_group("new_drawing").should_be_called().will_return("group")
ifc.run("group.unassign_group", group="group", product="new_drawing").should_be_called()
ifc.run("group.add_group").should_be_called().will_return("new_group")
ifc.run(
"group.edit_group", group="new_group", attributes={"Name": "unique_name", "ObjectType": "DRAWING"}
).should_be_called()
ifc.run("group.assign_group", group="new_group", products=["new_drawing"]).should_be_called()
drawing.import_drawings().should_be_called()
subject.duplicate_drawing(ifc, drawing, drawing="drawing")
class TestRemoveDrawing:
def test_run(self, ifc, drawing):
drawing.get_drawing_collection("drawing").should_be_called().will_return("collection")
+18
View File
@@ -32,6 +32,16 @@ class TestImplementsTool(NewFile):
assert isinstance(subject(), blenderbim.core.tool.Drawing)
class TestCopyDrawingRepresentation(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
source = ifc.createIfcAnnotation(Representation=ifc.createIfcProductDefinitionShape())
dest = ifc.createIfcAnnotation()
subject.copy_drawing_representation(source, dest)
assert dest.Representation.is_a("IfcProductDefinitionShape")
class TestCreateAnnotationObject(NewFile):
def test_nothing(self):
pass
@@ -562,6 +572,14 @@ class TestSetDrawingCollectionName(NewFile):
assert collection.name == "IfcGroup/Foobaz"
class TestSetName(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
drawing = ifc.createIfcAnnotation()
subject.set_name(drawing, "Name")
assert drawing.Name == "Name"
class TestShowDecorations(NewFile):
def test_run(self):
bpy.context.scene.DocProperties.should_draw_decorations = False