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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

Mass attribute relations

khimani_mohiki
14-Alexandrite

Mass attribute relations

I am investigating using Mass properties from Creo in Windchill, at the start of a project we want to use the calculated mass, then as we get real parts and weigh them, we want to enter this into the Alternate Mass PRO_MP_ALT_MASS and use that in Windchill, but we don't want to have 2 different mass attributes on each CAD document as we want to compare CAD mass (calculated or alternate) to an target mass attribute in the WT part.

 

So I have created a new parameter called "MASS" and I want this parameter to equal the value of PRO_MP_MASS or the value of PRO_MP_ALT_MASS but only if it does not equal zero.

I struggling to write this and get it to work in Relations, can anyone help?

1 ACCEPTED SOLUTION

Accepted Solutions

This worked for me:

 

if pro_mp_alt_mass <> 0
weight = pro_mp_alt_mass
else
weight=pro_mp_mass
endif

 

The key is to have the pro_mp_alt_mass value entered for your part. If it is blank, then the relations fail.

Add pro_mp_alt_mass to your model tree and then enter the value. I tested it with both a 0.0 and a positive value, 7.25, for my test part.

 

View solution in original post

20 REPLIES 20

I don't know if you're having difficulties because you're trying to use built-in things like PRO_MP_MASS, but the relations code should be relatively simple, something like:

MASS = PRO_MP_MASS
IF PRO_MP_ALT_MASS > 0.0
  MASS = PRO_MP_ALT_MASS
ENDIF

If I try to verify with neither parameters having a value I get the following errors:

MASS = PRO_MP_MASS
errorInvalid data type combination at right side of expression
IF PRO_MP_ALT_MASS > 0.0
errorLeft and right sides are incompatible
  MASS = PRO_MP_ALT_MASS
ENDIF

Does it need to check the parameters are not null before the If statement? 

TomU
23-Emerald IV
(To:khimani_mohiki)

BenLoosli
23-Emerald II
(To:TomU)

The If Exists, at least in this context,  does not work because the parameter does exist as it is a system parameter.

I have not found a way to check if the pro_mp_alt_mass parameter is blank and act upon that information. I have only gotten results if I set pro_mp_alt_mass to some value.

KenFarley
21-Topaz I
(To:TomU)

I tried this and it still barfed up error codes.

IF EXISTS ( "myVariable" )
  do stuff with myVariable
ENDIF

Always fails if the stuff I want to do involves the (possibly nonexistant) parameter.

I tried out the method I suggested on an existing part, and it worked, but didn't work for a fresh new part, even after I had done a mass properties analysis, which was giving back nonzero values for the mass. This is an oddity, to be sure.

 

 

TomU
23-Emerald IV
(To:KenFarley)

It used to be that this was only valid in repeat region relations (in a drawing).  At some point PTC extended it out to relations in other areas (parts, assemblies, etc.) but I'm not sure how well they actually tested it...

Do you have the parameter MASS already created?

 

Hi Ben, yes I already have the MASS parameter created, I have tried the "if exists" method but I still get errors, I think perhaps although both parameters (PRO_MP_MASS & PRO_MP_ALT_MASS) exist in the template they don't have a value, so my relation is trying to set MASS equal to a null value.

This worked for me:

 

if pro_mp_alt_mass <> 0
weight = pro_mp_alt_mass
else
weight=pro_mp_mass
endif

 

The key is to have the pro_mp_alt_mass value entered for your part. If it is blank, then the relations fail.

Add pro_mp_alt_mass to your model tree and then enter the value. I tested it with both a 0.0 and a positive value, 7.25, for my test part.

 

Yes that worked for me, I left the density as default (1.0) and calculated mass properties which gave PRO_MP_MASS a value of 0.0, then I manually gave PRO_MP_ALT_MASS a value of 0.0. I will have to save the template in this state.

 

Out of interest is there anyway to check for parameters with null value?

TomU
23-Emerald IV
(To:khimani_mohiki)

A parameter can't be null.  If it exists it will have a value.  String parameters will be empty strings "" and real values will default to zero.

BenLoosli
23-Emerald II
(To:TomU)

That is what I thought, too, but my relation code proves otherwise.

When you add mp_pro_alt_mass to the model tree, it is blank.

My weight code fails until I enter 0 or some other value for mp_pro_alt_mass in the parameter field.

TomU
23-Emerald IV
(To:BenLoosli)

Interesting.  Did you notice that none of the mass property parameters have a type?  Maybe a case is in order...

TomU
23-Emerald IV
(To:BenLoosli)

Prior to a value being assigned they cannot be accessed by J-Link either.  Weird.

 

"By default, mass property parameters do exist in the models, but have no value assigned."

 

https://www.ptc.com/en/support/article?n=CS11140

 

 

TomU
23-Emerald IV
(To:BenLoosli)

I opened a case.  We'll see what tech support says.

 

A few more interesting articles:

TomU
23-Emerald IV
(To:TomU)

After going back and forth with tech support for a while, the conclusion is that it's not possible to determine if this system parameter (PRO_MP_ALT_MASS) has a value assigned to it or not via relations.  IF EXISTS() will always return true since the parameter does exist, but using standard comparison operators in relations statements will fail if a value has not been assigned to the parameter.  Creo allowing system parameters to have NULL values causes problems because there is no way for relations to check for those NULL values.

 

After checking with PTC R&D, it has been determined that the functionality you are looking for is not currently the part of the application specification and the relation will fail if the parameter has undefined value.

 

However, if you would like this feature to be implemented in a future release, I would recommend filing a new Product Idea (formerly known as Enhancement Requests) via the PTC Website for this functionality: https://www.ptc.com/appserver/cs/misc/PTC_Product_Ideas.jsp

 

 

RPN
17-Peridot
17-Peridot
(To:BenLoosli)

Alternate mass properties are a very important feature to maintain easily the weight of big assemblies, and to have an accurate display of this value in drawings for single parts.

 

The most important attribute for this feature is PRO_MP_SOURCE. The value of this string attribute can be one of: 

 

GEOMETRY, PARAMETERS, FILE or FULLY ASSIGNED.

 

Your relation must valide first where the source is. Geometry act like the default, value is driven by 3D Volumen and MP Density. 

 

You do not need to add a relation like I saw in all in the examples.

 

weight = pro_mp_mass

 

This is all you need, if you don‘t want the PTC‘s default name ,pro_mp_mass‘. Based on my toolkit experience with this attribute, I guess you can‘t initialize this per relation. I thing this makes no sense.

 

 PRO_MP_SOURCE will decide where the final value comes from.

 

Make it simple and start with a model. I see no reason why a model can’t have the correct weight. But it will appear, that the reported value is incorrect. 

 

Your model is not really a twin. What to do, two options here ...

 

  1. change your density, so your weight is now 100% correct
  2. Change  PRO_MP_SOURCE to Parameters and assigned an alternate density, if you can‘t change the official one, due to some reports dependent on the official density.

This has no effect for center of gravity and most of the other parameters.

 

Done! 

 

Now Creo will report for your model the correct weight and will use that weight in each assembly on reports.

 

For Assemblies this is even more handy. 

 

If a sub assembly weight in Creo is invalid, change PRO_MP_SOURCE to Parameters as well and enter your 100% weight at  PRO_MP_ALT_MASS. 

 

Done

 

Pro 

All Assemblies using this sub assemblies will report the weight based on you new value, no further action required (bottom to top).

 

Con

The value is no longer automatically updated (was wrong, anyway)

 

 

If you use FULLY ASSIGNED as your source, you have to enter a value for each alternate parameter to avoid an error. By File your Mass property file must be maintained.

 

 

Even in Toolkit, the alternate Parameter a way tricky, because of the strange type, spend some time to initialize them proper 🙂 Magic NULL

 

Have fun ...

 

khimani_mohiki
14-Alexandrite
(To:RPN)

OK, so I think I understand, we don't actually need to make any relations, instead we should enter the measured mass in PRO_MP_ALT_MASS and change the parameter PRO_MP_SOURCE = PARAMETERS then PRO_MP_MASS will be updated to equal PRO_MP_ALT_MASS.

 

The only snag I found is that after changing PRO_MP_SOURCE = PARAMETERS you then have to update mass properties in order for PRO_MP_MASS to update, setting mass_property_calculate to automatic will update PRO_MP_MASS on regen but at present we have ours set to by_request.

 

Also we are asking the users to do 2 new things, set the value of PRO_MP_SOURCE and enter a value in PRO_MP_ALT_MASS

 

If we use the relations method we can leave the mass properties calculation set to by_request and the only extra step for the user is to enter a value in PRO_MP_ALT_MASS.

 

What is the effect of setting mass_property_calculate = automatic ?

If you change this to auto, you may end up, in updating or creating new requested parameter for older components, where you don’t have this. E.g old library components, and this may be tricky if you use Windchill. For single components make sure your density will set the perfect weight. You can easily have a small interface for this. For assemblies you ask the user to change the source and mass, or doing both by a small interface as well.

 

I would not set the source for components to be ‚parameter‘, only for assemblies, and here maybe just before release. In creo you have both reports available. Note: I can’t remember if you can reset this alternate mass parameter back to be void. I would not change my template to have them all included. At all it is a nice feature, which allows you to have proper values at assembly level. 

khimani_mohiki
14-Alexandrite
(To:RPN)

Thanks a lot for all your contributions, I have 1 additional question, when we designate a mass attribute into Windchill, the calculated mass has 13 decimal places and is displayed in base-10 format as below:

 

I would like it to display to 3 decimal places with leading zero, as this is how we will enter the estimated mass attribute in the WT part.

 

I know there are Real to String conversion relations but Im not sure how could I combine this with my relation:

IF PRO_MP_ALT_MASS != 0
MASS = PRO_MP_ALT_MASS
ELSE
MASS = PRO_MP_MASS
ENDIF

 

Top Tags