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

We are happy to announce the new Windchill Customization board! Learn more.

How to attach a Part to a Document using Windchill API ?

aachanta
13-Aquamarine

How to attach a Part to a Document using Windchill API ?

Hi All,

How do we attach a WTPart or a WTDocument to a WTdocument in the related objects using API ?

Can anyone tell like which API is used exactly ?

Thanks in Advance,

Aditya

9 REPLIES 9
aachanta
13-Aquamarine
(To:aachanta)

Like inserting a document in the sense.

WTDocument -> Information Page -> Related Objects ->

So how do we add a Where Used Document  or References Document or Referenced By Documents or Parts using Windchill API.

Kindly let me know the solution if anyone is aware of it.

Thanks and Regards,

Aditya Achanta

Please refer to the API Below :-

ReferencedBy

WTDocument workable = (WTDocument)WorkInProgressHelper.service.workingCopyOf(doc);
wt.doc.WTDocumentDependencyLink  dependlnk= wt.doc.WTDocumentDependencyLink.newWTDocumentDependencyLink(workable,referenceddoc);
PersistenceServerHelper.manager.save(dependlnk);

UsedBy

WTDocumentUsageLink usage_link = WTDocumentUsageLink.newWTDocumentUsageLink(parent_document,(WTDocumentMaster)child_document.getMaster());
usage_link.setStructureOrder(0);
PersistenceServerHelper.manager.save(usage_link);

Thanks,

Aditya

aachanta
13-Aquamarine
(To:asingh)

Hi Aditya,

Thank you.

But how about attaching a WTPart -DESCRIBES PARTS for a WTDocument in Related Objects ?

Can you please suggest API even for that ?

Thanks and Regards,

Aditya

Hi Aditya,

Please refer to the API below for DescribeBy link between WTPart and WTDocument.

if ( !(checkInOutTaskLogic.isWorkingCopy(wtpart)) ){

            

             workingcopyPart =(WTPart)WorkInProgressHelper.service.checkout((WTPart)wtpart,WorkInProgressHelper.service.getCheckoutFolder(),null).getWorkingCopy();

         }

WTPartDescribeLink describeLink=WTPartDescribeLink.newWTPartDescribeLink(workingcopyPart,docObj);

describeLink = (WTPartDescribeLink)PersistenceHelper.manager.save(describeLink);

If you feel this post has answered your query, please mark it as correct answer, so that others can also rip benefit out of this.

Thanks,

Aditya

aachanta
13-Aquamarine
(To:asingh)

Hi Aditya,

Thanks a lot for the logic. It has been marked as correct.

What is checkInOutTaskLogic ?  Is it a document name. I haven't understood like what it is. So can you please elaborate the code to some extent if that is possible.

Thanks and Regards,

Aditya

hpali
1-Newbie
(To:asingh)

Hi Aditya,

The link created is correct.However when i try to obtain a working copy using this i get error taht part cannot be checkedout as it is not the latest iteration.I used below :

WTPart workingcopyPart = null;

  if(!WorkInProgressHelper.isWorkingCopy(partObj))

  {System.out.println("Not a working copy"+docmaster.getName());

  workingcopyPart =(WTPart) WorkInProgressHelper.service.checkout((WTPart)partObj,WorkInProgressHelper.service.getCheckoutFolder(),null).getWorkingCopy();

  }


It is coming inside the loop and then  giving error that part cannot be checkedout as it is not the latest iteration.

Any idea?

Hi Aditya,

Sorry for the late response, you can probably use :-

if(!WorkInProgressHelper.isWorkingCopy(wtpart))

this checks if the WTPart instance under consideration is the workingCopy, if not then Checkout.

Thanks,

Aditya

aachanta
13-Aquamarine
(To:asingh)

Thanks Aditya.

I got it.

Best Regards,

Aditya

Hi Aditya,

Is there any other way that we can create link without checking out the WTPart

Regards,

Chetan

Top Tags