User Tools

Site Tools


Sidebar

Home



Expressions


About

Functions

   expr_list()

   exec()
   return()
   if()
   for()
   loop()
   nop()

  Output
   print()
   clear()
   debug()

  Math
   abs()
   sign()

   sqr()
   sqrt()

   min()
   max()

   inc()
   dec()

   rand()

   none()
   nan()

   def()
   defnz()

   is_none()
   is_num()
   is_str()
   is_valid()

   bool()

  Rounding
   round()
   roundup()
   floor()
   ceil()
   trunc()
   center()
   centerex()

   s8()
   u8()
   s16()
   u16()
   s32()
   u32()

  Trigonometric
   pi()
   sin()
   cos()
   tan()
   asin()
   acos()
   atan()
   atan2()

   rad2deg()
   deg2rad()

  Logarithmic
   e()
   pow()
   exp()
   exp10()
   exp2()
   log()
   log10()
   log2()

  Bitwise
   bit()
   not()
   and()
   or()
   xor()
   nand()
   nor()
   xnor()
   shl()
   shr()

  Logical
   lnot()
   land()
   lor()
   lxor()
   lnand()
   lnor()
   lxnor()

  Relational
   eq()
   ne()
   gt()
   lt()
   ge()
   le()

  Date & Time
   date()
   datetime()
   year()
   month()
   day()
   hour()
   minute()
   second()
   millisec()

  Strings
   str()
   strlen()
   padleft()
   padright()
   hex()
   bin()
   chr()
   match()

  Parameters
   param_get()
   param_set()
   param_remove()
   param_persistent()

  Coordinates & Units
   to_motor()
   to_motor_xy()
   to_motor_uv()

   to_work()
   to_work_xy()
   to_work_uv()

   mm_to_unit()
   unit_to_mm()

   mm_to_setunit()
   setunit_to_mm()

   unit_to_setunit()
   setunit_to_unit()

   setunit()

  Commands
   estop()
   stop()
   pause()
   start()

   open()
   close()

   settings()
   exit()
   exitforce()

   output()
   output_pwm()
   output_rc()

   mist()
   flood()
   spindle()

   extout1()
   extout2()

   jog()
   jog_axis()
   jog_stop()

   speed_override()
   spindle_override()

   thc()

   cmd_list()
   cmd_count()

   cmd_get_id()
   cmd_get_name()
   cmd_get_displayname()

   cmd_is_enabled()
   cmd_is_checked()

   cmd_exec()

   open_file()
   open_code()
   start_file()
   start_code()
   test_file()
   test_code()

   run()

   py_list()
   py()
   py_term()
   py_msg()

  UI
   is_visible()
   show()
   hide()

   set_status()
   set_progress()

   is_ui_ready()

  Message
   msg()
   msgerr()

   msg_show()

   msg_count()
   msg_is_active()

   msg_click_ok()
   msg_click_cancel()

   bubble()

  Dialog
   dlg_file_open()
   dlg_file_save()

   dlg_new()
   dlg_init()
   dlg_update()
   dlg_clear()

   dlg_show()
   dlg_abort()

   dlg_is_valid()
   dlg_keep_open()
   dlg_callback()

   dlg_modal()
   dlg_set_resizable()
   dlg_set_pos()
   dlg_set_size()
   dlg_set_btn()
   dlg_set_name()
   dlg_set_color()

   dlg_add_separator()
   dlg_add_image()
   dlg_add_label()
   dlg_add_checkbox()
   dlg_add_num_input()
   dlg_add_txt_input()
   dlg_add_dropbox()
   dlg_add_button()

   dlg_comp_pos()
   dlg_comp_size()
   dlg_comp_color()
   dlg_comp_font()
   dlg_comp_name()
   dlg_comp_value()
   dlg_comp_callback()

   dlg_draw_line()
   dlg_draw_arrow()
   dlg_draw_circle()
   dlg_draw_rect()

   dlg_click_apply()
   dlg_click_ok()
   dlg_click_close()

   dlg_has_btn_apply()
   dlg_has_btn_ok()
   dlg_has_btn_close()

  Points
   points_count()
   points_clear()
   points_add()
   points_get()
   points_set()
   points_delete()
   points_load()
   points_save()

  File
   file_delete()
   file_open()
   file_close()
   file_read()
   file_append()
   file_flush()

  Array
   array_new()
   array_delete()
   array_isvalid()
   array_size()
   array_clear()
   array_resize()
   array_insert()
   array_remove()
   array_copy()
   array_printstring()
   array_printdata()
   array_setstring()
   array_getstring()
   array_setdata()
   array_setdata16()
   array_setdata32()
   array_setdata64()
   array_setdataflt32()
   array_setdataflt64()
   array_getdata()
   array_getdata16()
   array_getdata32()
   array_getdata64()
   array_getdataflt32()
   array_getdataflt64()
   array_crc16()
   array_crc32()

  Serial
   serial_list()
   serial_info()
   serial_open()
   serial_close()
   serial_config()
   serial_write()
   serial_writedata()
   serial_writedata16()
   serial_writedata32()
   serial_writearray()
   serial_writeflush()
   serial_read()
   serial_readdata()
   serial_readarray()
   serial_readflush()
   serial_addlistener()
   serial_remlistener()

  USB
   usb_list()
   usb_info()
   usb_open()
   usb_close()
   usb_read()
   usb_readdata()
   usb_readarray()
   usb_write()
   usb_writedata()
   usb_writearray()
   usb_addlistener()
   usb_remlistener()

  Hash
   crc16()
   crc32()
   sha256()
   sha256_f()
   md5()
   md5_f()

  Crypt
   aes256_encrypt()
   aes256_encrypt_f()
   aes256_decrypt()
   aes256_decrypt_f()

  Colors
   rgb_to_hue()
   rgb_to_saturation()
   rgb_to_lightness()
   rgb_to_name()

  Camera
   cam_grab()
   cam_color()
   cam_rect()

  Sound
   beep()
   siren()
   sound_load()
   sound_unload()
   sound_play()
   sound_stop()
   sound_is_playing()

  MIDI
   midi_note_on()
   midi_note_off()
   midi_ctrl()
   midi_prog()
   midi_play()
   midi_stop()
   midi_is_playing()

   midiin_channel()
   midiin_prog()
   midiin_note()
   midiin_ctrl()

  Misc
   sleep()

   url()
   rubik()

  PoKeys
   pk_digital()
   pk_analog()

Operators

Events

expr:functions:func-cmd_exec

cmd_exec()

Executes a command by either its ID or name. Optionally, additional parameters can be passed depending on the command requirements.

Syntax

Execute a command by ID or name, optionally with up to three parameters

cmd_exec(command)
cmd_exec(command, parameter)
cmd_exec(command, int_value, double_value)
cmd_exec(command, int_value, double_value1, double_value2)

Parameters

Parameter Type Description
command_id Number The ID of the command to execute.
command_name String The name of the command to execute.
parameter Number A single numeric parameter. optional
int_value Number An integer value. optional
double_value Number A numeric value. optional
double_value1, double_value2 Number Additional numeric values for extended command arguments. optional
string_argument String A string parameter for the command. optional

Return Value

  • `0` if the command was successfully executed.
  • `None` if an error occurs.

Examples

Open “File Open” dialog.

cmd_exec("File.Open_...");
id = cmd_get_id("File.Open_...");
cmd_exec(id);

Open G-code for small square.

cmd_exec("File.Open_Code", "G00 X0 Y0\nG01 X30\nG01 Y30\nG01 X0\nG01 Y0");

Set jogging speed to 100.

cmd_exec("Jog.Jog_Speed.Set", 100.0/60);

Turn output pin 3 on.

cmd_exec("Machine.Output", 3, 1);

Set output pin 6 to PWM to duty cycle 25% at frequency 10kHz.

cmd_exec("Machine.Output_PWM", 6, 25, 10000);

Set spindle override value to 120%.

cmd_exec("Machine.Override.Spindle.Reset", 1.2)

Set feed override value to 80%.

cmd_exec("Machine.Override.Feed.Reset", 0.8)

See also

expr/functions/func-cmd_exec.txt · Last modified: 2025/03/02 22:20 by andrej

Page Tools