在Dbox中的start_command中可以动态生成界面控件,但要在动态控件中再使用命令问题就很多。解决办法是通过调用宏或者使用字符串命令。下面是在字符串命令的解决方法:
控件创建:
"for variable=$_self.model object=(eval(db_descendants(0,'model',1,2)))", &
" if condition=(anym($_self.model.object_value.model_class.string_value == {'subsystem','testrig'}))", &
" if condition=($_self.model.object_value.model_class.string_value != 'testrig' && db_exists($_self.model.object_value.parent))", &
" var set var=$_self.cnt integer=(eval($_self.cnt + 1))", &
" var set var=$_self.subs object=(eval($_self.model[1])) index=(eval($_self.cnt))", &
" var set var=$_self.tmp_sub_name str=(eval($_self.model[1].name))", &
" var set var=$_self.tmp_str str=(eval(STR_CASE($_self.model[1].name, 2)))", &
" interface container create &", &
" container_name = (eval($_topgui.tc.c_stiffness.tc_stiffness//'.cont_sn_'//$_self.tmp_str)) &", &
" height = 357.0 &", &
" width = 496.0 &", &
" units = pixel &", &
" horiz_resizing = expand &", &
" vert_resizing = expand &", &
" tab_label = (eval($_self.tmp_sub_name)) ", &
生成命令:
" var set var=$_self.cmd index=1 str=(eval('interface toggle_button set toggle_button='//$_self.tog_sn_name//'_x state=(eval(on_off('//$_self.tog_sn_name//'.state)))' )) ", &
" var set var=$_self.cmd index=2 str=(eval('interface toggle_button set toggle_button='//$_self.tog_sn_name//'_y state=(eval(on_off('//$_self.tog_sn_name//'.state)))' )) ", &
" var set var=$_self.cmd index=3 str=(eval('interface toggle_button set toggle_button='//$_self.tog_sn_name//'_z state=(eval(on_off('//$_self.tog_sn_name//'.state)))' )) ", &
" var set var=$_self.cmd index=4 str=(eval('interface toggle_button set toggle_button='//$_self.tog_sn_name//'_rx state=(eval(on_off('//$_self.tog_sn_name//'.state)))' )) ", &
" var set var=$_self.cmd index=5 str=(eval('interface toggle_button set toggle_button='//$_self.tog_sn_name//'_ry state=(eval(on_off('//$_self.tog_sn_name//'.state)))' )) ", &
" var set var=$_self.cmd index=6 str=(eval('interface toggle_button set toggle_button='//$_self.tog_sn_name//'_rz state=(eval(on_off('//$_self.tog_sn_name//'.state)))' )) ", &
" interface toggle_button create &", &
" toggle_button_name = (eval($_self.tog_sn_name)) &", &
" location = 4.0, (eval($_self.pt_cnt*25+4)) &", &
" height = 25.0 &", &
" width = 216.0 &", &
" units = pixel &", &
" horiz_resizing = attach_left &", &
" vert_resizing = attach_top &", &
" label = (eval($_self.tmp_pt_name)) &", &
" state = off &", &
" on_value = 'yes' &", &
" off_value = 'no' &", &
" commands = (eval($_self.cmd)) ", &
效果图: