Rename all the entities in a model using TCL script.
Altair Forum User
Altair Employee
Answers
-
proc rename_things { } {variable sFromvariable sTovariable colValuesforeach col [array names colValues] {if {$colValues($col) == 1} {foreach setName [hm_entitylist $col name] {if {[set newName [string map [list $sFrom $sTo] $setName]]!= $setName} {catch {*renamecollector $col $setName $newName}}}}}}proc initColNames { } {variable colNamesset colNames(nameList) [list comps props materials loadcols sets groups beamsectcols systemcols shapes vectorcols]set colNames(comps) 'Components'set colNames(props) 'Propertys'set colNames(materials) 'Materials'set colNames(loadcols) 'Load Collectors'set colNames(groups) 'Groups'set colNames(beamsectcols) 'Beam Section Collectors'set colNames(systemcols) 'System Collectors'set colNames(vectorcols) 'Vector Collectors'set colNames(shapes) 'Shapes'set colNames(sets) 'Entity Sets'}proc buildGUI { } {variable colNamesvariable sFromvariable sTovariable colValuesset sFrom ''set sTo ''set curNs [namespace current]# destroy window if it already existif {[winfo exists .build_renameGui]} {destroy .build_renameGui}# create windowset build_expand [ hwt::CreateWindow build_renameGui \-windowtitle 'Modify Names : Altair Hyd' \-post \-noGeometrySaving \-geometry 260x320 \-minSize 260 320 \-noCommandArea \]::hwt::KeepOnTop $build_expandset build_expandPanel [hwt::WindowRecess $build_expand];# okCancleFrameset okcanFrame [frame $build_expand.ok]pack $okcanFrame -side top -anchor eset okButton [button $okcanFrame.ok -width 10 -text ' OK ' -command 'destroy .build_renameGui; ${curNs}::rename_things']set cancelButton [button $okcanFrame.cancel -width 10 -text 'Discard' -command { destroy .build_renameGui; } ]pack $cancelButton $okButton -side right -padx 4 -pady 4 -anchor e# build framset stringsFrame [frame $build_expandPanel.stringsframe]pack $stringsFrame -side top -anchor nset labelFrom [label $stringsFrame.labelfrom -text 'Search for:' ]set valueFrom [entry $stringsFrame.valuefrom -textvariable ${curNs}::sFrom -width 25]grid $labelFrom -row 0 -column 0 -columnspan 2 -padx 5 -sticky egrid $valueFrom -row 0 -column 2 -padx 5 -sticky wset labelTo [label $stringsFrame.labelto -text 'Replace with:' ]set valueTo [entry $stringsFrame.valueto -textvariable ${curNs}::sTo -width 25]grid $labelTo -row 1 -column 0 -columnspan 2 -padx 5 -sticky egrid $valueTo -row 1 -column 2 -padx 5 -sticky wset colFrame [hwt::LabeledFrame $build_expandPanel.colframe ' Affected Entitys: ' \-side left -anchor nw -padx 2 -pady 10 -justify left ]set row 2array unset colValuesforeach col $colNames(nameList) {set colValues(${col}) 0# Default wert...set label [label $colFrame.label$col -text $colNames($col)]set check [checkbutton $colFrame.check$col -variable ${curNs}::colValues(${col}) -onvalue 1]grid $check -row $row -column 0 -padx 2grid $label -row $row -column 1 -padx 2 -sticky wincr row#foreach}return 1}## end proc buildGUIproc ::run {args} {initColNamesbuildGUI}run 0
0 -
you can rename its work like textpad, it replaces property name material name also
0