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 change the type of existing part.

apatil-2
1-Newbie

How to change the type of existing part.

Hi,

I have a WTPart and is associated with an EPM Document. Now I want to change the type of Part its subtype.

How can I achieve it?

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
BenPerry
13-Aquamarine
(To:apatil-2)

Can you expand on the requirement? You want to do this via API like Sudeep has suggested? Or by using some type of utility? Or something else?

There are existing articles on using a command line tool. It generates some SQL code. But the SQL code it generates will change the type of all WTPart objects. You'll need to modify the SQL for only that single WTPart if you choose this method.

https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS7287

https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS52368

View solution in original post

8 REPLIES 8

Hi Avinash,

You can do this using code :

TypeHelper.setType((Persistable)partObj, TypeHelper.getTypeIdentifier("internal_name"));

PersistenceServerHelper.update(partObj);

partObj = (WTPart)PersistenceHelper.manager.refresh(partObj);

Hope this helps.

Regards

Sudeep

I've just tried Sudeep Pai's code and it seems to work perfectly. Thank you!

I plan to use it with WTParts and prefer it over the SQL tool because it gives me better control over which part to change and which not.

Has anyone experience with this solution? Any side-effects to be aware of?

(Obviously lifecycle, attributes, versioning schema have to be taken into account, that's ok.)

I've been using this since long time. But you need to pay attention to two things:

- If the target type has less or different attributes set, you won't be able to remove them afterwards and you also will find them with solr. So you need to clean them before changing the type

- If you need the history you can change only the latest iteration or you also can change all iteration

Thanks for your answer!

- The first issue is no problem as I plan to move to a subtype anyway. So all IBAs on top level are there as well (plus more). But I have to move those IBAs to the sublevel afterwards as well. Which can be done by the TypeAttributeMoevTool by PTC. Thanks for the tip with SolR. Wouldn't have thought of that.

- Want to move all iterations. Will check the behavior, thanks.

BenPerry
13-Aquamarine
(To:apatil-2)

Can you expand on the requirement? You want to do this via API like Sudeep has suggested? Or by using some type of utility? Or something else?

There are existing articles on using a command line tool. It generates some SQL code. But the SQL code it generates will change the type of all WTPart objects. You'll need to modify the SQL for only that single WTPart if you choose this method.

https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS7287

https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS52368

Hi all,

I want to do it in UI (any OOTB functionality).

Because a user wrongly associated many of those.

Any how I given him the workaround to use edit association to remove existing part and do association again (create new part) and its working.

And old part we are deleting.

I wanted to know can we change the type ? is there any setting ? because this is common mistake and can happen to many customers.

Thanks,

BenPerry
13-Aquamarine
(To:apatil-2)

There is not something in the UI where you can change the type of an object. It must be done through the steps outlined in the duplicate articles I listed above (direct database edit). Furthermore, additional conditions will need to be added to the SQL code to ensure you only change the type of specific objects - not all of the objects.

Thank you Ben and Sudeep for your responses.

Top Tags