Automated ID Management

The MotionSolve Python Interface is capable of managing IDs for you. You do not need to specify an ID while you are modeling. However, you can create entities with IDs if you want to. Here is an example.
blk2 = Part (label="Block-2", mass=2, ip=[9.8e-4,9.8e-4,9.8e-4])

# Create a RIGID BODY WITH an ID
blk3 = Part (id=30101011, label="Block-3", mass=2, ip=[9.8e-4,9.8e-4,9.8e-4])
The ID of any object (that can have an ID), can be obtained by using the id attribute of the object. Here are two examples:

IDs are used in only one place in the MotionSolve Python Interface – for creating function expressions that MotionSolve will evaluate at run time. You can use standard Python programming to construct function expressions. Here is an example that illustrates how you can do this.

Assume that you created a block on a translational joint as shown below.
p0 = Point (10,0,0) 
ux = Vector (0,0,1)
ux = Vector (1,0,0)
blk = Part (mass=1, ip=[4.9e-4,4.9e-4,4.9e-4], label="Block") = Marker (body=blk, qp=p0, zp=p0+uz, xp=p0+ux, label="Block CM")

im = Marker (body=blk, qp=p0, zp=p0+ux, xp=p0+uz, label="Joint Marker on Block")
jm = Marker (body=grnd, qp=p0, zp=p0+ux, xp=p0+uz, label="Joint Marker on Ground")
jnt = Joint (type="TRANSLATIONAL", i = im, j = jm, label="Trans Joint")
Now you wish to create a request that can compute the kinetic energy of the block. Here is how you would do it.
KE = "0.5 * {m} * (VM({blkcm})**2)".format(m=blk.mass, 
r1 = Request (type="EXPRESSION", f2=KE, comment="Kinetic Energy of Block")