InterOp:Connect/Translation Basics
From DocR18
Contents |
Basic Translation
Translation is performed by the SPAIConverter object with specification of source and destination documents.
The source document indicates which model is to be translated. The destination document indicates in which format, and where, the translated model is to be created.
Source and destination documents are specified with the SPAIDocument object. In most cases, a document is a file on the file system specified by a file path or a file pointer. InterOp Connect also supports file names with multibyte characters. You can enable an application to support files with multibyte characters by setting the locale correctly through the application before a call is made to the Connect APIs. For more information, refer to Setting the Locale to Support Files with Multibyte Characters.
The following example illustrates how to use the SPAIConverter and SPAIDocument objects for translating a CATIA V5 Part file into an ACIS SAT file:
#include "SPAIConverter.h" #include "SPAIDocument.h" int main() { SPAIDocument src("C:\\model.CATPart"); SPAIDocument dst("C:\\model.sat"); SPAIConverter converter; converter.Convert(src, dst); return 0; }
Connect determines the type of document to read or to write using the given file extension. In the above example, .sat and .CATPart are recognized as ACIS and CATIA V5 extensions. In some cases where the document is created without a recognized file extension, the SetType method must be used in order to specify the document type. For instance, the file may have no extension, or the document is specified with a file pointer instead of a file path. Many extensions are automatically recognized by Connect, but some are not. The SetType documentation provides a list of those that are recognized and the document type that must be specified for each.
The following example illustrates how to use the SetType method for translating an Inventor Part file into an ACIS SAT file:
#include "SPAIConverter.h" #include "SPAIDocument.h" void main() { SPAIDocument src("C:\\model.ipt"); src.SetType("Inventor"); SPAIDocument dst("C:\\model.sat"); SPAIConverter converter; converter.Convert(src, dst); }
Simple Sample
This sample demonstrates simple translation from an input file to an output file. The input and output format can be specified with the arguments iformat and oformat, respectively.
Usage
Simple -i file -iformat format -o file -oformat format
Options
-i : input file -o : output file -iformat : input format -oformat : output format -options : options file
