hexagon logo

I have a dialogue box created where I am setting number of design variables. I want to display set variable values into respective fields upon displaying that dialogue box whenever I open model next time. What would be proper cmd command

I have a dialogue box created where I am setting number of design variables.
I want to display set variable values into respective fields upon displaying that dialogue box whenever I open model next time. What would be proper cmd command
  • Hi Skaka,
     
    In start_commands of dialog box put commands as follows:
    "var set var=$_self.model_obj obj=(eval(db_default(.system_defaults,\"model\")))", &
    " interface field set field=$_topgui.f_pinion_teeth_num_cyl   data=eval($_self.model_obj//\".pinion_teeth_number\"))", &
    ...
    Regards,
    Jan
     
  • Hello Mr. Jan
    It worked
    only small correction is there -  data=(eval($_self.model_obj//\".pinion_teeth_number\"))
  • Hello Mr. Jan,
     
    I appreciate the your response.
    May one more query, if it is possible to display all the variable with fewer lines of code may be with loops.
    Because I have large number of variables
     
    Thanks and Regards,
    Shriram
  • Hello Skaka,
     
    I do not have anything like that in hand. To initialize all fields in dbox I usually use following code - note the commands are in double quotes since it is an excerpt from start_commands block:
     
              "!--- Initialize Fields to zero", &
              "for var=$_Self.loop obj=(eval(db_children($_topgui.tabcont_1.cont_general,\"Graphic_Interface_Field\")))", &
              " interface field set field=(eval($_self.loop)) str=\"0.0\" ", &
              "end", &
     
    I hope you could elaborate on that with expanding those lines.
     
    Eventually you could make a list of variables with matching field object names so you could do something as below (macro code):
    var set var=$_self.model_obj obj=(eval(db_default(.system_defaults,\"model\")))
     
    !--- create list of variables
    variable set variable_name=$_topgui.var_list &
     string="var_01", &
         "var_02", &
         "var_03"
     
     
    !--- Make loop over all variables
    for var=$_self.loop start_value=1 end_value=(ROWS($_self.var_list))
     
     interface field set field=(eval($_topgui//$_self.var_list.string_value[$_self.loop]) )  data=(eval($_self.var_list.string_value[$_self.loop]) )", &
     
    end !--- End loop over variables
     
    Disclaimer: This code is not tested at all so it most probably does not work out of the box, please play around with string syntax to make Adams happy :)
     
    Hope that helps.
    Jan