
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Trying to drive a cylindrical joint rotation (that drives a mechanism through other joints) but not successful. The attached model is a trivial example (without the final mechanism), using this script:
import adsk.core, adsk.fusion, adsk.cam, traceback
import math
def run(context):
app = adsk.core.Application.get()
ui = app.userInterface
try:
design = adsk.fusion.Design.cast(app.activeProduct)
root = design.rootComponent
crankJoint = root.joints.itemByName('Crankshaft to Bearing')
crankAngle = adsk.fusion.CylindricalJointMotion.cast(crankJoint.angle)
for step in range(0,180,1):
angle = (math.pi / 90) * step
crankAngle = angle
app.activeViewport.refresh()
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
When executed, nothing happens.
But, this script fragment does work for a revolute joint.
driveJoint = root.joints.itemByName('Lever 1 to Foundation')
revMotion = adsk.fusion.RevoluteJointMotion.cast(driveJoint.jointMotion)
app.activeViewport.refresh()
for step in range(0,360,1):
angle = (math.pi / 90) * step
revMotion.rotationValue = angle
app.activeViewport.refresh()
The documentation suggests that the property for CylindricalJointMotion should be "rotationValue" . . . but this generates a run error. The script editor suggest the property "angle" which does not generate a run error but also doesn't do anything. The property "jointMotion" used for the revolute joint works (for the revolute joint) but it seems that it would be ambiguous for a cylindrical joint since it has both rotational and sliding motions . . . it, also generates a run error.
Thoughts?
Thanks
Solved! Go to Solution.