Use Tcl Script to Write Callbacks

To access/modify properties of a TextField (or TextArea) whose instance name is mytext:

Property (Type) Getter/Setter Example
value Getter set strValue [::hw::pmgr::PmgrGetData 0 "mytext.value"];
Setter set strValue "ABC";

::hw::pmgr::PmgrSetData 0 "mytext.value" $strValue;

 
enable (true/false) Getter set bEnabled [::hw::pmgr::PmgrGetData 0 "mytext.enable"];
Setter ::hw::pmgr::PmgrSetData 0 "mytext.enable" true;
 
visible (true/false) Getter set bVisible [::hw::pmgr::PmgrGetData 0 "mytext.visible"];
Setter ::hw::pmgr::PmgrSetData 0 "mytext.visible" true;

To access/modify properties of a Button whose instance name is mybutton:

Property (Type) Getter/Setter Example
text Getter set strText [::hw::pmgr::PmgrGetData 0 "mybutton.text"];
Setter set strText "Import Model";

::hw::pmgr::PmgrSetData 0 "mybutton.text" $strText;

 
enable (true/false) Getter set bEnabled [::hw::pmgr::PmgrGetData 0 "mybutton.enable"];
Setter ::hw::pmgr::PmgrSetData 0 "mybutton.enable" true;
 
visible (true/false) Getter set bVisible [::hw::pmgr::PmgrGetData 0 "mybutton.visible"];
Setter ::hw::pmgr::PmgrSetData 0 "mybutton.visible" true;

To access/modify properties of a FileBrowser whose instance name is myfb:

Property (Type) Getter/Setter Example
value Getter set strFilename [::hw::pmgr::PmgrGetData 0 "myfb.value"];
Setter set strFilename "C:/altair/hw8.0/demos/hm/bumper.hm";

::hw::pmgr::PmgrSetData 0 "myfb.value" $ strFilename;

 
enable (true/false) Getter set bEnabled [::hw::pmgr::PmgrGetData 0 "myfb.enable"];
Setter ::hw::pmgr::PmgrSetData 0 "myfb.enable" true;
 
visible (true/false) Getter set bVisible [::hw::pmgr::PmgrGetData 0 "myfb.visible"];
Setter ::hw::pmgr::PmgrSetData 0 "myfb.visible" true;

To access/modify properties of a ComboBox whose instance name is mycombo:

Property (Type) Getter/Setter Example
value Getter set strSelected [::hw::pmgr::PmgrGetData 0 "mycombo.value"];
Setter set strSelected "Nastran";

::hw::pmgr::PmgrSetData 0 "mycombo.value" $ strSelected;

 
entries Getter set listEntries = [::hw::pmgr::PmgrGetData 0 "mycombo.entries"];

for {set nIdx 0} {$nIdx<[llength $listEntries]} {incr nIdx} {

set strEntry [lindex $listEntries $nIdx];

};

Setter set listEntries "Red {Green Color} Blue";

::hw::pmgr::PmgrSetData 0 "mycombo.entries" $ listEntries;

 
enable (true/false) Getter set bEnabled [::hw::pmgr::PmgrGetData 0 "mycombo.enable"];
Setter ::hw::pmgr::PmgrSetData 0 "mycombo.enable" true;
 
visible (true/false) Getter set bVisible [::hw::pmgr::PmgrGetData 0 "mycombo.visible"];
Setter ::hw::pmgr::PmgrSetData 0 "mycombo.visible" true;

To access/modify properties of a ListBox whose instance name is mylist:

Property (Type) Getter/Setter Example
value Getter set listSelected = [::hw::pmgr::PmgrGetData 0 "mylist.value"];

set strFirstSelected [lindex $listSelected 0];

Setter set listSelected "{LS Dyna} Abaqus";

::hw::pmgr::PmgrSetData 0 "mylist.entries" $ listSelected;

 
entries Getter set listEntries = [::hw::pmgr::PmgrGetData 0 "mylist.entries"];

for {set nIdx 0} {$nIdx<[llength $listEntries]} {incr nIdx} {

set strEntry [lindex $listEntries $nIdx];

};

Setter set listEntries "Red {Green Color} Blue";

::hw::pmgr::PmgrSetData 0 "mylist.entries" $ listEntries;

 
enable (true/false) Getter set bEnabled [::hw::pmgr::PmgrGetData 0 "mylist.enable"];
Setter ::hw::pmgr::PmgrSetData 0 "mylist.enable" true;
 
visible (true/false) Getter set bVisible [::hw::pmgr::PmgrGetData 0 "mylist.visible"];
Setter ::hw::pmgr::PmgrSetData 0 "mylist.visible" true;

To access/modify properties of a RadioButton whose instance name is myradio:

Property (Type) Getter/Setter Example
value Getter set strValue [::hw::pmgr::PmgrGetData 0 "myradio.value"];
Setter set strValue "Nastran";

::hw::pmgr::PmgrSetData 0 "myradio.value" $strValue;

 
enable (true/false) Getter set bEnabled [::hw::pmgr::PmgrGetData 0 "myradio.enable"];
Setter ::hw::pmgr::PmgrSetData 0 "myradio.enable" true;
 
visible (true/false) Getter set bVisible [::hw::pmgr::PmgrGetData 0 "myradio.visible"];
Setter ::hw::pmgr::PmgrSetData 0 "myradio.visible" true;

To access/modify properties of a CheckBox whose instance name is mycheckbox:

Property (Type) Getter/Setter Example
value Getter set Selected [::hw::pmgr::PmgrGetData 0 "mycheckbox.value"];
Setter ::hw::pmgr::PmgrSetData 0 "mycheckbox.value" true;
 
enable (true/false) Getter set bEnabled [::hw::pmgr::PmgrGetData 0 "mycheckbox.enable"];
Setter ::hw::pmgr::PmgrSetData 0 "mycheckbox.enable" true;
 
visible (true/false) Getter set bVisible [::hw::pmgr::PmgrGetData 0 "mycheckbox.visible"];
Setter ::hw::pmgr::PmgrSetData 0 "mycheckbox.visible" true;

To access/modify properties of a Label whose instance name is mylabel:

Property (Type) Getter/Setter Example
value Getter set strValue [::hw::pmgr::PmgrGetData 0 "mylabel.value"];
Setter set strValue "Import Model: ";

::hw::pmgr::PmgrSetData 0 "mylabel.value" $strValue;

 
visible (true/false) Getter set bVisible [::hw::pmgr::PmgrGetData 0 "mylabel.visible"];
Setter ::hw::pmgr::PmgrSetData 0 "mylabel.visible" true;

To send any message (command/query) to HyperWorks:

  Example
Prepare Message --
Send Message *readfile $filename;
Example 1
To get the selected file from the file browser (myfb) and set it on the text field (mytext), the following callback script will be written on the myfb’s OnClicked:

var filename = DataModel.GetValue("myfb");

DataModel.SetValue("mytext", filename);

Example 2
To get the HyperMesh file name from the text field (mytext) and send the command to HyperMesh to read the HyperMesh file, the following callback script will be written on the Apply button’s OnClicked:

var filename = DataModel.GetValue("mytext");

var command = "*readfile " + filename;

HyperWorks.SendMessage(command);

Note: Every Tcl command MUST be terminated by a semicolon (;).
for {set nIdx 0} {$nIdx<[llength $listEntries]} {incr nIdx} {
   set strEntry [lindex $listEntries $nIdx];
};  ## This semi colon is also VERY important.

To access/modify properties of a Slider whose instance name is mySlider:

Property (Type) Getter/Setter Example
Current Slider Value Getter set nCurr_val [::hw::pmgr::PmgrGetData 0 "mySlider.value"];
Setter set nCurr_val 20;

::hw::pmgr::PmgrSetData 0 "mySlider.value" $nCurr_val;

 
Orientation (Vertical / Horizontal ) Getter set strSlider_orientation [::hw::pmgr::PmgrGetData 0 "mySlider.orientation"];
Setter set strSlider_orientation "Vertical";

::hw::pmgr::PmgrSetData 0 "mySlider.orientation" $ strSlider_orientation;

 
Slider Intervals Getter set nSlider_interval [::hw::pmgr::PmgrGetData 0 "mySlider.tick_intervals"];
Setter set nSlider_interval 20;

::hw::pmgr::PmgrSetData 0 "mySlider.tick_intervals" $nSlider_interval;

 
Slider Max Getter set nSlider_max [::hw::pmgr::PmgrGetData 0 "mySlider.ticks_RangeMax"];
Setter set nSlider_max 200;

::hw::pmgr::PmgrSetData 0 "mySlider.ticks_RangeMax" $nSlider_max;

 
Slider Min Getter set nSlider_min [::hw::pmgr::PmgrGetData 0 "mySlider.ticks_RangeMin"];
Setter set nSlider_min 20;

::hw::pmgr::PmgrSetData 0 "mySlider.ticks_RangeMin" $nSlider_min;

 
Ticks Label Visibility (True/False) Getter set strSlider_ticks_label [::hw::pmgr::PmgrGetData 0 "mySlider.ticks_label"];
Setter set strSlider_ticks_label "False";

::hw::pmgr::PmgrSetData 0 "mySlider.ticks_label" $strSlider_ticks_label;

 
Tooltip Getter set strSlider_tooltip [::hw::pmgr::PmgrGetData 0 "mySlider.tooltip"];
Setter set strSlider_tooltip "This is Slider";

::hw::pmgr::PmgrSetData 0 "mySlider.tooltip" $strSlider_tooltip;

 
Visible (true/false) Getter set bSlider_visible [::hw::pmgr::PmgrGetData 0 "mySlider.visible"];
Setter set bSlider_visible true;

::hw::pmgr::PmgrSetData 0 "mySlider.visible" $bSlider_visible;

To access/modify properties of a Spinner whose instance name is mySpinner:

Property (Type) Getter/Setter Example
Current Slider Value Getter set nSpinner_curr_val [::hw::pmgr::PmgrGetData 0 "mySpinner.value"];
Setter set nSpinner_curr_val 10;

::hw::pmgr::PmgrSetData 0 "mySpinner.value" $nSpinner_curr_val;

 
Maximum Value Getter set nSpinner_max [::hw::pmgr::PmgrGetData 0 "mySpinner.maxspinnervalue"];
Setter set nSpinner_max 100;

::hw::pmgr::PmgrSetData 0 "mySpinner.maxspinnervalue" $nSpinner_max;

 
Minimum Value Getter set nSpinner_min [::hw::pmgr::PmgrGetData 0 "mySpinner.minspinnervalue"];
Setter set nSpinner_min 1;

::hw::pmgr::PmgrSetData 0 "mySpinner.minspinnervalue" $nSpinner_min;

 
Step Size Value Getter set nSpinner_step_size [::hw::pmgr::PmgrGetData 0 "mySpinner.stepsizevalue"];
Setter set nSpinner_step_size 5;

::hw::pmgr::PmgrSetData 0 "mySpinner.stepsizevalue" $nSpinner_step_size;

 
Tooltip Getter set strSpinner_tooltip [::hw::pmgr::PmgrGetData 0 "mySpinner.tooltip"];
Setter set strSpinner_tooltip "This is Spinner";

::hw::pmgr::PmgrSetData 0 "mySpinner.tooltip" $strSpinner_tooltip;

 
Visible (true/false) Getter set bSpinner_visible [::hw::pmgr::PmgrGetData 0 "mySpinner.visible"];
Setter set bSpinner_visible true;

::hw::pmgr::PmgrSetData 0 "mySpinner.visible" $bSpinner_visible;