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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

How to update quantity attribute of Part Structure through api?

rkumar-10
5-Regular Member

How to update quantity attribute of Part Structure through api?

How to update quantity attribute of Part Structure through api.

2 REPLIES 2

Hello Rakesh Kumar‌,

You can try below code snippet:

public class UpdateLineNumber implements RemoteAccess

{

  public static void main (String a[]) throws WTException, WTPropertyVetoException, RemoteException, InvocationTargetException

  {

  RemoteMethodServer rms = RemoteMethodServer.getDefault();

  rms.setUserName("wcadmin");

  rms.setPassword("ts");

  Class[] arg_type = {};

  Object[] ar = {};

  rms.invoke("updateLineNumberUS37", "ext.UpdateLineNumber", null, arg_type, ar);

  }

  public static void updateLineNumberUS37() throws WTException, WTPropertyVetoException, IOException

  {

  String partOid = "VR:wt.part.WTPart:657087";

  ReferenceFactory rf = new ReferenceFactory();

  WTReference obj = (WTReference) rf.getReference(partOid);

  WTPart part = (WTPart)obj.getObject();

  CheckoutLink col = WorkInProgressHelper.service.checkout(part, (Folder)WorkInProgressHelper.service.getCheckoutFolder(), "MG");

  WTPart prt =(WTPart)col.getWorkingCopy();

  QueryResult qr = wt.part.WTPartHelper.service.getUsesWTPartMasters(prt);

  while(qr.hasMoreElements())

  {

  WTPartUsageLink ul = (WTPartUsageLink)qr.nextElement();

  Quantity q = new Quantity();

  double quantity = 12;

  q.setAmount(quantity);

  ul.setQuantity(q);

  PersistenceServerHelper.manager.update(ul);

  PersistenceHelper.manager.save(prt);

  }

  // Check in part

  WorkInProgressHelper.service.checkin(prt,"cc") ;

  System.out.println("\n finihsed");

  }

}

Quantity.png

I hope this helps you.

Regards,

Shirish

rkumar-10
5-Regular Member
(To:ShirishMorkhade)

Hi Shirish

Thanks for the help.

//Rakesh

Top Tags