PLM XML Export Import Admin
PLM XML Export Import Admin
The goal of this document is to discuss the different extension points available to the developer when
importing or exporting a PLMXML file in Teamcenter and provide a walkthrough example in how to
implement these extensions.
The option to import and export PLMXML files provides a wide array of extension points for a user to
take advantage of. The follow customization points are available:
Following is the order user extensions are called when exporting a PMLXML file:
pre-action
export process
filters
user methods
during-action (PLMXML file not save and XML document still loaded)
xslt (optional)
post-action
Following is the order user extensions are called when importing a PMLXML file:
pre-action
xslt (optional)
load/parse the PLM XML document
during action
import process
filters
user methods
post action
To begin, it is assumed you have created a BMIDE project using the “foundation” template. The project
name used in this example is, “PLMXMLUserExt” and uses a prefix string of, “G4”.
Add the “pie” dependency because it will include the need PLMXML library.
Next, in the Extension view, select Rules->Extensions, right click on Extensions and click “New Extension
Definition…”
Provide an Extension name of “G4PLMXMLUserExt” and click the “Add” button to the right of
Availability. Populate the New Extension Availability dialog:
Likewise, add a new Extension Availability for Filters and Export methods.
Once finished, the new Extension Definition dialog should look as follows:
Clicking Finish the Extension View should update showing the new Extension:
Next, expand the User Exits in the Extension view and double click on “PLMXML.”
The meta data model requirements for Import/Export Extensions is now complete.
To generate the need extension ‘C’ code, select the “G4PLMXMLUserExt” from the Extension View and right click,
“Generate extension code…”
In the Navigator View, select the root project node and press F5 to refresh the project.
If you expand the output/server/gensrc/G4PLMXMLUserExt folder you should see the auto generated
G4PLMXMLUserExt.c & .h file. Open the G4PLMXMLUserExt.c file.
#include <G4PLMXMLUserExt/G4PLMXMLUserExt.h>
printf("G4PLMXMLUserExt registration\n");
/* user actions */
PIE_register_user_action("GTACCustomExportPreAction", (PIE_user_action_func_t)G4PreExportExtension);
PIE_register_user_action("GTACCustomExportDuringAction", (PIE_user_action_func_t)G4DuringExportExtension);
PIE_register_user_action("GTACCustomExportPostAction", (PIE_user_action_func_t)G4PostExportExtension);
/* filters */
PIE_register_user_filter("GTACCustomFilterRule", (PIE_user_filter_func_t)G4FilterExtension);
return 0;
}
printf("G4FilterExtension\n");
PIE_get_obj_from_callpath(userPath, &tag);
TCTYPE_ask_object_type(tag, &type_tag);
TCTYPE_ask_name(type_tag, type_name);
Save the source files and do a Project->Build All. Your project should build without errors.
Argument overview
PIE_register_user_methods
contextStr: A unique string and the string value is entered in the “Context” field in TransferMode
definition. This string allows the user to group user-methods with different names for a given context.
name: This string maps an import/export method to a specific Teamcenter Object or PLMXML element.
For example:
Names used in Export user-methods Names used in Import user-methods
Teamcenter objects PLM XML element
Item ProcessorProduct
Item Product
Item Software
ItemRevision ProcessorProductRevision
ItemRevision ProductRevision
ItemRevision SoftwareRevision
A full list of schema mappings is available in the PLM XML Export Import Administration Guide in
the PLM XML/Teamcenter entity mapping section.
The userPath argument can be used in any of the PIE_* ITK functions that takes a void* named
“userPath”. Please see the Integration Toolkit (ITK) Function Reference documentation for a full listing of
available PIE functions.
The function body will generally use the PLMXML SDK to implement the writing or reading of the PLMXML
document. The details of this implementation however are beyond the scope of this document.
PIE_register_user_filter
filterRuleName: A unique string that will be displayed in the FilterRule, Filter Rule Name, drop down list.
The userPath argument can be used in any of the PIE_* ITK functions that takes a void* named
“userPath”. Valid return values are defined in the PIE_rule_type_e enum (pie/pie.h):
PIE_register_user_action
handleName: A unique string that will be displayed in the ActionRule, Action handler, drop down list
The session tag_t can be used in any of the PIE_* ITK functions that takes a tag_t session. Please see the
Integration Toolkit (ITK) Function Reference documentation for a full listing of available PIE functions.
If your project built successfully you are now ready to deploy the project.
In the Extension View, right click the root node and click, Deploy Template…
Enter the User ID and Password and click “Connect.” When the connection is established, click “Finish.”
As the deployment is processing you should see similar out to your TAO window:
When the deployment is completed you should get the following confirmation dialog:
We are done with the BMIDE.
In order to load the custom DLL the user needs to set BMF_CUSTOM_IMPLEMENTOR_PATH preference.
For the preference setting to take effect exit and restart the RAC.
PLM XML Export Import Administration Application
Once RAC has started, open the “PLM XML Export Import Administration Application.”
Enter the “Action Rule Name”, set the “Scope of Action” to Export, “Location of Action” to “Pre Action”, and the
drop down list for Action Handler should list, “GTACCustomExportPreAction”. Once complete, click the “Create”
button to create the new Action Rule object.
Likewise, create an Export Action for “During” and “Post” action extensions.
Click on “ClosureRule”.
Enter the Traversal Rule Name of “GTACCustomClosureRule”, select Export for Scope and PLMXML for Output
Format.
Click the “+” button on the right to create a new row and populate the row as shown.
Click on “FilterRule”.
Enter “GTACItemRevExportFilter” for the Filter Rule Name, select Export for Scope and PLMXML for Output
Format.
Click the “+” button on the right to create a new row and populate the row as shown. The “GTACCustonFileRule”
should be listed in the Filter Rule Name drop down list.
Click on TransferMode.
Enter “GTACCustomExport” for the name, set Export for the Transfer Type, PLMXML for the Output Format, for the
Closure Rule select “GTACCustomClosureRule”, for Filter Rule select “GTACItemRevExportFilter” and in the Action
list move the actions using the “+” button.
The Exporting of the Item and ItemRevision should look similar to the XML file below:
PIE_register_user_schema:
id checkoutRefs productId
name subType alternateForRef
nameRef effectivityRefs unitRef
descriptionTextRef releaseStatusRefs designRequired
attributeRefs catalogueId source
accessRefs optionRefs vendorRef
statusRef propertyRefs
Attempting to map PLMXML attributes not listed will have no effect. For more information in regards to
other PLMXML elements and their available attributes please see the PLMXML SDK documentation.
To map Teamcenter custom user properties into the PLMXML file use a PropertySet. A PropertySet will
place Teamcenter user properties within a PLMXML <UserData>…</UserData> element structure. Please
see the PLM XML Export Import Administration Guide for more information about PropertySets.
TransferMode Context
You may have noticed that the “Context” field was left blank. This was intentional. By entering the
Context string used in the PIEUserMethodList_t, CUSTOM_PIE_CONTEXT_STRING this will use user
defined method extensions to export or import a specific Teamcenter business object or PLMXML
element respectively. Because the body of our ItemRevision method extension is empty the data will not
be exported. You would export the data using the PLMXML SDK which is unfortunately beyond the scope
of this document.
XSLT
The XSLT option provides the option to translate a PLMXML file before import or after export. In the
sample code for function G4PreExportExtension you for will find the following code to set the XSLT file:
PIE_session_set_user_xslt_file(session, "C:\\TCU83\\dev\\xslt\\prettyprint.xsl");
This function will set the XSLT file for both import and export. If you wish to set the XSLT file for a
TransferMode object without using customization, use command line utility plmxml_tm_edit_xsl.
Please see the Utilities Reference manual for more information.
Sample pretty-print XSLT files are available on the internet. Use your favorite internet search engine and
search for “XSLT pretty print”.
Here are some links that I found useful for pretty-print output:
http://www.printk.net/~bds/indent.html
http://www.xml.com/pub/a/2006/11/29/xslt-xml-pretty-printer.html?page=1
Ver: 1.3
Patrick Hoonhout
GTAC Support