Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X
I am using Windchill 10.2. I am trying to download assembly as well as its child parts with correct version(Not latest) using JAVA APIs.
Here is the situation -
I created one Assembly A with version 1.1 has 2 parts P1 with version 1.1 and P2 with version 1.1. Now I changed P2 and checked-in assembly again. So assembly version becomes 1.2, P1 is still 1.1 but P2 moves to 1.2.
A (1.1) A (1.2)
|---- P1 (1.1) |---- P1 (1.1)
|---- P2 (1.1) |---- P2 (1.2)
Now, I want to download Assembly with version 1.1 and its children, P1 and P2, both having version 1.1. I am doing following to get EPMDocument of assembly.
QuerySpec qSpec = new QuerySpec( EPMDocumentMaster.class );
qSpec.appendWhere( new SearchCondition( EPMDocumentMaster.class, EPMDocumentMaster.NAME, SearchCondition.EQUAL, "abc.asm") );
QueryResult qrMasters = PersistenceHelper.manager.find( qSpec );
QueryResult qr = VersionControlHelper.service.allVersionsOf( (Mastered)qrMasters.nextElement() );
EPMDocument epmDocument;
while ( qr.hasMoreElements() ) {
epmDocument = (EPMDocument) qr.nextElement(); <-- Here I got EPMDocument of Assembly
VersionInfo versionInfo = epmDocumentTemp.getVersionInfo();
if ( versionInfo.getIdentifier().getValue().equals("1") ) {
break;
}
}
Now I got EPMDocument. I want to know its children. For this,
QueryResult qr = EPMStructureHelper.service.navigateUses( epmDocument, null, false);
Enumeration enum1 = qr.getEnumeration();
while (enum1.hasMoreElements()) {
EPMMemberLink aEPMMemberLink = (EPMMemberLink) enum1.nextElement();
}
Here, I want to know EPMDocument of each child of assembly.
When I do,
EPMDocumentMaster aEPMDocumentMaster = (EPMDocumentMaster) aEPMMemberLink.getUses();
QueryResult qr1 = VersionControlHelper.service.allVersionsOf(aEPMDocumentMaster);
EPMDocument doc = (EPMDocument) qr1.nextElement();
I always get document of latest iteration. I want the one that is referenced by assembly of earlier version. How do I find this? I am more interested in knowing its iteration number.
Hello Swapnil.
I haven't coded in a while; but there is a way to filter the child masters based on a config spec. Look for documentation on ConfigHelper.service.filteredIterationsOf()
You can then either provide the system created "As-stored" configuration or a baseline to get the version of the children you want.
"As-Stored" gives you the versions in the Workspace when the assembly was checked in.
I hope this points you in the right direction.
Jennifer
Jennifer,
Off topic here...but that is the best and clearest explaination I've seen on the definition of "As Stored". Do you have a simple description for Baseline? Maybe Baseline is just a fancy way of creating an As stored structure without using the workspace checkin process?
Hello Bill.
As Stored is like a baseline of:
- the objects you are checking in (their checked in version)
- PLUS the version of all children in the workspace.
As stored is more complicated than a baseline, because:
- It maintains information about why objects are in the configuration (i.e. they were being checked in or they were a dependent)
- It has special behavior for purge and delete such that they do not prevent delete and the as-stored becomes incomplete.
I hope this helps.
Jennifer
Hi Jennifer,
When I try to use filteredIterationsOf to get EPMDocument for Assembly or Part, I get following error.
Internal Error: as-stored configuration is null.
What can be reason behind this? I believe by default windchill stores this config spec for assembly.
Hello Swapnil.
The API will do the same thing as the UI. To verify if you think an As-Stored should be present, I would suggest using some action in the Windchill UI with the same seeds (e.g. Add to Workspace).
If the UI shows an as-stored in the same conditions, then please look at Randy's comment below to verify your syntax is correct. (Thanks for the example Randy).
Jennifer
Swapnil: Also take a look at the CadCollector api described in this article:
https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS81089
I have used this successfully to retrieve related drawings and wtparts. I haven't actually used it to retrieve the dependents of an asm.
Randy
Hi,
I am not able to use CadCollector. What is the JAR file name for this or how should I reference it?
I am not able to use CadCollector. What is the JAR file name for this or how should I reference it?
Looking up CadCollector in the Windchill java docs or hovering over CadCollector in Eclipse shows this:
com.ptc.windchill.collector.api.cad.CadCollector
and this resides in the codebase/WEB-INF/lib/wncWeb.jar jar file:
root@wct02:/opt/ptc/Windchill/Windchill/codebase/WEB-INF/lib# jar tvf wncWeb.jar | grep -i cadcollector
259 Fri Sep 25 23:44:40 CDT 2015 com/ptc/windchill/collector/api/cad/CadCollector$1.class
1471 Fri Sep 25 23:44:40 CDT 2015 com/ptc/windchill/collector/api/cad/CadCollector$GatherAssociatedParts$1.class
2417 Fri Sep 25 23:44:40 CDT 2015 com/ptc/windchill/collector/api/cad/CadCollector$GatherAssociatedParts.class
1716 Fri Sep 25 23:44:40 CDT 2015 com/ptc/windchill/collector/api/cad/CadCollector$GatherDependents$1.class
2586 Fri Sep 25 23:44:40 CDT 2015 com/ptc/windchill/collector/api/cad/CadCollector$GatherDependents.class
1450 Fri Sep 25 23:44:40 CDT 2015 com/ptc/windchill/collector/api/cad/CadCollector$GatherDrawings$1.class
2361 Fri Sep 25 23:44:40 CDT 2015 com/ptc/windchill/collector/api/cad/CadCollector$GatherDrawings.class
1457 Fri Sep 25 23:44:40 CDT 2015 com/ptc/windchill/collector/api/cad/CadCollector$GatherFamilyGenerics$1.class
2398 Fri Sep 25 23:44:40 CDT 2015 com/ptc/windchill/collector/api/cad/CadCollector$GatherFamilyGenerics.class
1562 Fri Sep 25 23:44:40 CDT 2015 com/ptc/windchill/collector/api/cad/CadCollector$GatherFamilyMembers$1.class
2502 Fri Sep 25 23:44:40 CDT 2015 com/ptc/windchill/collector/api/cad/CadCollector$GatherFamilyMembers.class
2146 Fri Sep 25 23:44:40 CDT 2015 com/ptc/windchill/collector/api/cad/CadCollector$Kind.class
1549 Fri Sep 25 23:44:40 CDT 2015 com/ptc/windchill/collector/api/cad/CadCollector$Type.class
6665 Fri Sep 25 23:44:40 CDT 2015 com/ptc/windchill/collector/api/cad/CadCollector.class
root@wct02:/opt/ptc/Windchill/Windchill/codebase/WEB-INF/lib#