hexagon logo

Is it possible to call a python function from a user created dialog box?

Is it possible to call a python function from a user created dialog box?
  • Hi Todd!
    Yes.
    You can do that. and you may use the objects in the dialog box just like you would do in cmd.
     
    For example with:
    var set var=$_self.answer int=(eval(run_python_code("import my_python_module")))
    var set var=$_self.answer int=(eval(run_python_code("my_python_module.my_function($f_my_real_field_value)")))
    var set var=$_self.answer int=(eval(run_python_code("my_python_module.my_function('$f_my_str_field_value')")))
     
    or better yet you can switch the language to python and write python code there as it may be less hassle with the " and '
     
    language switch_to python
    import my_python_module
    my_python_module.my_function($f_my_real_field_value)
    my_python_module.my_function('$f_my_str_field_value')
    Adams.switchToCmd()
     
    Regards
    Thomas