+
+ if theErrorExpected:
+ assert anExportFeature.error() != ""
+ aPart.removeFeature(anExportFeature)
+ else:
+ assert os.path.exists(theFile)
+
+ # Test exported file by importing
+ testImport(theType, theFile, theVolume, theDelta)
+
+def testExportXAO(theFile, theEmptyFormat = False):
+ type = "XAO"
+ format = "XAO"
+ if theEmptyFormat:
+ type = "Regular"
+ format = ""
+
+ # Import a reference part
+ aSession.startOperation("Add part")
+ aPartFeature = aSession.moduleDocument().addFeature("Part")
+ aSession.finishOperation()
+ aPart = aSession.activeDocument()
+
+ aSession.startOperation("Import Box_1")
+ anImportFeature = aPart.addFeature("Import")
+ aShapePath = os.path.join(os.getenv("DATA_DIR"), "Shapes", "Brep", "box1.brep")
+ anImportFeature.string("file_path").setValue(aShapePath)
+ aSession.finishOperation()
+
+ # Create groups
+ aSession.startOperation("First group")
+ aGroupFeature = aSession.activeDocument().addFeature("Group")
+ aGroupFeature.data().setName("boite_1")
+ aSelectionListAttr = aGroupFeature.selectionList("group_list")
+ aSelectionListAttr.setSelectionType("solid")
+ aSelectionListAttr.append(anImportFeature.lastResult(), None)
+ aSession.finishOperation()
+
+ aSession.startOperation("Second Group")
+ aGroupFeature = aSession.activeDocument().addFeature("Group")
+ aGroupFeature.data().setName("")
+ aSelectionListAttr = aGroupFeature.selectionList("group_list")
+ aSelectionListAttr.setSelectionType("face")
+ aSelectionListAttr.append("box1_1/Shape_1")
+ aSelectionListAttr.append("box1_1/Shape_2")
+ aSession.finishOperation()
+
+ aSession.startOperation("Create a field")
+ aField = aSession.activeDocument().addFeature("Field")
+ aSelectionListAttr = aField.selectionList("selected")
+ aSelectionListAttr.setSelectionType("face")
+ aSelectionListAttr.append("box1_1/Shape_1")
+ aSelectionListAttr.append("box1_1/Shape_2")
+ aComponentNames = aField.stringArray("components_names")
+ aComponentNames.setSize(2) # two components
+ aComponentNames.setValue(0, "temperatue")
+ aComponentNames.setValue(1, "porosity")
+ aStamps = aField.intArray("stamps")
+ aStamps.setSize(1) # one step
+ aStamps.setValue(0, 10)
+ aTables = aField.tables("values")
+ aTables.setType(2) # double
+ aTables.setSize(1 + 2, 2, 1) # default row + number of selected, number of compoents, number of steps (tables)
+ aTables.setValue(1., 0, 0, 0) # value, index of selection, index of component, index of step
+ aTables.setValue(2., 1, 0, 0)
+ aTables.setValue(3., 2, 0, 0)
+ aTables.setValue(4., 0, 1, 0)
+ aTables.setValue(5., 1, 1, 0)
+ aTables.setValue(6., 2, 1, 0)
+ aSession.finishOperation()
+
+ # Export
+ aSession.startOperation("Export to XAO")
+ anExportFeature = aPart.addFeature("Export")
+ anExportFeature.string("xao_file_path").setValue(theFile)
+ anExportFeature.string("file_format").setValue(type)
+ anExportFeature.string("ExportType").setValue(type)
+ anExportFeature.string("xao_author").setValue("me")
+ anExportFeature.string("xao_geometry_name").setValue("mygeom")
+ aSession.finishOperation()
+
+ # Check exported file
+ aRefPath = os.path.join(os.getenv("DATA_DIR"), "Shapes", "Xao", "box2.xao")
+ import filecmp
+ assert filecmp.cmp(theFile, aRefPath)