Automatically calculated mass

Hello,

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).
image

Is there any way I can get the correct mass value when it shows “1”?

Hmm, not sure I follow. How can I get those values you are seeing there?

  1. Make a polyCube
  2. Assign a Marker
  3. …?

Ah I was wondering how to recreate it - messing around a little I found this does the trick

  1. Scale cube
  2. Export marker
  3. Load physics
  4. Compare mass values

I suppose I could use this and load in my setup and copy over the values(?) -Maybe there is a better way

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. :slight_smile:

Oh I realised it’s also here when I open the manipulator - I suppose my question is actually - how to query the computed mass of a marker?


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.

Aha, yes now I’m with you.

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 :frowning: 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. :frowning: If you find a usecase for it, it would be trivial to expose this attribute as e.g. rMarker.computedMass. Let me know!

Veery cool- Thank you, I’ll have a look at this:)

  • I am using the value to calculate angular mass- It’s a one off calculation, so I don’t really need to connect it to anything in a rig just yet.
1 Like