AttributeError: 'NoneType' object has no attribute 'SetJointTarget'

While I am trying to run my python code for servo controller, I am getting the above error. I will really appreciate if anyone can guide me, how to take care of it?

Can you share your Python code?
‘NoneType’ usually means that you didn’t select your component or behavior correctly.

from vcScript import *
import vcMatrix
import vcHelpers

def OnRun():
# Get the machine object
comp = getComponent()

# Get the servo controllers, slides, and spindle
Servo_Controller = comp.findBehaviour("Servo_Controller")
Servo_Controller_2 = comp.findBehaviour("Servo_Controller_2")
Servo_Controller_3 = comp.findBehaviour("Servo_Controller_3")
if Servo_Controller is None:
    print("Could not find servo controller")
if Servo_Controller_2 is None:
    print("Could not find servo controller 2")
if Servo_Controller_3 is None:
    print("Could not find servo controller 3")

# Define the movement positions
left_position = vcMatrix.new(950.0, 0, 0)
forward_position = vcMatrix.new(950.0, 650.0, 0)

# Set the servo controller speed and acceleration
servo_speed = 100 # in mm/s
servo_accel = 500 # in mm/s^2

# Move link J1 to the left position
if Servo_Controller_2 is not None:
    Servo_Controller_2.moveJoint(left_position[1])
    Servo_Controller_2.waitMove(Servo_Controller_2)
else:
    print("Servo_Controller_2 not found")

# Move link J2 to the forward position
Servo_Controller_3.SetJointTarget(forward_position[0])
Servo_Controller_3.waitMove(Servo_Controller_3)

# Rotate link J3 360 degrees
Servo_Controller.SetJointTarget(0, 0, vcHelpers.Angle.fromDegrees(360), servo_speed, servo_accel)
Servo_Controller.waitMove(Servo_Controller)

# Reset the servo controller positions
Servo_Controller_2.resetPosition()
Servo_Controller_3.resetPosition()

( now getting a new error, saying its not subscriptable)

If possible, share the whole script.

  1. lowercase “s” in setJointTarget.
  2. Double check the name of the Servo Controller behaviors in the component
  3. There is no waitMove() and resetPosition() methods in vcServoController

Point 3 and the error you get is like eating chocolate pudding with your fingers. So I also have to ask what product and version are you using?

That is the whole script, which i have share. updated the recommendations from you. Still not working :frowning: it would be really nice if you can elaborate a little more when you say double check the name
File “00_PU_CC_Handling::PythonScript_4”, line 30, in OnRun
TypeError: ‘NoneType’ object is not subscriptable (new error)

Can you share your layout? I can try to help you

Closed the post. DM the op.