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