- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am trying to drive multiple joints inside of a Assembly(more specifically the model of a Robot) which is used inside of another assembly.
My Code is working if the Assembly of the Robot is the root Assembly however if the Robot is inside of another Assembly my script does not work anymore, it throws no exception, however the Joints in the view do not get updated.
Here is the code that I am using to get the Joints:
app = None
ui = None
product = None
design = None
rootComp = None
allComps = None
urComp = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
rootComp = design.rootComponent
allComps = design.allComponents
for comp in allComps:
if comp.name.startswith("eSeries_UR10e"):
urComp = comp
ui.messageBox(comp.name)
joints = urComp.allJoints
urjoints = [None]*6
for joint in joints:
if joint.name.startswith("Base"):
urjoints[0] = adsk.fusion.RevoluteJointMotion.cast(joint.jointMotion)
print("found Base")
elif joint.name.startswith("Shoulder"):
urjoints[1] = adsk.fusion.RevoluteJointMotion.cast(joint.jointMotion)
print("found Shoulder")
elif joint.name.startswith("Elbow"):
urjoints[2] = adsk.fusion.RevoluteJointMotion.cast(joint.jointMotion)
print("found Elbow")
elif joint.name.startswith("Wrist1"):
urjoints[3] = adsk.fusion.RevoluteJointMotion.cast(joint.jointMotion)
print("found Wrist1")
elif joint.name.startswith("Wrist2"):
urjoints[4] = adsk.fusion.RevoluteJointMotion.cast(joint.jointMotion)
print("found Wrist2")
elif joint.name.startswith("Wrist3"):
urjoints[5] = adsk.fusion.RevoluteJointMotion.cast(joint.jointMotion)
print("found Wrist3")
axisinversion = [1,1,-1,-1,1,1]And this is the code I use to drive the joints using a custom event handler:
class ThreadEventHandler(adsk.core.CustomEventHandler):
def __init__(self):
super().__init__()
def notify(self, args):
try:
realurjoints = robot.joints
for i in range(6):
urjoints[i].rotationValue = realurjoints[i] * axisinversion[i]
app.activeViewport.refresh()
adsk.doEvents()
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))I get the positions that the joints should go to using robot.joints.
The strange thing is that the rotationValue of each RevoluteJointMotion gets updated correctly but not displayed when the robot is inside of another assembly.
Thanks for the help.
Greetings from Germany
Oli
Solved! Go to Solution.