Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
Version: Windchill 12.0
Use Case: hi, I want to delete the part structure details for many of the parts at a time , such that it removes the structure details of the parent part completely for the current revision.
Description:
is there any utility or API to help get the changes updated ? please assist if anything helps
Are you looking at whacking the part from a BOM? That data is housed in the WTPARTUSAGELINK table I believe. normally this is done via the interface via check out and in process since this change should be done under an iteration. Are you looking at removing history? Like all instances of the linkage in the past?
Correct, I want to remove the history of the Bom details like the link needs to be removed.
Yes, there exists an API (PersistenceHelper) but there is likely more involved they just removing this link in all of history. I am sure there are other tables that could be impacted like Occurrences, substitutes, etc. Removing via API at a low level might circumvent some data integrity checks causing missing references and errors in the database records. Not something I would want to try out in production. If possible, better approach if scope is limited is to check out, remove links, check in, then purge history of those items. Its a PITA but its clean.
I don’t believe there is an OOTB utility to do this.
That said, I can write a utility to do it that, given a WTPart version, would remove all Parts in the structure of all iterations of the given WTPart version WITHOUT iterating anything.
My code runs without checkout/checkin.
Note, checkout/checkin would remove the structure from only the newly created checkin iteration.
That’s not going to get the job done for you.
You want the structure removed from ALL iteration of the given version. Therefore, checkout/checkin is NOT the way to get there.
David
I couldn't resist so I wrote a utility to remove all parts from all iterations of a WTPart's structure given the WTPart's number and revision.
Runs in a Windchill shell and is bombproof. 😊
In my example I have WTPart number 0000000003 which has rev A and B.
I want to remove the structure from all iterations of Rev A only. There are six iterations of Rev A
Iteration 6
Iteration 5
Iterations 4, 3 and 2 also have a part structure.
I run the utility in a Windchill shell entering the WTPart's number and revision.
After running note that no WTParts were iterated, but their structures have been completely removed.
Here's iteration 6 after running the utility.
Here's iteration 5 after running the utility.
All gone. 😊
Same is true for the part structures of iterations 4, 3 and 2, all gone.
@d_graham could you please explain this use case and share the code snippet if possible 😊 thanks.
@ashiq_097 , I think I already explained exactly what the code does so I'm a bit confused about your asking to "explain this use case".
That said, again, given two arguments, a number and a revision, all iterations of that WTPart's revision have their Part Structure removed.
Isn't that what your post asked for?
The utility I wrote does not reclusively go through the entire structure, although that would be easy enough to write. It only does the top-level structure for the number and revision entered.
@d_graham can you explain like which methods do need to utilize to get the structure of the part removed ?
private static void removePartStructure(WTPart part) throws WTException {
QueryResult usageLinks = PersistenceHelper.manager.navigate(part, "uses", WTPartUsageLink.class);
while (usageLinks.hasMoreElements()) {
WTPartUsageLink usageLink = (WTPartUsageLink) usageLinks.nextElement(); PersistenceHelper.manager.delete(usageLink); }
this will work right
No it won’t because the part is not checked out.
The conundrum is if you checkout/checkin only the newly checked in iteration will be free of the link. This doesn’t really help because you want all iterations of the specified revision to be free of the links.
what logic can we get add here or how can we implement to do this in a code ?