Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X
Hi ,
I am having Generic CAD Part and want to fetch all Instance CAD Part using java code.
Is there any API so that i can use.
Thanks,
Sourabh Singh
Solved! Go to Solution.
Hi ,
I got the solution and it worked for me:
below code will work:
EPMDocument top = (EPMDocument) PersistenceHelper.manager.refresh(epmd);
WTCollection seeds = new WTArrayList();
seeds.add(top);
EPMDocConfigSpec configSpec = new EPMDocConfigSpec();
EPMAsStoredConfigSpec asStored = EPMAsStoredConfigSpec.newEPMAsStoredConfigSpec(top);
if (asStored!=null){ configSpec.setAsStoredConfig(asStored);
configSpec.setAsStoredActive(true);} else { configSpec.setLatestActive();}
NavigationCriteria navCriteria = NavigationCriteria.newNavigationCriteria();navCriteria.setApplicableType( wt.epm.EPMDocument.class.getName() );
navCriteria.setConfigSpecs( Arrays.asList( new ConfigSpec[]{configSpec}));
CadCollectedResult ccr = CadCollector.newInstance(seeds, navCriteria)
.familyMembers(GatherFamilyMembers.ALL)
.collect();
Collection result = ccr.getCollectedObjects();
System.out.println("Number of objects Collected : " + result.size());
Iterator items = result.iterator();
while (items.hasNext())
{
Object item2 = items.next();
if (item2 instanceof Persistable) {
// System.out.println("Related CAD object : " + (Persistable)item2);
// Persistable pr =(Persistable)item2;
EPMDocument instanceDocument = (EPMDocument)item2;
String genericNumber = instanceDocument.getNumber();
if (!inputNumber.equals(genericNumber)) {
String genericName = instanceDocument.getName();
String genRevision= instanceDocument.getVersionIdentifier().getValue();
String genIteration = instanceDocument.getIterationIdentifier().getValue();
String genVersion= genRevision+"."+genIteration;
String genericVersion = "'" +genVersion+"'";
System.out.println("Number :"+genericNumber+" Version :"+genVersion);
}
}
}
I would hunt around in wt.epm.familytable package but at first glance I did not see anything useful. This link may be useful if you want to do a Query in Java to find them by navigating links.
One possibility is to use the CadCollector api. PTC has an article on that here:
https://www.ptc.com/en/support/article/cs376970
There is probably a better way but I don't know of them of the top of my head.
I think you nailed it Randy.
Is what you are looking for?
I wrote and ran a class in Windchill shell as a test. Seems to work.
I did this using QuerySpec however there are a couple of other ways to do it.
@RandyJones suggestion of using the CadCollector would not also work.
Hi D-Graham,
Yes, I saw the output and looking the similar type of data. It would be great help if you share the code
Thanks,
Sourabh Singh
Hi ,
I got the solution and it worked for me:
below code will work:
EPMDocument top = (EPMDocument) PersistenceHelper.manager.refresh(epmd);
WTCollection seeds = new WTArrayList();
seeds.add(top);
EPMDocConfigSpec configSpec = new EPMDocConfigSpec();
EPMAsStoredConfigSpec asStored = EPMAsStoredConfigSpec.newEPMAsStoredConfigSpec(top);
if (asStored!=null){ configSpec.setAsStoredConfig(asStored);
configSpec.setAsStoredActive(true);} else { configSpec.setLatestActive();}
NavigationCriteria navCriteria = NavigationCriteria.newNavigationCriteria();navCriteria.setApplicableType( wt.epm.EPMDocument.class.getName() );
navCriteria.setConfigSpecs( Arrays.asList( new ConfigSpec[]{configSpec}));
CadCollectedResult ccr = CadCollector.newInstance(seeds, navCriteria)
.familyMembers(GatherFamilyMembers.ALL)
.collect();
Collection result = ccr.getCollectedObjects();
System.out.println("Number of objects Collected : " + result.size());
Iterator items = result.iterator();
while (items.hasNext())
{
Object item2 = items.next();
if (item2 instanceof Persistable) {
// System.out.println("Related CAD object : " + (Persistable)item2);
// Persistable pr =(Persistable)item2;
EPMDocument instanceDocument = (EPMDocument)item2;
String genericNumber = instanceDocument.getNumber();
if (!inputNumber.equals(genericNumber)) {
String genericName = instanceDocument.getName();
String genRevision= instanceDocument.getVersionIdentifier().getValue();
String genIteration = instanceDocument.getIterationIdentifier().getValue();
String genVersion= genRevision+"."+genIteration;
String genericVersion = "'" +genVersion+"'";
System.out.println("Number :"+genericNumber+" Version :"+genVersion);
}
}
}