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

We are happy to announce the new Windchill Customization board! Learn more.

How to get all Attributes of WTObject..?

RS_10128209
10-Marble

How to get all Attributes of WTObject..?

I want to get all attribute Internal name which are related to WTPart or WTDocument

9 REPLIES 9

Take a look at this article

Marco

Thanks @Marco_Tosin 

Plz help me with any API or programatic solution

 

Hi @RS_10128209 

the API does not exists or I don't know it.

 

You need to write code to find TypeDefinition and then get attribute list.

 

Here is a code for you that can work. Just define soft type internal name and it returns what you need.

For me it works

 

try
{
String typeName = "wt.epm.EPMDocument";
QuerySpec queryspec;
queryspec = new QuerySpec();
int idLWCObject = queryspec.appendClassList(LWCTypeDefinition.class, true);
CompositeWhereExpression andCondition = new CompositeWhereExpression(LogicalOperator.AND);
andCondition.append(new SearchCondition(LWCTypeDefinition.class, LWCTypeDefinition.NAME, SearchCondition.LIKE, typeName), new int[]{idLWCObject});
queryspec.appendWhere(andCondition, new int[]{idLWCObject, idLWCObject});
queryspec.appendOrderBy(new OrderBy(new ClassAttribute(LWCTypeDefinition.class, LWCTypeDefinition.MODIFY_TIMESTAMP), false), new int[]{0});

QueryResult qrTypeDef = PersistenceHelper.manager.find((StatementSpec) queryspec);

if (qrTypeDef.hasMoreElements())
{
while (qrTypeDef.hasMoreElements())
{
Persistable persistables[] = (Persistable[]) qrTypeDef.nextElement();
if (persistables.length > 0)
{
LWCTypeDefinition lwcObj = (LWCTypeDefinition) persistables[0];
ArrayList typeList = LWCCommands.getTypeAttributes("OR:" + lwcObj.toString());
for (Object typeAtribs : typeList)
{
if (typeAtribs instanceof AttributeDefinitionReadView)
{
System.out.println(((AttributeDefinitionReadView)typeAtribs).getName());
}
}
}
}
} else
{
System.out.println("nothing");
}

} catch (Exception e)
{
// TODO: handle exception
e.printStackTrace();
}

 

PetrH

Thanks this helps alot and this works to me for windchill 11.0 + 

How do i replace

LWCCommands.getTypeAttributes("OR:" + lwcObj.toString());

 for windchill 10.2 because this package "import com.ptc.core.lwc.client.commands.LWCCommands;" does not exist in windchill.

 

Thanks 

Hi @KU_9877195 

The trouble is that the command really does not exist in the Windchill 10.2.

I do not know if there is another method to do so. I used version 10,2 many many years ago...

You would need to write own function to do same action as is in higher versions

PetrH

Its hard to make function in 10.2 for me because i dont have that much exposure to 10.2 API.

anyways Thanks for guidance.

 

Hello @RS_10128209 

Go to the Type and Attribute Management and check all subtypes what you want.

There you can see all internal names.

HelesicPetr_0-1654688966658.png

 

PetrH

Thanks @HelesicPetr 

but I want solution programatically /using API

There is a page to see them:

Windchill/app/#ptc1/carambola/tools/createtableview/availableAttributes

Add that your you hostname and URL for your server. 

Top Tags