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

Updating mass properties using JLink

ptc-5729728
1-Newbie

Updating mass properties using JLink

I'm trying to update/override the mass properties of a model from an application using the asynchronous J-Link API. I created a method which takes in a solid and a Hash of the mass property/value pairs. Everything succeeds with no errors/exceptions, however, the values do not change in Creo. I understand most of these properties are calculated and it's probably not a good idea to set them anyway, however, I do want to be able to set the density. Thoughts?

 

 

public void updateCADProperties(Solid solid, HashMap<String, Double> values){

MassProperty properties = null;

 

try {

properties = solid.GetMassProperty(null);

 

properties.SetMass(values.get("mass"));

properties.SetDensity(values.get("density"));

properties.SetSurfaceArea(values.get("surfaceArea"));

properties.SetVolume(values.get("volume"));

 

} catch (jxthrowable e) {

e.printStackTrace();

}

}

 

 

Thanks In Advance,

Bill

2 REPLIES 2

Hi

Set methods on MassProperty object doesn't work for me too.

Perhaps the inner Creo calculation as you mentioned.

You should try to access MASS (PRO_MP_MASS) and others via pfcModelItem > Parameter interface.

But I think ti won't work too.

But there is a Alternate Mass Properties table in Creo too.

It's purpose is to replace basic Mass Properties with manualy entered value (if am I right).

It looks that no inner calculation is used on this object.

But unlike MassProperty there is no AlternateMassProperty documented in API.

I'm experimenting with ALT_AREA parameter right now.

And it seems I will be able to write the calculated value into AlternateMassProperty table via Parameter interface.

Mass properties are read-only parameters. The only one that can be set, as Bill already mentioned, is the density. Density is a characteristic of the material. Take a look to the SetMassDensity method under the Material interface and/or MTL_PROP_MASS_DENSITY under the MaterialPropertyType Class.

I'm sorry I can't give you more details, I'm more familiar with Toolkit API's then Jlink.

Announcements