- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
XML-EBOM: Another approach to assembly translatio n
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
09-21-2009 01:31 PM
In some cases it may be more advantageous to translate your assembly files one part at a time, or choose only specific parts to translate instead of translating an assembly all at once with one call. This could be because you are only interested in inspecting certain parts, or because you'd like to give your user the opportunity to convert single parts at a time as needed. What ever the reason, we provide a simple solution using Interop and XML-EBOM. Instead of converting an assembly all at once using a single convert call like so:
SPAIDocument src("C:\\model.CATPart");
SPAIAcisDocument dst;
SPAIResult result=SPAX_S_OK;
SPAIConverter converter;
SPAIOptions options;
SPAIValue representation("Assembly");
result &= options.Add(SPAIOptionName::Representation, representation);
result &= options.Add(SPAIOptionName::Flatten, false);
converter.Convert(src, dst);
You can get the assembly structer in XML-EBOM format (without converting anything), parse the XML file, and then convert parts as needed. We offer api's to get an XML-EBOM file from an assembly, so that part is pretty easy and looks like this:
const char *assemblyInfoFile = "c:\\model_asm_info.xml"';
SPAIDocument src("C:\\model.CATProduct");
SPAIDocumentAssemblyInfo srcInfo(src);
SPAIFile inputAssemblyInfoFile(assemblyInfoFile);
srcInfo.SaveAs(inputAssemblyInfoFile);
Now that you have an assembly file, what do you do with it? Well, you need to parse it out. This can be done any number of ways, but I've created a small class that does exactly that and returns a list of available parts to translate. My example uses Xerces (http://en.wikipedia.org/wiki/Xerces) which can be found here: http://xerces.apache.org/xerces-c/
After downloading and installing Xerces, link your project against the Xerces libs (I used 3.0.1), and you can use the parser like this:
// Check that xml_file exists...
.
.
.
XmlEbomParser parser( xml_file );
parser.Parse();
EbomPart * parts;
if( !parser.HasErrors() && parser.PartCount() > 0 )
{
parser.GetAvailableParts( parts );
.
.
.
// convert one at a time, list out
// or loop over the array and convert
// the parts
}
delete [] parts;
I've attached two classes to this post. Feel free to use them as a starting point for your parsing class (as I'm sure you'll want to add a lot more functionality), and feel free to ask questions.
Robert Tadlock
Technical Account Manager

