APIs, concepts, guides, and more
Hello Axis Motion

Basics for getting up and running with Axis motion in RapidCode for Python.


📜 Hello Axis Motion

import os
import platform
import sys
import time
#Import the ntx.dll from INtime
if platform.system() == "Windows":
os.add_dll_directory("c:\\Program Files (x86)\\INtime\\bin") #ntx.dll
import RapidCodeHelpers as helpers # The check_errors() and check_errors() helpers provided on our API SampleApp documentation pages
#Import the RapidCodePython.py file (Path to your rapidcode install directory)
rapidcode_dir = helpers.find_rapid_code_directory()
sys.path.append(rapidcode_dir)
import RapidCodePython as RapidCode # The RapidCodePython.py wrapper located in your RMP install directory
def main():
print("Hello, RapidCode.")
creation_params:RapidCode.CreationParameters = helpers.get_creation_parameters()
motionController:RapidCode.MotionController = RapidCode.MotionController.Create(creation_params)
print("This object is a "+str(type(motionController)))#When creating your RapidCode objects (Axis, MultiAxis, MotionController,ect) we recommend specifying the type with my_object_name:RapidCode.*** (MotionController,Axis, Ect.) so that your IDE can autocomplete class member names.
#motionController=RapidCode.RapidCodeObject(motionController)
print("MotionController creation error count: ", motionController.ErrorLogCountGet())
helpers.check_errors(motionController)
motionController.AxisCountSet(1)
axis:RapidCode.Axis = motionController.AxisGet(0)
helpers.check_errors(axis)
print("Axis ",axis.NumberGet()," creation error count: ", axis.ErrorLogCountGet())
axis.MoveRelative(2, 10, 1, 1, 50)
while not axis.MotionDoneGet():
print("Position: ", axis.CommandPositionGet(), " Velocity: ", axis.CommandVelocityGet())
time.sleep(1)
motionController.Delete()

Learn more in settling topic page.