I tested the following code. but on further investigation, I discovered that this looks very promising but in fact, it sets the mass property of the complete part...
Dim doc As PartDocument = ThisDoc.Document
Dim def As PartComponentDefinition = doc.ComponentDefinition
Dim body As SurfaceBody = def.SurfaceBodies.Item(1)
Dim bodyDef As PartComponentDefinition = body.ComponentDefinition
Dim mass As MassProperties = bodyDef.MassProperties
mass.Volume = 1
Also, I found this topic. Here someone wants to get the value (not set it). The Autodesk employee confirms that there is no direct way to get the value. He proposes some alternative ways to get the value but I guess it will not help you set the values. I came to the conclusion that it's not possible to set the mass of a solid body.
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Blog: hjalte.nl - github.com