I would like to have access to the mass of the markers but I find that sometimes this value shows as calculated automatically and other times it shows the value of 1.
In this picture both mass values come from very similar shapes (mesh shaped markers).
Is there any way I can get the correct mass value when it shows “1”?
I think we need to take a step back for a moment, what is it that you would like to recreate?
I’d like to learn more about this “sometimes”, do you mean it happens differently every time you look? Is it different in the Channel Box versus Attribute Spreadsheet? Or the Attribute Editor? Is it only different when you import?
On import is possible; because the mass computed from the Density would be written to the .rag file. That is probably something that could be adjusted; such that if Density is anything other than 0 then Mass should import as 1.0. Is that what you are looking for? Need just a little bit more information in order to help you.
This “sometimes” was because I didn’t know why sometimes it was 1 and sometimes not 1- Now I do:)
Actually I wanted the mass that wasn’t 1, please don’t change it.
That Mass attribute is the user-defined value for Mass, whereas the Mass in the Manipulator is the final computed mass passed to the physics solver. The user-defined value is only relevant when Density = 0, otherwise Mass is computed based on that Density value and the volume occupied by your the geometry.
For a perfect UI, it should really be updating that Maya attribute also, but Maya attributes don’t work that way They are either inputs or outputs; can’t be both. Hence they act a little different.
To answer your question, you can query the value similar to how Export works, without actually making an export, like this.
import json
from maya import cmds
marker = cmds.getAttr("rMarker_polySurface31.ragdollId")
data = json.loads(cmds.ragdollDump())
data = data["entities"][str(marker)]
mass = data["components"]["RigidComponent"]["members"]["mass"]
# 0.999
That ragdollDump command is what serialises your scene to a ragfile, and in this file your Markers are known as “entities”. Every entity has one or more components, and the one you are looking for is called RigidComponent which in turn has a key called “mass”.
You can read more about this format and how to work with it here.
If you needed this value for anything rig-related, like connecting it somewhere, then at the moment this is not possible. If you find a usecase for it, it would be trivial to expose this attribute as e.g. rMarker.computedMass. Let me know!