Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
Could you please share API imports used for same. It will be helpful.
Reference topic link - https://community.ptc.com/t5/Windchill/Change-Object-type-using-API/m-p/302875#M35609
Solved! Go to Solution.
Hi @HO_10736653
In your case there can be many cases. Something is wrong in definition. It could be good to know a background and any code you use.
For example you are traying to change an Object type to something that is not possible.
Here is an example with explanation
The point is that you can not change a type from WTDocument to WTPart
You can change a type from WTDocument to subtype of WTDocument.
in your case you need to know what type is your Object.
From the error I can see that You try to retype Object to something that is not possible.
another example.
Cat and Dog are Pets. But you can not change a type Pet to a Dog if the type was Cat (originally crated as a Cat) ...
PetrH
Hi @HO_10736653
What API are you looking for?
If you create WTPart or WTDoc set the type with setTypeDefinitionReference method before first save
example
TypeDefinitionReference tdr = TypedUtility.getTypeDefinitionReference("cz.aveng.MYDOCTYPE");
try
{
doc.setTypeDefinitionReference(tdr);
} catch (WTPropertyVetoException e)
{
e.printStackTrace();
}
PetrH
@HelesicPetr I think he's looking for the packages to import in the old thread .
Thanks @HelesicPetr , for this solution. But I was trying type casting for Action Item creating a data utility. Getting below error :
java.lang.ClassCastException: class com.ptc.core.meta.type.common.impl.DefaultTypeInstance cannot be cast to class wt.meeting.actionitem.DiscreteActionItem (com.ptc.core.meta.type.common.impl.DefaultTypeInstance and wt.meeting.actionitem.DiscreteActionItem are in unnamed module of loader 'app') java.lang.ClassCastException: class com.ptc.core.meta.type.common.impl.DefaultTypeInstance cannot be cast to class wt.meeting.actionitem.DiscreteActionItem (com.ptc.core.meta.type.common.impl.DefaultTypeInstance and wt.meeting.actionitem.DiscreteActionItem are in unnamed module of loader 'app'
I am trying to cast Object type to DiscreteActionItem.
Hi @HO_10736653
In your case there can be many cases. Something is wrong in definition. It could be good to know a background and any code you use.
For example you are traying to change an Object type to something that is not possible.
Here is an example with explanation
The point is that you can not change a type from WTDocument to WTPart
You can change a type from WTDocument to subtype of WTDocument.
in your case you need to know what type is your Object.
From the error I can see that You try to retype Object to something that is not possible.
another example.
Cat and Dog are Pets. But you can not change a type Pet to a Dog if the type was Cat (originally crated as a Cat) ...
PetrH