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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Could you please share API imports

HO_10736653
4-Participant

Could you please share API imports

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

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

6 REPLIES 6

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

Fadel
22-Sapphire I
(To:HelesicPetr)

@HelesicPetr I think he's looking for the packages to import in the old thread  .

Fede
HelesicPetr
21-Topaz II
(To:Fadel)

@Fadel 

The original thread was talking about the changing the type. 

PetrH

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

Thanks @HelesicPetr Got it !!

Top Tags