Skip to main content
avillanueva
23-Emerald I
23-Emerald I
February 18, 2022
Solved

Calculated attribute based on existence of Cad Association

  • February 18, 2022
  • 2 replies
  • 4079 views

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.

2 replies

18-Opal
February 19, 2022

@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

d_graham_0-1645250102427.png

And here's the calculated attribute.

d_graham_1-1645250219440.png

Search view of the same part.

d_graham_2-1645250371746.png

 

David

avillanueva
23-Emerald I
23-Emerald I
February 19, 2022

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.

TomU23-Emerald IVAnswer
23-Emerald IV
February 19, 2022
HelesicPetr
22-Sapphire II
22-Sapphire II
February 21, 2022

Hello @avillanueva 

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:

buildTarget@wt.epm.build.EPMBuildRule~buildSource^wt.epm.EPMDocument~name 

 

Best Regards

PetrH

avillanueva
23-Emerald I
23-Emerald I
February 21, 2022

Yes, this is the approach I ended up testing and it does indeed work. I had used !(isNull(alias)) as the formula. However, this is not going to work the way I envisioned it. cs136428 cs350583 . 

avillanueva_0-1645449935406.gif

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.