From 8aae8807c99f7329fc1d4957d54e9c1cfd81fcf4 Mon Sep 17 00:00:00 2001 From: spo Date: Wed, 22 Jun 2016 16:04:07 +0300 Subject: [PATCH] Use high API for testing Export freature --- src/ExchangePlugin/Test/TestExport.py | 96 +++++++++++++-------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/src/ExchangePlugin/Test/TestExport.py b/src/ExchangePlugin/Test/TestExport.py index 26fb3c90d..554ee8066 100644 --- a/src/ExchangePlugin/Test/TestExport.py +++ b/src/ExchangePlugin/Test/TestExport.py @@ -15,6 +15,8 @@ from GeomAPI import * from TestImport import testImport +import model + __updated__ = "2015-05-22" aSession = ModelAPI_Session.get() @@ -38,38 +40,26 @@ def testExport(theType, theFormat, theFile, theVolume, theDelta): aPart = aSession.activeDocument() aSession.startOperation("Import screw") - anImportFeature = aPart.addFeature("Import") - anImportFeature.string("file_path").setValue("Data/screw.step") - anImportFeature.execute() + anImport = model.addImport(aPart, "Data/screw.step") +# anImportFeature = aPart.addFeature("Import") +# anImportFeature.string("file_path").setValue("Data/screw.step") +# anImportFeature.execute() aSession.finishOperation() removeFile(theFile) # Export a part aSession.startOperation("Export part") - aFeatureKind = "Export" - anExportFeature = aPart.addFeature(aFeatureKind) - assert anExportFeature, "{0}: Can not create a feature {1}".format(theType, aFeatureKind) - - aFormatAttrName = "file_format" - aFormatAttr = anExportFeature.string(aFormatAttrName) - assert aFormatAttr, "{0}: Can not receive string field {1}".format(theType, aFormatAttrName) - aFormatAttr.setValue(theFormat) - - aFileAttrName = "file_path" - aFileAttr = anExportFeature.string(aFileAttrName) - assert aFileAttr, "{0}: Can not receive string field {1}".format(theType, aFileAttrName) - aFileAttr.setValue(theFile) - - aSelectionListAttrName = "selection_list" - aSelectionListAttr = anExportFeature.selectionList(aSelectionListAttrName) - assert aSelectionListAttr, "{0}: Can not receive selection list field {1}".format(theType, aSelectionListAttrName) - aSelectionListAttr.setSelectionType("solids") - aSelectionListAttr.append(anImportFeature.firstResult(), anImportFeature.firstResult().shape()) - - anExportFeature.execute() + model.exportToFile(aPart, theFile, anImport.result(), theFormat) +# anExportFeature = aPart.addFeature("Export") +# anExportFeature.string("file_format").setValue(theFormat) +# anExportFeature.string("file_path").setValue(theFile) +# aSelectionListAttr = anExportFeature.selectionList("selection_list") +# aSelectionListAttr.setSelectionType("solids") +# aSelectionListAttr.append(anImportFeature.firstResult(), anImportFeature.firstResult().shape()) +# anExportFeature.execute() aSession.finishOperation() - assert os.path.exists(theFile), "{0}: Can not find exported file {1}".format(theType, theFile) + assert os.path.exists(theFile) # Test exported file by importing testImport(theType, theFile, theVolume, theDelta) @@ -82,40 +72,50 @@ def testExportXAO(): aPart = aSession.activeDocument() aSession.startOperation("Import Box_1") - anImportFeature = aPart.addFeature("Import") - anImportFeature.string("file_path").setValue("Data/Box_1.brep") - anImportFeature.execute() + anImport = model.addImport(aPart, "Data/Box_1.brep") +# anImportFeature = aPart.addFeature("Import") +# anImportFeature.string("file_path").setValue("Data/Box_1.brep") +# anImportFeature.execute() aSession.finishOperation() # Create groups aSession.startOperation() - aGroupFeature = aSession.activeDocument().addFeature("Group") - aGroupFeature.data().setName("boite_1") - aSelectionListAttr = aGroupFeature.selectionList("group_list") - aSelectionListAttr.setSelectionType("solid") - aSelectionListAttr.append(anImportFeature.lastResult(), None) - aGroupFeature.execute() + aGroup = model.addGroup(aPart, anImport.result()) + aGroup.defaultResult().data().setName("boite_1") + aGroup.groupList().setSelectionType("solid") +# aGroupFeature = aSession.activeDocument().addFeature("Group") +# aGroupFeature.data().setName("boite_1") +# aSelectionListAttr = aGroupFeature.selectionList("group_list") +# aSelectionListAttr.setSelectionType("solid") +# aSelectionListAttr.append(anImport.feature().lastResult(), None) +# aGroupFeature.execute() aSession.finishOperation() aSession.startOperation() - aGroupFeature = aSession.activeDocument().addFeature("Group") - aGroupFeature.data().setName("") - aSelectionListAttr = aGroupFeature.selectionList("group_list") - aSelectionListAttr.setSelectionType("face") - aSelectionListAttr.append("Box_1_1/Shape1_1") - aSelectionListAttr.append("Box_1_1/Shape2_1") - aGroupFeature.execute() + aGroup = model.addGroup(aPart, []) + aGroup.defaultResult().data().setName("") + aGroup.groupList().setSelectionType("face") + aGroup.groupList().append("Box_1_1/Shape1_1") + aGroup.groupList().append("Box_1_1/Shape2_1") +# aGroupFeature = aSession.activeDocument().addFeature("Group") +# aGroupFeature.data().setName("") +# aSelectionListAttr = aGroupFeature.selectionList("group_list") +# aSelectionListAttr.setSelectionType("face") +# aSelectionListAttr.append("Box_1_1/Shape1_1") +# aSelectionListAttr.append("Box_1_1/Shape2_1") +# aGroupFeature.execute() aSession.finishOperation() # Export aSession.startOperation("Export") - anExportFeature = aPart.addFeature("Export") -# anExportFeature.string("ExportType").setValue("XAO") - anExportFeature.string("file_path").setValue("Data/export.xao") -# anExportFeature.string("file_format").setValue("XAO") - anExportFeature.string("xao_author").setValue("me") - anExportFeature.string("xao_geometry_name").setValue("mygeom") - anExportFeature.execute() + model.exportToXAO(aPart, "Data/export.xao", "me", "mygeom") +# anExportFeature = aPart.addFeature("Export") +# # anExportFeature.string("ExportType").setValue("XAO") +# anExportFeature.string("file_path").setValue("Data/export.xao") +# # anExportFeature.string("file_format").setValue("XAO") +# anExportFeature.string("xao_author").setValue("me") +# anExportFeature.string("xao_geometry_name").setValue("mygeom") +# anExportFeature.execute() aSession.finishOperation() # Check exported file -- 2.39.2