After understanding I think a bit more of what you wanted. Here is a job that gives you pretty much most of the examples of how to do what you want.
Note the TODO's
that need completed.
static void JobImportXPOs(Args _args)
{
SysVersionControlSystem vcs = versionControl.parmSysVersionControlSystem();
SysImportElements sysImportElements = new SysImportElements();
TmpAotImport tmpAotImport;
Filename fileName = @"C:\Temp\testXPO.xpo";
SysVersionControllable controllable;
TreeNode treeNode;
sysImportElements.newFile(fileName);
sysImportElements.parmAddToProject(false);
sysImportElements.parmImportAot(true);
tmpAotImport = sysImportElements.getTmpImportAot();
while select tmpAotImport
{
treeNode = TreeNode::findNode(tmpAotImport.TreeNodePath);
if (!treeNode)
{
// New object being added to AX
// TODO - Remember this object and add this to VCS system at the end for check-in
continue;
}
controllable = SysTreeNode::newTreeNode(treeNode);
if (!controllable)
{
error(strFmt("Error processing %1 (%2) from file %3", tmpAotImport.TreeNodeName, tmpAotImport.TreeNodePath, Filename));
continue;
}
if (vcs.allowCreate(controllable))
{
info(strFmt("Planning to add to VCS %1 for import", tmpAotImport.TreeNodePath));
// TODO - Remember to add this to VCS at the end of the import
}
else if (vcs.allowCheckOut(controllable))
{
info(strFmt("Checking out %1 for import", tmpAotImport.TreeNodePath));
// TODO - Remember to check this specific object back in at the end of the import
}
}
// Do the actual import
sysImportElements.import();
// TODO - Check in all of the objects we just handled
info("Done");
}