Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
Can I reference Mass Properties in an Expression?
adrian_vlzkz
Member Posts: 266 PRO
in General
Could find anything on the help, basically trying to see if I can use "system" values when writing an Expresion for a Variable. (Mass, Volume, Density...)
Adrian V. | Onshape Ambassador
CAD Engineering Manager
CAD Engineering Manager
Tagged:
0
Answers
Twitter: @onshapetricks & @babart1977
It would be pretty easy to make a "measure volume" custom feature which sets a variable to the volume of a selected part. Density (and hence, mass) are trickier because FeatureScript does not have access to the material assignment of a part. What is the overall goal here?
CAD Engineering Manager
Maybe I misunderstood. Do you just want to set a variable to "3 m^3" or "10 kg", or do you want to set a variable to the measured volume/mass/density of an existing part?
CAD Engineering Manager
This should be possible using an "any" variable
function() { return evVolume(context, {"entities" : qEverything(EntityType.BODY)}); }
Hoping this will return the volume of all parts at the position it's in the tree.
I'm going to write a featurescript to set these variables. This is all that needs to be done. Adrian's request is still valid. Why aren't these already being set? The benefit with a feature script is that you can ask which parts to include in a volume calculation which is useful. The globals that you set in a partstudio will have to be "all".
Not sure if I understand your question, but mass properties can be expensive to compute -- we should not be doing it without the user asking.
@ilya_baran thanks, I think I have this under control. I'm going to have a featurescript write the volume to a variable using a featurescript.