Python 3 API: Upgrading Vortex Files
The following functions are available in the Vortex Python API. They are helper functions that perform the upgrade of existing Vortex files to the current version of Vortex.
For example, the part document has been removed in 2020b, any parts will be saved properly into their parent Assembly. VHL Interfaces were removed from the Assembly and replaced with a Linking interface.
Listing children files: getFiles()
From a document e.g. scene, list the files used by that definition e.g. mechanisms, assemblies.
This can be done by using either the parent fileName or the object itself if it is already loaded.
- Vortex.getFiles('my_scene.vxscene')
- Vortex.getFiles(my_sceneObject)
The return value is a list of ObjectFileInfo, containing the following information:
- fileName: Name of the child file
- fileInfo: Version of the software when the file was saved
- error: Any error encountered during the processing
# Getting the child file information from my scene file. files = Vortex.getFiles('my_scene.vxscene') for f in files: print(f.fileName)
Listing dependencies files: getAllFileDependencies()
From a document e.g. scene or an equipment, list the files used by that definition e.g. mechanisms, assemblies as well as all files referenced in extensions inside a VxFilename Field.
This can be done by using either the parent fileName or the object itself if it is already loaded.
- Vortex.getAllFileDependencies('my_scene.vxscene')
- Vortex.getAllFileDependencies(my_sceneObject)
The return value is a list of ObjectFileInfo, containing the following information:
- fileName: Name of the child file
- fileInfo: Version of the software when the file was saved
- error: Any error encountered during the processing
Upgrading to the latest version
Upgrading a single document and its children: upgradeObject()
From a document e.g. scene, upgrade the file and its children used by that definition e.g. mechanisms, assemblies.
This can be done by using either the parent fileName of the object itself if it is already loaded.
- Vortex.upgradeObject('my_scene.vxscene')
- Vortex.upgradeObject(my_sceneObject)
The return value is a list of ObjectFileInfo, containing the following information:
- fileName: Name of the file upgraded
- fileInfo: Version of the software saved
- error: Any error encountered during the processing
# Getting the child file information from my scene file. files = Vortex.upgradeObject('my_scene.vxscene') for f in files: print(f.fileName + ' has been saved to the latest version')
Upgrading a single document: upgradeFiles()
Upgrade a list of files to the latest version.
This can be done by using either the return value of getFiles() or passing a list of file name.
- Vortex.upgradeFiles(listOfReturnValueOfMultiplesCallsToGetFiles())
- Vortex.upgradeFiles(listOfFiles)
The return value is a list of ObjectFileInfo, containing the following information:
- fileName: Name of the file upgraded
- fileInfo: Version of the software saved
- error: Any error encountered during the processing
# processing all files in a directory def processDirectory(directory) allfiles = [] for file in directory allfiles.append(Vortex.getFiles(file)) return allfiles; #... get the directory information filesToProcess = processDirectory(d) # ... display information or use some algorithm to filter out some file filesProcessed = Vortex.upgradeFiles(filesToProcess) # ... display information
Upgrading a Python 2 script extension to Python 3 dynamics script extension
Vortex is no longer supporting Python 2. Any remaining Python 2 dynamics extension in simulation content when loaded in Vortex editor is auto-upgraded to the new python 3 dynamics extension. The conversion does not actually convert the code but otherwise, the extension is effectively replaced. The user is responsible to manually correct the script code to have it fully functional in Vortex.