Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
Hi All,
I want to list out all Soft types of WTDocumnet by using Windchill API's.
I have created few soft types from type and attribute manager, now my requirement is to show all the soft types of WTDocumnet in a list by using API.
My soft types from type and attribute manager as shown here,
Kindly let me know the related API for this.
Thanks,
Vivek
I belief it should work like this. I copied different methods to one. So you should get an idea.
try {
TypeIdentifier localTypeIdentifier = null;
GetTypeIdentifierCommand localGetTypeIdentifierCommand = new GetTypeIdentifierCommand();
localGetTypeIdentifierCommand.setTypename(WTDocument.class.getName());
localGetTypeIdentifierCommand.setLocale(SessionHelper.getLocale());
localGetTypeIdentifierCommand = (GetTypeIdentifierCommand) localGetTypeIdentifierCommand.execute();
TypeIdentifier[] typeIdentifiers = localGetTypeIdentifierCommand.getAnswer();
if ((typeIdentifiers != null) && (typeIdentifiers.length > 0)) {
localTypeIdentifier = typeIdentifiers[0];
logger.debug("Found type <" + localTypeIdentifier.getTypename() + "> for class <" + WTDocument.class.getName() + ">");
} else {
logger.debug("Didn't find type identifier for class <" + WTDocument.class.getName() + ">");
}
if (localTypeIdentifier != null) {
if (TYPE_MODEL.isInstantiable(localTypeIdentifier)) {
String sDisplayName = TypedUtilityServiceHelper.service.getLocalizedTypeName(localTypeIdentifier, SessionHelper.getLocale());
logger.debug("found sybtype <" + localTypeIdentifier.getTypename() + "> - " + sDisplayName + " for type <" + localTypeIdentifier.getTypename() + ">");
}
TypeIdentifier[] arrayOfTypeIdentifier = TYPE_MODEL.getInstantiableDescendants(localTypeIdentifier, (TypeInstanceIdentifier) null);
if ((arrayOfTypeIdentifier != null) && (arrayOfTypeIdentifier.length > 0)) {
for (TypeIdentifier arrayOfTypeIdentifier1 : arrayOfTypeIdentifier) {
String sDisplayName = TypedUtilityServiceHelper.service.getLocalizedTypeName(arrayOfTypeIdentifier1, SessionHelper.getLocale());
logger.debug("found sybtype <" + arrayOfTypeIdentifier1.getTypename() + "> - " + sDisplayName + " for type <" + localTypeIdentifier.getTypename() + ">");
}
}
}
} catch (WTException | RemoteException ex) {
logger.error(ex);
} catch (WTPropertyVetoException e) {
e.printStackTrace();
}
hi bjorn thanks for the reply.
in the above image how can we get the "TYPE_MODEL" value?
static {
TYPE_MODEL = (TypeModel) DefaultServiceProvider.getService(TypeModel.class, null);
}
did it work?
try using this API:
TypeIdentifier tiCheck = ClientTypedUtility.getTypeIdentifier("typeName");
TypedUtility.getSubtypes(tiCheck, true, true, null);