mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 14:02:27 +00:00
You can now create drawing sheets in IFC. See #1153.
This commit is contained in:
@@ -67,3 +67,53 @@ class TestEditTextProduct:
|
||||
drawing.update_text_value("obj").should_be_called()
|
||||
drawing.disable_editing_text_product("obj").should_be_called()
|
||||
subject.edit_text_product(ifc, drawing, obj="obj", product="product")
|
||||
|
||||
|
||||
class TestLoadSheets:
|
||||
def test_run(self, drawing):
|
||||
drawing.import_sheets().should_be_called()
|
||||
drawing.enable_editing_sheets().should_be_called()
|
||||
subject.load_sheets(drawing)
|
||||
|
||||
|
||||
class TestDisableEditingSheets:
|
||||
def test_run(self, drawing):
|
||||
drawing.disable_editing_sheets().should_be_called()
|
||||
subject.disable_editing_sheets(drawing)
|
||||
|
||||
|
||||
class TestAddSheet:
|
||||
def test_run(self, ifc, drawing):
|
||||
ifc.run("document.add_information").should_be_called().will_return("sheet")
|
||||
drawing.generate_sheet_identification().should_be_called().will_return("identification")
|
||||
drawing.ensure_unique_identification("identification").should_be_called().will_return("u_identification")
|
||||
ifc.get_schema().should_be_called().will_return("IFC4")
|
||||
ifc.run(
|
||||
"document.edit_information",
|
||||
information="sheet",
|
||||
attributes={"Identification": "u_identification", "Name": "UNTITLED", "Scope": "DOCUMENTATION"},
|
||||
).should_be_called()
|
||||
drawing.create_svg_sheet("sheet", "titleblock").should_be_called()
|
||||
drawing.import_sheets().should_be_called()
|
||||
subject.add_sheet(ifc, drawing, titleblock="titleblock")
|
||||
|
||||
def test_using_a_document_id_in_ifc2x3(self, ifc, drawing):
|
||||
ifc.run("document.add_information").should_be_called().will_return("sheet")
|
||||
drawing.generate_sheet_identification().should_be_called().will_return("identification")
|
||||
drawing.ensure_unique_identification("identification").should_be_called().will_return("u_identification")
|
||||
ifc.get_schema().should_be_called().will_return("IFC2X3")
|
||||
ifc.run(
|
||||
"document.edit_information",
|
||||
information="sheet",
|
||||
attributes={"DocumentId": "u_identification", "Name": "UNTITLED", "Scope": "DOCUMENTATION"},
|
||||
).should_be_called()
|
||||
drawing.create_svg_sheet("sheet", "titleblock").should_be_called()
|
||||
drawing.import_sheets().should_be_called()
|
||||
subject.add_sheet(ifc, drawing, titleblock="titleblock")
|
||||
|
||||
|
||||
class TestOpenSheet:
|
||||
def test_run(self, drawing):
|
||||
drawing.get_sheet_filename("sheet").should_be_called().will_return("filename")
|
||||
drawing.open_svg("filename").should_be_called()
|
||||
subject.open_sheet(drawing, sheet="sheet")
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
import bpy
|
||||
import ifcopenshell
|
||||
import blenderbim.core.tool
|
||||
@@ -29,6 +30,21 @@ class TestImplementsTool(NewFile):
|
||||
assert isinstance(subject(), blenderbim.core.tool.Drawing)
|
||||
|
||||
|
||||
class TestCreateSvgSheet(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
document = ifc.createIfcDocumentInformation(Identification="X", Name="FOOBAR")
|
||||
subject.create_svg_sheet(document, "A1")
|
||||
assert os.path.isfile(os.path.join(bpy.context.scene.BIMProperties.data_dir, "sheets", "X - FOOBAR.svg"))
|
||||
|
||||
|
||||
class TestDisableEditingSheets(NewFile):
|
||||
def test_run(self):
|
||||
bpy.context.scene.DocProperties.is_editing_sheets = True
|
||||
subject.disable_editing_sheets()
|
||||
assert bpy.context.scene.DocProperties.is_editing_sheets == False
|
||||
|
||||
|
||||
class TestDisableEditingText(NewFile):
|
||||
def test_run(self):
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
@@ -45,6 +61,13 @@ class TestDisableEditingTextProduct(NewFile):
|
||||
assert obj.BIMTextProperties.is_editing_product == False
|
||||
|
||||
|
||||
class TestEnableEditingSheets(NewFile):
|
||||
def test_run(self):
|
||||
bpy.context.scene.DocProperties.is_editing_sheets = False
|
||||
subject.enable_editing_sheets()
|
||||
assert bpy.context.scene.DocProperties.is_editing_sheets == True
|
||||
|
||||
|
||||
class TestEnableEditingText(NewFile):
|
||||
def test_run(self):
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
@@ -59,6 +82,26 @@ class TestEnableEditingTextProduct(NewFile):
|
||||
assert obj.BIMTextProperties.is_editing_product == True
|
||||
|
||||
|
||||
class TestEnsureUniqueIdentification(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
tool.Ifc.set(ifc)
|
||||
assert subject.ensure_unique_identification("FOOBAR") == "FOOBAR"
|
||||
ifc.createIfcDocumentInformation(Identification="FOOBAR", Scope="DOCUMENTATION")
|
||||
assert subject.ensure_unique_identification("FOOBAR") == "FOOBAR-X"
|
||||
ifc.createIfcDocumentInformation(Identification="FOOBAR-X", Scope="DOCUMENTATION")
|
||||
assert subject.ensure_unique_identification("FOOBAR") == "FOOBAR-X-X"
|
||||
|
||||
def test_unique_document_id_ifc2x3(self):
|
||||
ifc = ifcopenshell.file(schema="IFC2X3")
|
||||
tool.Ifc.set(ifc)
|
||||
assert subject.ensure_unique_identification("FOOBAR") == "FOOBAR"
|
||||
ifc.createIfcDocumentInformation(DocumentId="FOOBAR", Scope="DOCUMENTATION")
|
||||
assert subject.ensure_unique_identification("FOOBAR") == "FOOBAR-X"
|
||||
ifc.createIfcDocumentInformation(DocumentId="FOOBAR-X", Scope="DOCUMENTATION")
|
||||
assert subject.ensure_unique_identification("FOOBAR") == "FOOBAR-X-X"
|
||||
|
||||
|
||||
class TestExportTextLiteralAttributes(NewFile):
|
||||
def test_run(self):
|
||||
TestImportTextAttributes().test_run()
|
||||
@@ -69,6 +112,27 @@ class TestExportTextLiteralAttributes(NewFile):
|
||||
}
|
||||
|
||||
|
||||
class TestGetSheetFilename(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
document = ifc.createIfcDocumentInformation(Identification="X", Name="FOOBAR", Scope="DOCUMENTATION")
|
||||
subject.get_sheet_filename(document) == "X - FOOBAR"
|
||||
|
||||
def test_run_ifc2x3(self):
|
||||
ifc = ifcopenshell.file(schema="IFC2X3")
|
||||
document = ifc.createIfcDocumentInformation(DocumentId="X", Name="FOOBAR", Scope="DOCUMENTATION")
|
||||
subject.get_sheet_filename(document) == "X - FOOBAR"
|
||||
|
||||
|
||||
class TestGenerateSheetIdentification(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
tool.Ifc.set(ifc)
|
||||
subject.generate_sheet_identification() == "A01"
|
||||
document = ifc.createIfcDocumentInformation()
|
||||
subject.generate_sheet_identification() == "A02"
|
||||
|
||||
|
||||
class TestGetTextLiteral(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
@@ -94,6 +158,30 @@ class TestGetTextProduct(NewFile):
|
||||
assert subject.get_text_product(label) == wall
|
||||
|
||||
|
||||
class TestImportSheets(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
tool.Ifc.set(ifc)
|
||||
ifc.createIfcDocumentInformation(Identification="Y", Name="FOOBAZ")
|
||||
document = ifc.createIfcDocumentInformation(Identification="X", Name="FOOBAR", Scope="DOCUMENTATION")
|
||||
subject.import_sheets()
|
||||
props = bpy.context.scene.DocProperties
|
||||
assert props.sheets[0].ifc_definition_id == document.id()
|
||||
assert props.sheets[0].identification == "X"
|
||||
assert props.sheets[0].name == "FOOBAR"
|
||||
|
||||
def test_run_ifc2x3(self):
|
||||
ifc = ifcopenshell.file(schema="IFC2X3")
|
||||
tool.Ifc.set(ifc)
|
||||
ifc.createIfcDocumentInformation(DocumentId="Y", Name="FOOBAZ")
|
||||
document = ifc.createIfcDocumentInformation(DocumentId="X", Name="FOOBAR", Scope="DOCUMENTATION")
|
||||
subject.import_sheets()
|
||||
props = bpy.context.scene.DocProperties
|
||||
assert props.sheets[0].ifc_definition_id == document.id()
|
||||
assert props.sheets[0].identification == "X"
|
||||
assert props.sheets[0].name == "FOOBAR"
|
||||
|
||||
|
||||
class TestImportTextAttributes(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
@@ -137,6 +225,11 @@ class TestImportTextProduct(NewFile):
|
||||
assert label_obj.BIMTextProperties.relating_product is None
|
||||
|
||||
|
||||
class TestOpenSvg(NewFile):
|
||||
def test_nothing(self):
|
||||
pass
|
||||
|
||||
|
||||
class TestUpdateTextValue(NewFile):
|
||||
def test_updating_arbitrary_strings(self):
|
||||
TestGetTextLiteral().test_run()
|
||||
|
||||
Reference in New Issue
Block a user