#Property Browser version 3.2
#created by Rajasekaran Natarajan, Japan
#www.oocities.org/rajsekarann
#rajasekaran.natarajan <at> gmail.com
#This Property Browser GUI is based on Altair's
#material Browser available with Hyperworks written by Mr.Yaswant
$osTable configure -flashmode 0
#disable cells for props != Prop1
$osTable tag config cellsdisabled -state disabled
$osTable set 0,0 " "\
0,1 " Name"\
0,2 " PID"\
0,3 " Type"\
0,4 " MID"\
0,5 " A"\
0,6 " I1" \
0,7 " I2" \
0,8 " J" \
0,9 " Eqv.Section";
#
set i 1
foreach pid $propListId {
# #S NO
$osTable set $i,0 $i
#
# ## MAT ID
set comps(PID,$i) [hm_getentityvalue props $pid id 0
-byid]
if { $comps(PID,$i) == 0} {
set $comps(PID,$i) ""
}
# ## MAT NAME
if {$comps(PID,$i) > 0} {
set comps(PIDN,$i) [hm_getentityvalue
PROPERTIES $comps(PID,$i) name 1 -byid]
} else {
set comps(PIDN,$i) ""
}
set ::propDropVal($i) "$comps(PIDN,$i)"
# ## MAT TYPE
if {$comps(PID,$i) > 0} {
catch {set comps(PIDTi,$i)
[hm_attributeindexidentifier PROPERTIES $comps(PID,$i) 1]}
set val [info exist comps(PIDTi,$i)]
if {$val == 0} {
set comps(PIDTi,$i) 99999999
}
switch $comps(PIDTi,$i) {
107 {set comps(PIDTn,$i)
PBAR }
264 {set comps(PIDTn,$i)
PROD }
187 {set comps(PIDTn,$i)
PBEAM }
253 {set comps(PIDTn,$i)
PGAP }
186 {set comps(PIDTn,$i)
PELAS }
default {set
comps(PIDTn,$i) ""}
}
} else {
set comps(PIDTn,$i) ""
}
#
$osTable set $i,1 $comps(PIDN,$i)
$osTable set $i,2 $comps(PID,$i)
$osTable set $i,3 $comps(PIDTn,$i)
#
if {$comps(PIDTn,$i) == "PBAR"} {
set comps(PID,MID,$i) [hm_getentityvalue props
$comps(PID,$i) materialid 0 -byid]
set comps(PID,A,$i) [format "%6.2f"
[hm_getentityvalue props $comps(PID,$i) "\$PBAR_A" 0 -byid] ]
set comps(PID,I1,$i) [format "%3.4e"
[hm_getentityvalue props $comps(PID,$i) "\$PBAR_I1" 0 -byid] ]
set comps(PID,I2,$i) [format "%3.4e"
[hm_getentityvalue props $comps(PID,$i) "\$PBAR_I2" 0 -byid] ]
set comps(PID,J,$i) [format "%3.4e"
[hm_getentityvalue props $comps(PID,$i) "\$PBAR_J" 0 -byid] ]
# ##This sect roughly gives the equivalaent section of
circulat cross section
if {$comps(PID,A,$i) != "0"} {
#set pival [expr 2*asin(1.0)]
#set eqDia
[expr ceil(sqrt ((4 * $comps(PID,A,$i) ) / $pival))]
#set str "CIRC
"
#append str
$eqDia
#set comps(PID,SECT,$i) $str
set str [os::props::getSection
$comps(PIDN,$i) $comps(PID,A,$i) $comps(PID,I1,$i) $comps(PID,I2,$i)]
set comps(PID,SECT,$i) $str
}
#
if {$comps(PID,MID,$i) != "0"} {
$osTable set $i,4
$comps(PID,MID,$i)
} else {set comps(PID,MID,$i) "";
$osTable set $i,4 $comps(PID,MID,$i)}
if {$comps(PID,A,$i) != "0"} {
$osTable set $i,5 $comps(PID,A,$i)
} else {set comps(PID,A,$i) "";
$osTable set $i,5 $comps(PID,A,$i)}
if {$comps(PID,I1,$i) != "0"} {
$osTable set $i,6
$comps(PID,I1,$i)
} else {set comps(PID,I1,$i) "";
$osTable set $i,6 $comps(PID,I1,$i)}
if {$comps(PID,I2,$i) != "0"} {
$osTable set $i,7
$comps(PID,I2,$i)
} else {set comps(PID,I2,$i) "";
$osTable set $i,7 $comps(PID,I2,$i)}
if {$comps(PID,J,$i) != "0"} {
$osTable set $i,8 $comps(PID,J,$i)
} else {set comps(PID,J,$i) "";
$osTable set $i,8 $comps(PID,J,$i)}
if {$comps(PID,SECT,$i) != "0"} {
$osTable set $i,9
$comps(PID,SECT,$i)
} else {set comps(PID,SECT,$i)
""; $osTable set $i,9 $comps(PID,SECT,$i)}
#
} elseif {$comps(PIDTn,$i) == "PROD"} {
#tk_messageBox -icon info
-message "Hi Raja!!!"
set comps(PID,MID,$i) [hm_getentityvalue props
$comps(PID,$i) materialid 0 -byid]
set comps(PID,A,$i) [format "%6.2f"
[hm_getentityvalue props $comps(PID,$i) "\$PROD_A" 0 -byid]]
set comps(PID,I1,$i) ""
set comps(PID,I2,$i) ""
set comps(PID,J,$i) ""
if {$comps(PID,A,$i) != "0"} {
set pival [expr 2*asin(1.0)]
set eqDia
[expr ceil(sqrt ((4 * $comps(PID,A,$i) ) / $pival))]
set str "CIRC "
append str
$eqDia
set comps(PID,SECT,$i) $str
puts $comps(PID,SECT,$i)
}
if {$comps(PID,MID,$i) != "0"} {
$osTable set $i,4
$comps(PID,MID,$i)
} else {set comps(PID,MID,$i) "";
$osTable set $i,4 $comps(PID,MID,$i)}
if {$comps(PID,A,$i) != "0"} {
$osTable set $i,5 $comps(PID,A,$i)
} else {set comps(PID,A,$i) "";
$osTable set $i,5 $comps(PID,A,$i)}
if {$comps(PID,SECT,$i) != "0"} {
$osTable set $i,9
$comps(PID,SECT,$i)
} else {set comps(PID,SECT,$i)
""; $osTable set $i,9 $comps(PID,SECT,$i)}
} elseif {$comps(PIDTn,$i) == "PBEAM"} {
#tk_messageBox -icon info
-message "Hi PBeam!!!"
set comps(PID,MID,$i) [hm_getentityvalue props
$comps(PID,$i) materialid 0 -byid]
set comps(PID,A,$i) [format "%6.2f"
[hm_getentityvalue props $comps(PID,$i) "\$PBEAM_Aa" 0 -byid]]
set comps(PID,I1,$i) [format "%3.4e"
[hm_getentityvalue props $comps(PID,$i) "\$PBEAM_I1a" 0 -byid]]
set comps(PID,I2,$i) [format "%3.4e"
[hm_getentityvalue props $comps(PID,$i) "\$PBEAM_I2a" 0 -byid]]
set comps(PID,J,$i) [format "%3.4e"
[hm_getentityvalue props $comps(PID,$i) "\$PBEAM_Ja" 0 -byid]]
if {$comps(PID,A,$i) != "0"} {
set str [os::props::getSection
$comps(PIDN,$i) $comps(PID,A,$i) $comps(PID,I1,$i) $comps(PID,I2,$i)]
set comps(PID,SECT,$i) $str
}
if {$comps(PID,MID,$i) != "0"} {
$osTable set $i,4
$comps(PID,MID,$i)
} else {set comps(PID,MID,$i) "";
$osTable set $i,4 $comps(PID,MID,$i)}
if {$comps(PID,A,$i) != "0"} {
$osTable set $i,5 $comps(PID,A,$i)
} else {set comps(PID,A,$i) "";
$osTable set $i,5 $comps(PID,A,$i)}
if {$comps(PID,I1,$i) != "0"} {
$osTable set $i,6
$comps(PID,I1,$i)
} else {set comps(PID,I1,$i) "";
$osTable set $i,6 $comps(PID,I1,$i)}
if {$comps(PID,I2,$i) != "0"} {
$osTable set $i,7
$comps(PID,I2,$i)
} else {set comps(PID,I2,$i) "";
$osTable set $i,7 $comps(PID,I2,$i)}
if {$comps(PID,J,$i) != "0"} {
$osTable set $i,8 $comps(PID,J,$i)
} else {set comps(PID,J,$i) "";
$osTable set $i,8 $comps(PID,J,$i)}
if {$comps(PID,SECT,$i) != "0"} {
$osTable set $i,9
$comps(PID,SECT,$i)
} else {set comps(PID,SECT,$i)
""; $osTable set $i,9 $comps(PID,SECT,$i)}
} else {
set comps(PID,MID,$i) ""
set comps(PID,A,$i) ""
set comps(PID,I1,$i) ""
set comps(PID,I2,$i) ""
set comps(PID,J,$i) ""
set comps(PID,SECT,$i) ""
#
$osTable set $i,4 $comps(PID,MID,$i)
$osTable set $i,5 $comps(PID,A,$i)
$osTable set $i,6 $comps(PID,I1,$i)
$osTable set $i,7 $comps(PID,I2,$i)
$osTable set $i,8 $comps(PID,J,$i)
$osTable set $i,9 $comps(PID,SECT,$i)
#
$osTable tag cell cellsdisabled $i,4
$osTable tag cell cellsdisabled $i,5
$osTable tag cell cellsdisabled $i,6
$osTable tag cell cellsdisabled $i,7
$osTable tag cell cellsdisabled $i,8
$osTable tag cell cellsdisabled $i,9
}
incr i
}
#
#
$osTable tag config colstatedisabled -state disabled
$osTable tag col colstatedisabled 3 9
$osTable configure -flashmode 1
#
}
variable osTable
variable ostemplate
global comps
set win_x [winfo pointerx .os_props]
set win_y [winfo pointery .os_props]
set ovalue [string trim $ovalue]
set nvalue [string trim $nvalue]
set row [lindex [split $index ,] 0]
set col [lindex [split $index ,] 1]
# tk_messageBox -message "Index: $index, Orig Val:
$ovalue, New Val: $nvalue \n \
# row:
$row, col: $col \n \
# orig St
len: [string length $ovalue], new St len: [string length $nvalue]"
hm_markclear props 1
hm_createmark props 1 advanced all
set proplistId [hm_getmark props 1]
set proplistName ""
foreach pId $proplistId {
lappend proplistName [hm_getcollectorname
props $pId]
}
switch $col {
1 {
#tk_messageBox -message "In
Property Name"
if { $nvalue != $ovalue} {
if
{$nvalue != ""} {
if {[lsearch $proplistName $nvalue] == -1} {
catch {*renamecollector props "$ovalue" "$nvalue" }
#destroy .os_props
os::props::getPropData all
tk_messageBox -message "Property Renamed."
} else {tk_messageBox -message "Property name already exists.";$osTable
set $index $ovalue}
} else {$osTable set $index $ovalue}
}
}
2 {
#tk_messageBox -message "In
Property ID"
if {$uChoice == 0} {
if { $nvalue !=
$ovalue} {
if {$nvalue != "" || $nvalue == 0} {
if {[lsearch $proplistId $nvalue] == -1} {
hm_markclear props 1
#
*createmark props 1 $ovalue
hm_createmark props 1 "by id only" $ovalue
catch {*renumber props 1 "$nvalue" 1 0 0 }
os::props::getPropData all
tk_messageBox -message "Property card renumbered."
} else {tk_messageBox -message "Property ID already exists.";$osTable
set $index $ovalue}
} else {$osTable set $index $ovalue}
}
}
}
4 {
#tk_messageBox -message
$nvalue
if {$uChoice == 0} {
if { $nvalue != $ovalue} {
if {$nvalue != ""} {
set mname
[hm_getcollectorname mats $nvalue]
hm_markclear props 2
hm_createmark props 2 "by
id only" $comps(PIDN,$row)
set propid [hm_getmark
props 2]
*materialupdate properties
2 $mname
tk_messageBox -message
"Material id updated."
os::props::getPropData all
} else {$osTable set
$index $ovalue}
}
}
}
5 {
#Area
if { $nvalue != $ovalue} {
if
{$nvalue != ""} {
hm_markclear props 2
puts $row
hm_createmark props 2 "by id only" $comps(PID,$row)
set propid [hm_getmark props 2]
*dictionaryload props 2 "$os::globl(ostemplate)" "PBAR"
*attributeupdatedouble props $propid 68 1 2 0 $nvalue
tk_messageBox -message "Area value updated."
os::props::getPropData all
} else {$osTable set $index $ovalue}
}
}
6 {
#I1
if { $nvalue != $ovalue} {
if
{$nvalue != ""} {
hm_markclear properties 2
hm_createmark props 2 "by id only" $comps(PID,$row)
set propid [hm_getmark props 2]
*dictionaryload properties 2 "$os::globl(ostemplate)" "PBAR"
*attributeupdatedouble properties $propid 69 1 2 0 $nvalue
tk_messageBox -message "I1 value updated."
os::props::getPropData all
} else {$osTable set $index $ovalue}
}
}
7 {
#I2
if { $nvalue != $ovalue} {
if
{$nvalue != ""} {
hm_markclear properties 2
hm_createmark props 2 "by id only" $comps(PID,$row)
set propid [hm_getmark props 2]
*dictionaryload properties 2 "$os::globl(ostemplate)" "PBAR"
*attributeupdatedouble properties $propid 70 1 2 0 $nvalue
tk_messageBox -message "I2 value updated."
os::props::getPropData all
} else {$osTable set $index $ovalue}
}
}
8 {
#J
if { $nvalue != $ovalue} {
if
{$nvalue != ""} {
hm_markclear properties 2
hm_createmark props 2 "by id only" $comps(PID,$row)
set propid [hm_getmark props 2]
*dictionaryload properties 2 "$os::globl(ostemplate)" "PBAR"
*attributeupdatedouble properties $propid 71 1 2 0 $nvalue
tk_messageBox -message "J value updated."
os::props::getPropData all
} else {$osTable set $index $ovalue}
}
}
9 {
#TREF
if { $nvalue != $ovalue} {
if
{$nvalue != ""} {
hm_markclear properties 2
#
*createmark properties 2 "$comps(MIDN,$row)"
hm_createmark props 2 "by id only" $comps(PID,$row)
set propid [hm_getmark props 2]
*dictionaryload properties 2 "$os::globl(ostemplate)" "MAT1"
*attributeupdatedouble properties $matid 6 1 1 0 $nvalue
tk_messageBox -message "TREF value updated."
os::props::getPropData all
} else {$osTable set $index $ovalue}
}
}
}
}
proc os::props::infoAbout {} {
set aboutMsg {
This Nastran Property browser is written by me, \
Rajasekaran Natarajan Kawasaki, Tokyo, Japan \
Email:rajasekaran.natarajan@gmail.com
This program based on already available Material Browser created by
Yeshwant Mummaneni, Altair Inc. \
If you face any problem or need some more options let me know, \
This program tested to my abilities but not rigorously, as this is
create-on-the-run-program. \
so use it with your own risk. [No gurantee attached]
The Equivalent section option is inspired by similar section
recognition from I-DEAS, SDRC. \
It recognises Circular or Rectangular sections [or Approximates a
Section] \
when a section does not satisfies both these categories then it
classifies it as OTHER \
Possible Improvements:
I-section recongnition and more can be included.\
The Sections Can be used to create Hyperbeam Database as \
this opens the door for many many functionalities in HM.
}
set width 500
set height 250
set geom "[set width]x[set height]"
set mainwin [::hwt::CreateWindow macroWindow \
windowTitle "Convert" \
cancelButton "Cancel" \
cancelFunc "" \
geometry $geom \
propagate 1 \
resizeable 0 0 \
noGeometrySaving \
destroyOnUnpost \
maxSize 700 650 \
minSize $width $height]
set Recess [ ::hwt::WindowRecess macroWindow];
set mainframe [frame $Recess.mainframe -bd 0 -relief
flat]
pack $mainframe -anchor nw -fill x -side top -padx 7
-pady 6
set messageframe [frame $Recess.msgframe -bd 0
-relief flat]
pack $messageframe -anchor nw -fill x -side top
-padx 7 -pady 4
set text_help [text $messageframe.textw -font
[::hwt::AppFont] -wrap word -width 150 -height 70];
pack $text_help -side right -padx 7 -pady 4 -fill
both -expand true;
$text_help insert end $aboutMsg
PostWindow macroWindow
#tk_messageBox -icon info -message $aboutMsg
}
proc os::props::getSection {pn pA i1 i2 } {
variable osTable
variable ostemplate
global comps
set pname [string trim $pn]
set area [string trim $pA]
set ixx [string trim $i1]
set iyy [string trim $i2]
set izz [expr $i1+$i2]
#tk_messageBox -message "$pA $i1 $i2"
#finding equivalent circular section
set eqCirDia [expr round(sqrt ((4 * $area ) /
$pival))]
set eqCirIxx [expr $pival * pow($eqCirDia,4)/ 64]
set eqCirIzz [expr $eqCirIxx * 2]
set errCixx [expr abs(($ixx - $eqCirIxx)*100/$ixx)]
set errCizz [expr abs(($izz - $eqCirIzz)*100/$izz)]
#puts [format
"%15s\t%2.2f\t%2.3e\t%2.3e\t%2.3e\t%2.3e\t%3.3f\t%3.3f" $pname
$eqCirDia $ixx $izz $eqCirIxx $eqCirIzz $errCixx $errCizz]
#finding equivalane rectangular section
set rectd [expr round( sqrt( abs( 12 * $ixx /
$area)))]
set rectb [expr round($area/$rectd)]
set eqRectA [expr $rectb * $rectd]
set eqRectIxx [expr $rectb * pow($rectd,3)/12]
set eqRectIyy [expr $rectd * pow($rectb,3)/12]
set eqRectIzz [expr
$rectb*$rectd/3*(pow($rectb,2)+pow($rectd,2))]
set errRixx [expr abs(($ixx - $eqRectIxx)*100/$ixx)]
set errRiyy [expr abs(($iyy - $eqRectIyy)*100/$iyy)]
set errRizz [expr abs(($izz - $eqRectIzz)*100/$izz)]
#puts [format
"%15s\t%2.2f\t%2.2f\t%2.3e\t%2.3e\t%2.3e" $pname $rectb $rectd $ixx
$iyy $izz]
#puts [format
"\t\t\t\t%2.3e\t%2.3e\t%2.3e\t%5.2f\t%5.2fe" $eqRectIxx $eqRectIyy
$eqRectIzz $errRixx $errRiyy]
if { ($errRiyy < $errCixx) && ($errRiyy
< 5)} {
set secStr "RECT"
set secDim [format "%2.1fx%2.1f"
$rectb $rectd]
set mySect [concat $secStr
$secDim]
return $mySect
} elseif { $errCixx < 5 } {
set secStr "CIRC"
set secDim [format "%2.2f"
$eqCirDia]
set mySect [concat $secStr
$secDim]
return $mySect
} else {
set mySect "OTHER"
return $mySect
}
}
}
##---
proc os::props::createGUI {rows} {
if {[array exists fram]} {unset fram}
set ::proptablerows $rows
set winwidth [expr {int([hm_winfo graphicwidth] * 1.0)}]
set xpos [expr {int([hm_winfo x] + 0.0)}]
set ypos [expr {int([hm_winfo y] + [hm_winfo graphicheight] -
43)}]
#set ypos [expr {int([hm_winfo y] + [hm_winfo graphicheight] -
0)}]
set hmmenuHeight [expr {(10.0 + ( [hm_winfo height] - [hm_winfo
graphicheight] ) / 1.0)}]
set winheight [ expr {int($hmmenuHeight) - 1}]
toplevel .os_props
set w .os_props
wm geometry $w ${winwidth}x$winheight+$xpos+[expr
{int($ypos) + 3}]
wm withdraw .os_props
wm title $w "Propertiess"
set fram(lab) [frame $w.fram(lab)]
set fram(tab) [frame $w.fram(tab)]
set fram(but) [frame $w.fram(but)]
pack $fram(lab) -padx 5 -pady 5 -fill both -expand 1
pack $fram(tab) -padx 5 -fill both -expand 1
pack $fram(but) -padx 5 -pady 5 -fill both -expand 1
set fram(lab1) [frame $fram(lab).fram(lab1)]
set fram(lab2) [frame $fram(lab).fram(lab2)]
pack $fram(lab1) -side left -fill x -expand 1 -in
$fram(lab)
pack $fram(lab2) -side right -fill x -expand 1 -in
$fram(lab)
set select_allButton [button $fram(lab1).select_allButton
-text "Select All" -width 15 -command {
global chkFlag c
if {$chkFlag == 0} {
#tk_messageBox -message "0"
for {set i 1}
{$i < $::proptablerows} {incr i} {
set c($i) 1
$os::props::osTable tag row rowstatedelete $i
}
set chkFlag 1
} else {
#tk_messageBox -message "1"
for {set i 1}
{$i < $::proptablerows} {incr i} {
set c($i) 0
$os::props::osTable tag row rowhighlightnormal $i
}
set chkFlag 0
}
}];
scrollbar $win.sx -orient h -command "$osTable
xview";
scrollbar $win.sy -orient v -command "$osTable
yview";
pack $win.sy -side right -fill y -padx 5
pack $win.sx -side top -fill x -padx 5
pack $osTable -fill both -side top -before $win.sx
-expand 1 -padx 5
$osTable tag configure "title" -fg black -bg #90ee90
-relief raised ;
$osTable tag configure "sel" -relief sunken -fg
black -bg white;
$osTable tag config active -bg navy -fg white;
global chk but c disabledrows selectedC chkFlag display numberOfComps
set chkFlag 0
if {[array exists chk]} {unset chk}
if {[array exists c]} {unset c}
$osTable tag config rowstatedisabled -state disabled -bg salmon
$osTable tag config rowstatedelete -bg salmon
$osTable tag config rowhighlight -bg lavender
$osTable tag config rowhighlightnormal
$osTable tag config rightjustify -anchor e
$osTable tag col rightjustify 2 4 5 6 7 8 9
#$osTable tag col rowstatedisabled 4 8
set disabledrows ""
set selectedC ""
set display ""
#$osTable tag row rowhighlight $selectedC
for {set i 1} {$i < $rows} {incr i} {
set fram($i) [frame $osTable.fram($i)]
set chk($i) [checkbutton $osTable.chk($i) -variable "c($i)"
-command {
global chk disabledrows
#get checked boxes
set display ""
for {set i 1} {$i <
$::proptablerows} {incr i} {
if {$c($i)
== 1} {
$os::props::osTable tag row rowstatedelete $i
} else
{$os::props::osTable tag row rowhighlightnormal $i}
}
}]
set but($i) [button $osTable.but($i) -text "x" -bg salmon \
-command {
global comps chk disabledrows
#get
checked boxes
set
selectedprops ""
for
{set i 1} {$i < $::proptablerows} {incr i} {
if {$c($i) == 1} {
lappend selectedprops $comps(PID,$i)
set c($i) 0
}
}