开发技巧-3D InterOp

Configurable Translation using 3D InterOp

By Venugopal Chiramdasu

3D InterOp translators have a flexible interface which gives an application developer many more options than traditional one step file-to-file translation does. Application developers can use this flexible interface to configure the mode of file import/export in their application.
The basic workflow consists of three steps:

  1. Query the source file for document type using the SPAIDocumentHeaderInfo interface, and then query for key document settings (e.g. units) and/or summary information using the appropriate document info class (SPAIDocumentBRepInfo or SPAIDocumentAssemblyInfo). These query methods load only small sections of the file and are faster than doing a full translation.
  2. Use the queried information to configure the conversion step using the SPAIOptions and SPAIConverter classes. During this step the user can also review the summary information to determine if some or all of the file or associated files should be converted.
  3. Finally, perform the conversion as specified.

A common use of this workflow is in translation of large assemblies. Often an application only needs to translate a few parts or sub-assemblies, so translating the entire assembly would incur unnecessary performance costs.

  1. Use SPAIDocumentAssemblyInfo to create an xml summary of the product structure for the input assembly.
  2. Parse the xml file and its nodes to process the the product structure to obtain the file names and paths of the parts or sub-assemblies.
  3. Use the file names and paths to convert each part or sub-assembly file individually. This could be done in a loop or even in different processes of a multi-process application.

For further details, please see the following examples on using Document Info classes.

Twitter Facebook LinkedIn RSS