Skip to main content
1-Visitor
July 27, 2015
Solved

Rename a WT part using Import from Spreadhseet

  • July 27, 2015
  • 4 replies
  • 5128 views

Dear Experts,


I am trying to rename a WT part name using Import from spreadsheet functionality even though I receive a message stating that validation is succeeded, I dont see the change in the name of the Part


Can some one suggest a way to fix this


Currently I am using WC 10.1, M040


Thanks,


Athmanand

Best answer by BineshKumar1

I don't think import from spreadsheet or loadfromfile could help in renaming wtparts. You could modify structure by adding or renaming components. You can write a custom utility to do that. By the way what does your methodserver log file say?

Thanks

Binesh

Barry Wehmiller

4 replies

1-Visitor
July 27, 2015

I don't think import from spreadsheet or loadfromfile could help in renaming wtparts. You could modify structure by adding or renaming components. You can write a custom utility to do that. By the way what does your methodserver log file say?

Thanks

Binesh

Barry Wehmiller

Anand1-VisitorAuthor
1-Visitor
July 27, 2015

Hello Binesh,

Thanks for the clarification

Completely forgot about method server , Let me check it

Thanks,

Athmanand

1-Visitor
July 27, 2015

Athmanand,

if you want to write custom utility then below are some sample API which u need to use

public static void renameWTPart(String[] array) {

// Read csv file to get the original number, new number and name,

  String orgNumber = array[1];

  String oldName = array[2];

  String newNumber = array[3];

  String newName = array[4];

  WTPartMaster partMaster = null;

  WTPartMaster dupMaster = null;

  String message;

  try {

  // Search for existing part

  partMaster = (WTPartMaster) getWTPartMaster(orgNumber);

  if (partMaster == null) {

  message = "ERROR: Can not find WTPart: " + orgNumber;

  addToLogs(message, logFile);

  // If we always return true then the load will continue

  return;

  }

  //search for with new WTPart number incase if part already exist

  dupMaster = (WTPartMaster) getWTPartMaster(newNumber);

  if (dupMaster != null) {

  message = "ERROR: WTPart already exists in database: " + newNumber;

  addToLogs(message, logFile);

  // If we always return true then the load will continue

  return;

  }

  try {

  // change WTPart identiry i.e. rename

  WTPartMasterIdentity partIdentity = (WTPartMasterIdentity) partMaster.getIdentificationObject();

  orgNumber = partIdentity.getNumber();

  partIdentity.setNumber(newNumber);

  partIdentity.setName(newName);

  IdentityHelper.service.changeIdentity(partMaster, partIdentity);

  PersistenceHelper.manager.refresh(partMaster);

  message = "SUCCESS: Renamed successfully: " + orgNumber + " to " + newNumber;

  addToLogs(message, logFile);

  }// try

  catch (WTException ex) {

  message = "FAIL: Rename error: " + orgNumber + " to " + newNumber + ": " + ex;

  addToLogs(message, logFile);

  // If we always return true then the load will continue

  return;

  }

  }// try

  catch (Exception ex) {

  message = "FAIL: Rename error: " + orgNumber + " to " + newNumber + ": " + ex;

  addToLogs(message, logFile);

  }// catch

  }

  public static WTPartMaster getWTPartMaster(String orgNumber) {

  WTPartMaster wtPartMaster = null;

  QuerySpec qs = null;

  try {

  qs = new QuerySpec(WTPartMaster.class);

  SearchCondition sc1 = new SearchCondition(WTPartMaster.class, "number", "=", orgNumber);

  qs.appendWhere(sc1);

  QueryResult qr = PersistenceHelper.manager.find(qs);

  if (qr.size() > 0) {

  wtPartMaster = (WTPartMaster) qr.nextElement()

  } catch (WTException ex) {

  ex.printStackTrace();

  }

  return wtPartMaster;

  }

Hope it helps !!!

Thanks

Shreyas

1-Visitor
July 27, 2015

I have a utility that can mass rename WTParts in Windchill.  It can do either name, number, or both.  It is run from a WC shell and the input is a simple CSV file.

If you're looking to do a large mass rename, let me know if you're interested and we may be able to work something out.

11-Garnet
September 9, 2021

Hi

Is there any OOTB rename utility for mass rename for WTPart?

If not pls share your utility

 

Thanks

Afroz

avillanueva
23-Emerald I
23-Emerald I
September 9, 2021

I believe the import from spreadsheet will rename objects but also iterates them.

Anand1-VisitorAuthor
1-Visitor
July 29, 2015

Dear Shreyas,

Thanks for sharing the details,

@ Bob is your utility similar to the one shared by Shreyas

Thanks,

Athmanand

1-Visitor
July 29, 2015

It's a bit simpler in terms of the setup, but yes the concept is the same.

Anand1-VisitorAuthor
1-Visitor
July 29, 2015

@ Binesh,

You are right,

Column Header

Required

Editable on reimport

Description

Action

Yes

Actions include Add or Delete.

Type

Yes

No, class type cannot be changed for existing parts

Class type, logical identifier, or an external type ID. For example:

  • for OEM parts, use wt.part.WTPart
  • for manufacturer parts, use com.ptc.windchill.suma.part.ManufacturerPart
  • for vendor parts, use com.ptc.windchill.suma.part.VendorPart

Note

The class types can be defined in the logical identifiers file with an alias. For example, wt.part.WTPART=part. Part, Manufacturer Part and Vendor part will be included in the logical id file.

Name

Yes

No, part name cannot be changed for existing parts

Part name.

1-Visitor
July 29, 2015

Thanks Anand for confirmation.