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

Mass attribute relations

SOLVED
Highlighted

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

Re: Mass attribute relations

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.

 

20 REPLIES 20

Re: Mass attribute relations

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

Re: Mass attribute relations

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? 

Re: Mass attribute relations

Try seeing if the parameter exists first.

IF EXISTS("PRO_MP_MASS")
   /* Do Stuff
ENDIF

http://support.ptc.com/help/creo/creo_pma/usascii/#page/fundamentals%2Ffundamentals%2Ffund_seven_sub...

Re: Mass attribute relations

Do you have the parameter MASS already created?

 

Re: Mass attribute relations

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.

Re: Mass attribute relations

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.

 

Re: Mass attribute relations

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?

Re: Mass attribute relations

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.

Re: Mass attribute relations

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.