APIs, concepts, guides, and more
HelloAxisMotion.py
1
16
17
18
19import os
20import platform
21import sys
22import time
23
24#Import the ntx.dll from INtime
25if platform.system() == "Windows":
26 os.add_dll_directory("c:\\Program Files (x86)\\INtime\\bin") #ntx.dll
27
28import RapidCodeHelpers as helpers # The check_errors() and check_errors() helpers provided on our API SampleApp documentation pages
29
30#Import the RapidCodePython.py file (Path to your rapidcode install directory)
31rapidcode_dir = helpers.find_rapid_code_directory()
32sys.path.append(rapidcode_dir)
33import RapidCodePython as RapidCode # The RapidCodePython.py wrapper located in your RMP install directory
34
35def main():
36 print("Hello, RapidCode.")
37
38 creation_params:RapidCode.CreationParameters = helpers.get_creation_parameters()
39 motionController:RapidCode.MotionController = RapidCode.MotionController.Create(creation_params)
40 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.
41
42 #motionController=RapidCode.RapidCodeObject(motionController)
43 print("MotionController creation error count: ", motionController.ErrorLogCountGet())
44 helpers.check_errors(motionController)
45
46 motionController.AxisCountSet(1)
47 axis:RapidCode.Axis = motionController.AxisGet(0)
48 helpers.check_errors(axis)
49
50 print("Axis ",axis.NumberGet()," creation error count: ", axis.ErrorLogCountGet())
51
52 axis.MoveRelative(2, 10, 1, 1, 50)
53
54 while not axis.MotionDoneGet():
55 print("Position: ", axis.CommandPositionGet(), " Velocity: ", axis.CommandVelocityGet())
56 time.sleep(1)
57
58 motionController.Delete()
59
60
61
62
63if __name__ == '__main__':
64 main()