cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Family table related API

ssingh-10-11-12
7-Bedrock

Family table related API

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

ACCEPTED SOLUTION

Accepted Solutions

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);
}

}
}

 

 

View solution in original post

6 REPLIES 6

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.

https://www.ptc.com/en/support/article/cs179216?language=en&posno=5&q=wt.epm.familytable&source=search

 

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.

avillanueva
22-Sapphire II
(To:RandyJones)

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.

 

d_graham_0-1670170523757.png

 

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);
}

}
}

 

 

Announcements


Top Tags