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

How to retrieve the values of Classification Attributes for WTParts?

Highlighted

How to retrieve the values of Classification Attributes for WTParts?

Hello All,

I trying to write a Query report to list all the values of Classification Attributes for all the WTParts. I followed PTC solution CS220979, I'm only getting the Attribute Names of all the WTParts. The values of the Attributes are not generated. Is there something I'm missing to add in the query?

Any suggestions would be helpful.

Thanks,

Kiran

2 REPLIES 2

Re: How to retrieve the values of Classification Attributes for WTParts?

You should join this group Reporting and also read this article Resource for reporting

In the document there are lots of report ready to use and I think you can find what you're looking for.

Marco

Marco

Re: How to retrieve the values of Classification Attributes for WTParts?

1. You can fetch the classification node on a WTPart by simply fetching the IBA value of classification attribute. Below snippet can be used to fetch the internal name of classification node:

String node = getibaValue( <WTPart Object>, <Internal name of Classification Binding attribute>);

public static String getibaValue(Persistable obj, String id) {
 
  try {

   // fetching persistable object
   final PersistableAdapter obj2 = new PersistableAdapter(obj, null,
     Locale.US, null);
   obj2.load(id);

   String value = obj2.getAsString(id).toString();

   return value;
  } catch (WTException e) {
   // return - if exception
   return "";
  }

}

2. Now we need to fetch all the classification attributes corresponding to the internal name of node which we have fetched in step 1. Below code snippet returns a list with all classification attributes.

public static List<String> getPartsLinkIBA(String node)

throws WTException {

 

List<String> l1 = new ArrayList<String>();

final TypeDefinitionReadView localTypeDefinitionReadView = TypeDefinitionServiceHelper.service

.getTypeDefView(AttributeTemplateFlavor.LWCSTRUCT,

CsmConstants.NAMESPACE, node);

 

if (localTypeDefinitionReadView != null) {

final Collection<AttributeDefinitionReadView> x = localTypeDefinitionReadView

final Iterator<AttributeDefinitionReadView> it = x.iterator();

// getting all the attributes internal name

while (it.hasNext()) {

 

final Object object = (Object) it.next();

final AttributeDefinitionReadView adrv = (AttributeDefinitionReadView) object;

l1.add(adrv.getName());

 

   /*

 

return l1;

}

3. Once you have the WTPart Object and all the classification attributes (List in step 2), you can fetch the values of all the attributes by using any method like Persistable Adapter, IBAHolder, etc.

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum! ______________________________ Check out the Windchill Tips Board! We're talking about Whirlpool's use of digital twin, augmented reality, and data-driven design!

The NAVIGATE WORKING GROUP is here! Come innovate with PTC!

Sign up for a Working Group