Curious if anyone has done this. It would be nice in PartsLink as users search for parts to know if there already exists a CAD model for that Part. This can be a simple Boolean but I am not sure alias or calculated attributes can work here. Has anyone does something like this or have a similar approach?
I am sure a listener can be used to calculate this value as the Part is checked in. Since CAD associations need to be modified with Part modification, it would be straight forward to add in this value setting on the way in. Listeners can get complicated when the Part object changes midstream causing stale object errors.
Solved! Go to Solution.
@avillanueva , hi
Yes, this is doable
You can pass the attributes that hold the values of number, revision, iteration to a custom method which then find the WTPart.
You can pass the attribute that holds the view too it that required.
Once the method has the WTPart it can determine if it's linked to a CAD Document by navigating any links you want.
The return value cannot be a Boolean however, Booleans are not allowed in the return value for calculated attributes (not sure why PTC does not allow this but they don't).
The return value can be a String. So, maybe return String.valueOf(Boolean.TRUE).
Note: In the type manager we see lots of attributes but those are ONLY the ones PTC chose to display OOTB. There are many more attributes available that can be used. For example the attribute for the iteration value is not displayed in type manager but it exists and can be used to run a calculation.
Here's a WTPart that's linked to a CAD Doc. The Part uses a Calculated attribute LINKED_CADDOCUMENT
And here's the calculated attribute.
Search view of the same part.
Intrigued but I think you missed explaining a step. How do you call this custom method or one that I can find in the API. I assume you mean I can pass the attributes of the WTPart itself (iteration ID or IDA2A2 might be easier) but then what. I did not see anywhere in the formulas for calculated attributes that allowed you to call custom methods.
The link @TomU post tells the story. Look at that. If you have any question, give me a call. You've got my number.
To be clear you don't pass database column names. You need to pass the attribute name that corresponds to the database column name.
I would agree passing the attribute name that corresponds to the id, ida2a2, would be simple. For the example I posted I used number and version only because those attributes are displayed in the type manager whereas the attribute name for ida2a2 is not. So, I thought easier for others to follow along.
HINT: The first arg I pass to is the name of the calculated attribute as a String.
Why do I do that you ask? Good question.
I do it so that I can use an if statement in my "execute" method that determine which code to run. I might have many methods in the class that are used to calculate several calculate attributes. The String I pass is used to determine which code to run. So, one class with lots of methods that do different thing and maybe return different object types.
Thanks both of you. I did not see that in my searches. I did find "buildStatus" and possibly another attribute that can be used for a stand in for a custom method but I have a clear path now either way. Thanks again.
this is something I've been looking for a very long while. But I don't understand the "solution" how it is really done practival. Afterwards I wanted to use the traffic light to show if there is a model available or not in the classification or search results.
How is the attribute 'LINKED_CADDOCUMENT" built inside Windchill because the other replies could also have been chinese for me?
You can do it without creating own class.
Just Create alias attribute on WTpart to get number of CAD and then create Calculate attribute to show True if the alias attribute has any value.
I did it for MPMProcessPlan.
alias attribute mapping: processPlanLink~processPlan~name
calculated attribute formula: (isNull(TP_ALIAS)) ? "False" : "True"
for CAD there is following mapping:
My goal was to have this as a classification attribute so users can filter on Parts with CAD models. This would not be something that they can search on using classification search.
Is it possible to create the similar alias attribute for fetching CAD Drawing number on CAD Document?
(CAD Document is linked to CAD Drawing as referenced by)