4.12 BasScript Program Class
Overview
BasScript lets you construct BAS instruction sequences for the teach pendant in a structured way from the host PC, covering motion, logic, program calls, communication, vision, and Modbus commands.
By chaining BasScript.* method calls in Python you generate a script flow identical to that on the teach pendant, making it easy to automatically create, edit, or reuse complex programs.
Constructor
| Method Name | BasScript( name ) |
|---|---|
| Description | Corresponds to the instructions in the teaching pendant program editor |
| Request Parameters | name : Script name |
| Compatible robot software version | Collaborative (Copper): v7.5.2.0+ Industrial (Bronze): v7.6.0.0+ |
| Notes | All methods under BasScript follow the same compatible robot software versions as this class |
4.12.1 Motion to Point Instruction
| Method Name | BasScript.move_joint( pose_type , pose_index , speed_type , speed_value , smooth_type , smooth_distance , extra_param ) |
|---|---|
| Description | Corresponds to the MoveJoint instruction in the teaching pendant program writing |
| Request Parameters | pose_type : Pose type pose_index : Pose index speed_type : Speed type speed_value : Speed value smooth_type : Smooth type smooth_distance : Smooth distance extra_param : Extra parameter |
| Return Value | StatusCodeEnum: Function execution result |
4.12.2 Linear Motion to Point Instruction
| Method Name | BasScript.move_line( pose_type , pose_index , speed_type , speed_value , smooth_type , smooth_distance , extra_param ) |
|---|---|
| Description | Corresponds to the MoveLine instruction in the teaching pendant program writing |
| Request Parameters | pose_type : Pose type pose_index : Pose index speed_type : Speed type speed_value : Speed value smooth_type : Smooth type smooth_distance : Smooth distance extra_param : Extra parameter |
| Return Value | StatusCodeEnum: Function execution result |
4.12.3 Arc Motion to Point Instruction
| Method Name | BasScript.move_circle( pose_type1 , pose_index1 , pose_type2 , pose_index2 , speed_type , speed_value , smooth_type , smooth_distance , extra_param ) |
|---|---|
| Description | Corresponds to the MoveCircle instruction in the teaching pendant program writing |
| Request Parameters | pose_type1 : First pose type pose_index1 : First pose index pose_type2 : Second pose type pose_index2 : Second pose index speed_type : Speed type speed_value : Speed value smooth_type : Smooth type smooth_distance : Smooth distance extra_param : Extra parameter |
| Return Value | StatusCodeEnum: Function execution result |
4.12.4 If Conditional Instruction
| Method Name | BasScript.logi_if( param1 , index , param2 , value , operator ) |
|---|---|
| Description | Corresponds to the IF logical statement in the teaching pendant program writing |
| Request Parameters | param1 : First parameter index : Index param2 : Second parameter value : Value operator : Logical operator |
| Return Value | StatusCodeEnum: Function execution result |
4.12.5 ElseIf Conditional Branch Instruction
| Method Name | BasScript.logi_else_if( param1 , index , param2 , value , operator ) |
|---|---|
| Description | Corresponds to the ELIF logical statement in the teaching pendant program writing |
| Request Parameters | param1 : First parameter index : Index param2 : Second parameter value : Value operator : Logical operator |
| Return Value | StatusCodeEnum: Function execution result |
4.12.6 Else Instruction
| Method Name | BasScript.logi_else() |
|---|---|
| Description | Corresponds to the ELSE logical statement in the teaching pendant program writing |
| Request Parameters | None |
| Return Value | StatusCodeEnum: Function execution result |
4.12.7 End Conditional Instruction
| Method Name | BasScript.logi_end_if() |
|---|---|
| Description | Corresponds to the ENDIF logical statement in the teaching pendant program writing |
| Request Parameters | None |
| Return Value | StatusCodeEnum: Function execution result |
4.12.8 While Loop Instruction
| Method Name | BasScript.logi_while( param1 , index , param2 , value , operator ) |
|---|---|
| Description | Corresponds to the WHILE logical statement in the teaching pendant program writing |
| Request Parameters | param1 : First parameter index : Index param2 : Second parameter value : Value operator : Logical operator |
| Return Value | StatusCodeEnum: Function execution result |
4.12.9 End Loop Instruction
| Method Name | BasScript.logi_end_while() |
|---|---|
| Description | Corresponds to the ENDWHILE logical statement in the teaching pendant program writing |
| Request Parameters | None |
| Return Value | StatusCodeEnum: Function execution result |
4.12.10 Switch Multi-branch Selection Instruction
| Method Name | BasScript.logi_switch( param , index ) |
|---|---|
| Description | Corresponds to the SWITCH logical statement in the teaching pendant program writing |
| Request Parameters | param : Parameter index : Index |
| Return Value | StatusCodeEnum: Function execution result |
4.12.11 Case Branch Instruction
| Method Name | BasScript.logi_case( param , value ) |
|---|---|
| Description | Corresponds to the CASE logical statement in the teaching pendant program writing |
| Request Parameters | param : Parameter value : Value |
| Return Value | StatusCodeEnum: Function execution result |
4.12.12 Default Branch Instruction
| Method Name | BasScript.logi_default() |
|---|---|
| Description | Corresponds to the DEFAULT logical statement in the teaching pendant program writing |
| Request Parameters | None |
| Return Value | StatusCodeEnum: Function execution result |
4.12.13 End Multi-branch Selection Instruction
| Method Name | BasScript.logi_end_switch() |
|---|---|
| Description | Corresponds to the ENDSWITCH logical statement in the teaching pendant program writing |
| Request Parameters | None |
| Return Value | StatusCodeEnum: Function execution result |
4.12.14 Goto Jump Instruction
| Method Name | BasScript.logi_goto( index ) |
|---|---|
| Description | Corresponds to the GOTO jump statement in the teaching pendant program writing |
| Request Parameters | index : Index of the target label |
| Return Value | StatusCodeEnum: Function execution result |
4.12.15 Label Instruction
| Method Name | BasScript.logi_label( index ) |
|---|---|
| Description | Corresponds to the LABEL label statement in the teaching pendant program writing |
| Request Parameters | index : Label index |
| Return Value | StatusCodeEnum: Function execution result |
4.12.16 Skip Condition Instruction
| Method Name | BasScript.logi_skip_condition( param1 , index , param2 , value , operator ) |
|---|---|
| Description | Corresponds to the SKIP CONDITION jump statement in the teaching pendant program writing |
| Request Parameters | param1 : First parameter index : Index param2 : Second parameter value : Value operator : Logical operator |
| Return Value | StatusCodeEnum: Function execution result |
4.12.17 Break Loop Instruction
| Method Name | BasScript.logi_break() |
|---|---|
| Description | Corresponds to the BREAK statement in the teaching pendant program writing |
| Request Parameters | None |
| Return Value | StatusCodeEnum: Function execution result |
4.12.18 Skip Loop Instruction
| Method Name | BasScript.logi_continue() |
|---|---|
| Description | Corresponds to the CONTINUE statement in the teaching pendant program writing |
| Request Parameters | None |
| Return Value | StatusCodeEnum: Function execution result |
4.12.19 Assignment Instruction
| Method Name | BasScript.assign_value( param1 , index , param2 , value , opt_index , opt_value ) |
|---|---|
| Description | Corresponds to the ASSIGN assignment statement in the teaching pendant program writing |
| Request Parameters | param1 : First parameter index : Index param2 : Second parameter value : Value opt_index : Optional index opt_value : Optional value |
| Return Value | StatusCodeEnum: Function execution result |
4.12.20 Wait Condition Instruction
| Method Name | BasScript.wait( param1 , index , param2 , value , operator ) |
|---|---|
| Description | Corresponds to the WAIT COND wait condition statement in the teaching pendant program writing |
| Request Parameters | param1 : First parameter index : Index param2 : Second parameter value : Value operator : Logical operator |
| Return Value | StatusCodeEnum: Function execution result |
4.12.21 Wait Time Instruction
| Method Name | BasScript.wait_time( param , value ) |
|---|---|
| Description | Corresponds to the WAIT TIME wait time statement in the teaching pendant program writing |
| Request Parameters | param : Parameter value : Time value |
| Return Value | StatusCodeEnum: Function execution result |
4.12.22 Pause Instruction
| Method Name | BasScript.pause() |
|---|---|
| Description | Corresponds to the PAUSE pause statement in the teaching pendant program writing |
| Request Parameters | None |
| Return Value | StatusCodeEnum: Function execution result |
4.12.23 Abort Instruction
| Method Name | BasScript.abort() |
|---|---|
| Description | Corresponds to the ABORT terminate statement in the teaching pendant program writing |
| Request Parameters | None |
| Return Value | StatusCodeEnum: Function execution result |
4.12.24 Call Synchronous Program Call Instruction
| Method Name | BasScript.call( name ) |
|---|---|
| Description | Corresponds to the CALL synchronous program call in the teaching pendant program writing |
| Request Parameters | name : Program name |
| Return Value | StatusCodeEnum: Function execution result |
4.12.25 Run Asynchronous Program Call Instruction
| Method Name | BasScript.run( name ) |
|---|---|
| Description | Corresponds to the RUN asynchronous program call in the teaching pendant program writing |
| Request Parameters | name : Program name |
| Return Value | StatusCodeEnum: Function execution result |
4.12.26 Load Program Instruction
| Method Name | BasScript.load( param , value ) |
|---|---|
| Description | Corresponds to the LOAD load program in the teaching pendant program writing |
| Request Parameters | param : Parameter value : Value |
| Return Value | StatusCodeEnum: Function execution result |
4.12.27 Unload Program Instruction
| Method Name | BasScript.unload( param , value ) |
|---|---|
| Description | Corresponds to the UNLOAD unload program in the teaching pendant program writing |
| Request Parameters | param : Parameter value : Value |
| Return Value | StatusCodeEnum: Function execution result |
4.12.28 Execute Program Instruction
| Method Name | BasScript.exec( param , value ) |
|---|---|
| Description | Corresponds to the EXEC execute program in the teaching pendant program writing |
| Request Parameters | param : Parameter value : Value |
| Return Value | StatusCodeEnum: Function execution result |
4.12.29 Open Socket Connection Instruction
| Method Name | BasScript.socket_open( index ) |
|---|---|
| Description | Corresponds to the SOCKET OPEN open socket connection in the teaching pendant program writing |
| Request Parameters | index : SK register sequence number |
| Return Value | StatusCodeEnum: Function execution result |
4.12.30 Close Socket Connection Instruction
| Method Name | BasScript.socket_close( index ) |
|---|---|
| Description | Corresponds to the SOCKET CLOSE close socket connection in the teaching pendant program writing |
| Request Parameters | index : SK register sequence number |
| Return Value | StatusCodeEnum: Function execution result |
4.12.31 Connect Socket Instruction
| Method Name | BasScript.socket_connect( index ) |
|---|---|
| Description | Corresponds to the SOCKET CONNECT connect socket in the teaching pendant program writing |
| Request Parameters | index : SK register sequence number |
| Return Value | StatusCodeEnum: Function execution result |
4.12.32 Send Socket Data Instruction
| Method Name | BasScript.socket_send( index , msg_type , value ) |
|---|---|
| Description | Corresponds to the SOCKET SEND send data in the teaching pendant program writing |
| Request Parameters | index : SK register sequence number msg_type : Message type value : Message content or sequence number |
| Return Value | StatusCodeEnum: Function execution result |
4.12.33 Receive Socket Data Instruction
| Method Name | BasScript.socket_recv( index , msg_length , msg_type , value ) |
|---|---|
| Description | Corresponds to the SOCKET RECV receive data in the teaching pendant program writing |
| Request Parameters | index : SK register sequence number msg_length : Message length msg_type : Message type value : Message content or sequence number |
| Return Value | StatusCodeEnum: Function execution result |
4.12.34 Read Modbus Holding Register Instruction
| Method Name | BasScript.modbus_read_MH( index , id , address , length , r_index ) |
|---|---|
| Description | Corresponds to the READ_MH read Modbus holding register in the teaching pendant program writing |
| Request Parameters | index : Channel sequence number id : Modbus ID address : Register address length : Register length r_index : R register sequence number |
| Return Value | StatusCodeEnum: Function execution result |
4.12.35 Read Modbus Input Register Instruction
| Method Name | BasScript.modbus_read_MI( index , id , address , length , r_index ) |
|---|---|
| Description | Corresponds to the READ_MI read Modbus input register in the teaching pendant program writing |
| Request Parameters | index : Channel sequence number id : Modbus ID address : Register address length : Register length r_index : R register sequence number |
| Return Value | StatusCodeEnum: Function execution result |
4.12.36 Write Modbus Holding Register Instruction
| Method Name | BasScript.modbus_write_MH( index , id , address , length , value_type , value ) |
|---|---|
| Description | Corresponds to the WRITE_MH write Modbus holding register in the teaching pendant program writing |
| Request Parameters | index : Channel sequence number id : Modbus ID address : Register address length : Register length value_type : Value type value : Value or index |
| Return Value | StatusCodeEnum: Function execution result |
4.12.37 Find Vision Program Instruction
| Method Name | BasScript.vision_find( name ) |
|---|---|
| Description | Corresponds to the VISION FIND find vision program in the teaching pendant program writing |
| Request Parameters | name : Vision program name |
| Return Value | StatusCodeEnum: Function execution result |
4.12.38 Get Vision Program Offset Instruction
| Method Name | BasScript.vision_get_offset( name , index , label_index ) |
|---|---|
| Description | Corresponds to the VISION GET OFFSET get vision program offset in the teaching pendant program writing |
| Request Parameters | name : Vision program name index : Vision register index label_index : Label index |
| Return Value | StatusCodeEnum: Function execution result |
4.12.39 Get Vision Program Result Instruction
| Method Name | BasScript.vision_get_quantity( name , index ) |
|---|---|
| Description | Corresponds to the VISION GET QUANTITY get vision program result in the teaching pendant program writing |
| Request Parameters | name : Vision program name index : R register index |
| Return Value | StatusCodeEnum: Function execution result |
4.12.40 Set Parameter Instruction
| Method Name | BasScript.set_param( type , value_type , value ) |
|---|---|
| Description | Corresponds to the SET PARAM set parameter in the teaching pendant program writing |
| Request Parameters | type : Parameter type value_type : Value type value : Value |
| Return Value | StatusCodeEnum: Function execution result |
4.12.41 Extra Parameter Class
| Method Name | ExtraParam() |
|---|---|
| Description | Extra parameter class, used to construct complex robot control commands |
| Request Parameters | None |
| Return Value | None |
4.12.41.1 Set Acceleration
| Method Name | ExtraParam.acceleration( value ) |
|---|---|
| Description | Set acceleration, range is 1~120 |
| Request Parameters | value : Acceleration value (float) |
| Return Value | None |
4.12.41.2 Set RTCP Parameter
| Method Name | ExtraParam.rctp() |
|---|---|
| Description | Set RTCP parameter |
| Request Parameters | None |
| Return Value | None |
4.12.41.3 Set Frame Offset
| Method Name | ExtraParam.offset( index ) |
|---|---|
| Description | Set frame offset |
| Request Parameters | index : Offset index (integer) |
| Return Value | None |
4.12.41.4 Set Time-Based Operation or Assignment
| Method Name | ExtraParam.tb( second , type , name =None, index =None, status =None) |
|---|---|
| Description | Set time-based operation or assignment |
| Request Parameters | second : Seconds (integer) type : Execution type (string) name : Name (for operation, string) index : Index (for assignment, integer) status : Status (for assignment, string) |
| Return Value | None |
4.12.41.5 Set Jump
| Method Name | ExtraParam.skip( index ) |
|---|---|
| Description | Set jump |
| Request Parameters | index : Label index (integer) |
| Return Value | None |
4.12.42 JUMP Quick Motion Instruction
4.12.42.1 JUMP Quick Motion Instruction
| Method Name | move_jump( pose_type , pose_index , speed_value , speed_ratio , lim_Z_type , lim_Z_value , smooth_type , smooth_distance =0.0, extra_param =None) |
|---|---|
| Description | Robot point-to-point move to the specified position |
| Request Parameters | pose_type : Target pose storage type ( MovePoseType , currently supports PR register) pose_index : Index of the target position (integer, indicating the position in the PR register on the controller) speed_value : Movement speed value (float, unit is mm/s) speed_ratio : Movement speed ratio (float, unit is %, range is 0~100) lim_Z_type : Z-axis limit type ( SpeedType , can be MR register or numerical VALUE) lim_Z_value : Z-axis limit value (if lim_Z_type is MR register, it indicates the MR register sequence number; if it is numerical VALUE, it indicates the Z-axis limit value, unit is mm/s, range is 0~100) smooth_type : Smooth type ( SmoothType , can be FINE or SMOOTH_DISTANCE) smooth_distance : Smooth distance (float, only effective when smooth_type is SMOOTH_DISTANCE, range is 0~1000) extra_param : Extra parameter ( ExtraParam , used to set the extra parameters of the MOVE instruction, optional) |
| Return Value | StatusCodeEnum: Function execution result |
4.12.42.2 JUMP3 Quick Motion Instruction
| Method Name | move_jump3( pose_type , pose_index , speed_value , speed_ratio , smooth_type , smooth_distance =0.0, extra_param =None) |
|---|---|
| Description | Robot point-to-point move to the specified position |
| Request Parameters | pose_type : Target pose storage type ( MovePoseType , currently supports PR register) pose_index : Index of the 3 target positions (list, containing 3 integers, indicating the positions in the PR register on the controller) speed_value : Movement speed value (float, unit is mm/s) speed_ratio : Movement speed ratio (float, unit is %, range is 0~100) smooth_type : Smooth type ( SmoothType , can be FINE or SMOOTH_DISTANCE) smooth_distance : Smooth distance (float, only effective when smooth_type is SMOOTH_DISTANCE, range is 0~1000) extra_param : Extra parameter ( ExtraParam , used to set the extra parameters of the MOVE instruction, optional) |
| Return Value | StatusCodeEnum: Function execution result |
4.12.42.3 JUMP3CP Quick Motion Instruction
| Method Name | move_jump3cp( pose_type , pose_index , speed_value , smooth_type , smooth_distance =0.0, extra_param =None) |
|---|---|
| Description | Robot point-to-point move to the specified position |
| Request Parameters | pose_type : Target pose storage type ( MovePoseType , currently supports PR register) pose_index : Index of the 3 target positions (list, containing 3 integers, indicating the positions in the PR register on the controller) speed_value : Movement speed value (float, unit is mm/s) smooth_type : Smooth type ( SmoothType , can be FINE or SMOOTH_DISTANCE) smooth_distance : Smooth distance (float, only effective when smooth_type is SMOOTH_DISTANCE, range is 0~1000) extra_param : Extra parameter ( ExtraParam , used to set the extra parameters of the MOVE instruction, optional) |
| Return Value | StatusCodeEnum: Function execution result |