Automated ID Management
# Create a RIGID BODY WITHOUT an ID
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])
>>> blk2.id
1
>>> blk3.id
30101011
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.
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")
blk.cm = 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")
KE = "0.5 * {m} * (VM({blkcm})**2)".format(m=blk.mass, blkcm=blk.cm.id)
r1 = Request (type="EXPRESSION", f2=KE, comment="Kinetic Energy of Block")