CylindricalJointMotion returns wrong limits value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi T_F360,
During some venturous exercise I have stumbled across some strange behaviour of CylindricalJointMotion API. It took me quite a wwwwhile to trace it to the joint limits returning method.
Here is the sample design test file:
#------------------------------------------------------------------------------------------------------------------------------------------
#Author-MichaelT
#Description-CylinderJointTest
import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
rootComp = design.rootComponent
builtInJoints = rootComp.asBuiltJoints
cylindricalJoint = builtInJoints.itemByName( 'CylindricalJoint' )
#Deep check !!!
if ( cylindricalJoint.name == 'CylindricalJoint' 😞
cylindricalMotion = cylindricalJoint.jointMotion
rotation_Limits = cylindricalMotion.rotationLimits
slide_Limits = cylindricalMotion.slideLimits
if ( rotation_Limits.isMaximumValueEnabled 😞
limRotMax = rotation_Limits.maximumValue
if ( rotation_Limits.isMinimumValueEnabled 😞
limRotMin = rotation_Limits.minimumValue
if ( rotation_Limits.isRestValueEnabled 😞
restRot = rotation_Limits.restValue
if ( slide_Limits.isMaximumValueEnabled 😞
limSlideMax = slide_Limits.maximumValue
if ( slide_Limits.isMinimumValueEnabled 😞
limSlideMin = slide_Limits.minimumValue
if ( slide_Limits.isRestValueEnabled 😞
restSlide = slide_Limits.restValue
if (limRotMax == None or
limRotMin == None or
restRot == None or
limSlideMax == None or
limSlideMin == None or
restSlide == None 😞
ui.messageBox('Can not find the CylindricalJoint ')
else:
messageStr = 'CylindricalJoint limit values:\n'
messageStr += '\tlimRotMax = {:g} rad \n'.format( limRotMax)
messageStr += '\tlimRotMin = {:g} rad \n'.format( limRotMin)
messageStr += '\trestRot = {:g} rad\n\n'.format( restRot )
messageStr += '\tlimSlideMax = {:g} cm\n'.format( limSlideMax )
messageStr += '\tlimSlideMin = {:g} cm\n'.format( limSlideMin )
messageStr += '\trestSlide = {:g} cm\n'.format( restSlide )
ui.messageBox( messageStr )
else:
ui.messageBox('Can not find the CylindricalJoint ')
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
#------------------------------------------------------------------------------------------------------------------------------------------
One would expect (based on user interface input values) that the rotation limits returned < -p, +p > … Instead we got values, which correspond to the slider’s limit values ???
I am attaching the .py & .f3d files … to commemorate my misfortune … or mine inability to understand the FAPI correctly.
… and also screencast …
Regards
MichaelT
PS. The system does not allow me to attach *.py file so it is pasted instead.