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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

How to get all soft types of WTDocument by using API ?

vuchekar
9-Granite

How to get all soft types of WTDocument by using API ?

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,

Soft types.jpg

Kindly let me know the related API for this.

Thanks,

Vivek

5 REPLIES 5

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();

}

vmhala
6-Contributor
(To:BjoernRueegg)

hi bjorn thanks for the reply.

10-10-2016 4-04-18 PM.jpg

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);

Top Tags