I put together a Bullet example for you, and then realised you were using the system prior to Bullet being introduced to Maya, so I’ll post both examples for future readers.
So I think you’re doing it right, at least it appears to be designed for use in this way. If so, it isn’t doing what it’s supposed to.
import maya.cmds as mc
mc.polySphere()
mc.rigidBody()
# mc.select(clear=1)
mc.gravity()
Firstly, I expect you’ll need to actually have your object selected, as forces are applied per-rigid. The problem however is that when applying gravity via Python, it generates this extra geoConnector
node for some reason. :/
You can “repair” this manually, and end up with what you get when using the Maya Fields menu, by connecting the missing bits like this.
import maya.cmds as mc
mc.polySphere()
rigid = mc.rigidBody()
_, gravity = mc.gravity()
cmds.connectAttr(gravity + ".outputForce[0]", rigid + ".inputForce[0]")
cmds.connectAttr(rigid + ".fieldData", gravity + ".inputData[0]", force=True)
And finally, here’s the Bullet equivalent, plus a ground plane.
from maya import cmds as mc
from maya.app.mayabullet import RigidBody
cmds.file(new=True, force=True)
mc.polySphere()
cmds.move(0, 5)
_, rigid = RigidBody.CreateRigidBody(True).executeCommandCB()
cmds.setAttr("bulletSolver1.groundPlane", True)
cmds.setAttr(rigid + ".colliderShapeType", 2) # Sphere
These were tested on Maya 2020.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/c63567ec-5594-4076-a3cf-ae87b6a8c9cen%40googlegroups.com.