Message 1 of 4
Error when reading rotationValue

Not applicable
10-12-2020
03:17 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to change the angel of a simple revolution as BuiltIn joint like this:
import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
design = adsk.fusion.Design.cast(app.activeProduct)
root = design.rootComponent
occ = root.occurrences.itemByName("MyComponent:1")
ui.messageBox(occ.name)
driveJoint = occ.component.asBuiltJoints.itemByName("Rev7")
revMotion = adsk.fusion.RevoluteJointMotion.cast(driveJoint.jointMotion)
somevar = revMotion.rotationValue
revMotion.rotationValue = somevar
ui.messageBox(revMotion.rotationValue)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
The problem is that I always get an error when trying to read the value of `rotationValue` like in this line:
revMotion.rotationValue
---------------------------
Fusion 360
---------------------------
Failed:
Traceback (most recent call last):
File "C:/Users/XXX/AppData/Roaming/Autodesk/Autodesk Fusion 360/API/Scripts/Simulator/Simulator.py", line 22, in run
somevar = revMotion.rotationValue
File "C:/Users/XXX/AppData/Local/Autodesk/webdeploy/production/e93c21ea16478b49c4dee1f65accf1a11ae6ef96/Api/Python/packages\adsk\fusion.py", line 50025, in _get_rotationValue
return _fusion.RevoluteJointMotion__get_rotationValue(self)
RuntimeError: 2 : InternalValidationError : axis
---------------------------
OK
---------------------------
Could anyone help me to get rid of this error? I cannot understand totally why this is happening..
What I am trying to achieve is getting a relative motion, so just to increase the current angel like this:
revMotion.rotationValue = revMotion.rotationValue + 1