# # Copyright 2007 (c) Pointwise, Inc. # All rights reserved. # # This sample Gridgen script is not supported by Pointwise, Inc. # It is provided freely for demonstration purposes only. # SEE THE WARRANTY DISCLAIMER AT THE BOTTOM OF THIS FILE. # # WhatsInMyDatabase.glf # Print various information about a database in Gridgen # # History: # 02 Jan 2007 - File name written to shell window. # 29 Dec 2006 - File now written to directory from which script was run. # 30 Apr 2006 - Results now written to a file instead of stdout. # # To Do List: # write results to a csv file (to import into Excel for sorting, etc.) # number of intervals, polynomial degree of parametric entities # group membership # components of each quilt and model set scriptDir [file dirname [info script]] set fname "WhatsInMyDatabase.out" set fullname [file join $scriptDir $fname] set fileID [open $fullname w] ######################################################################## puts $fileID "" puts $fileID "--- What's in my database? ---" puts $fileID "--- A Glyph Script for Gridgen ---" puts $fileID "" # get the DB set DB [gg::dbGetAll] # print number of entities set n_entities [llength $DB] if { $n_entities <= 0 } { puts $fileID "Nothing." puts $fileID "" exit } elseif { $n_entities == 1 } { puts $fileID "Only $n_entities entity." } else { puts $fileID "There are $n_entities entities total." } puts $fileID "" ######################################################################## # count the number of layers used set n_layers_used 0 set layer_list "" set n_Layers [gg::dbLayerGetNum] for {set i 0} {$i < $n_Layers} {incr i} { if { [gg::dbLayerNumEnts $i] > 0 } { incr n_layers_used lappend layer_list $i } } #if { $n_layers_used == 1 } { # puts $fileID "All entities are in layer $layer_list." #} else { # puts $fileID "The entities are in $n_layers_used layers: $layer_list" #} # get the enable/disable status puts $fileID "Entity Count By Layer" puts $fileID "-----------------------------------------------------" set Able [gg::dbEnable $DB] set n_enabled 0 set n_disabled 0 foreach a $Able { if { $a } { incr n_enabled } else { incr n_disabled } } # enabled/disabled entities per layer puts $fileID "layer description enabled disabled total" puts $fileID "----- ------------------------ ------- -------- -----" foreach layer $layer_list { set descrip [gg::dbLayerText $layer] set n_able [gg::dbLayerNumEnts $layer -enabled_only] set n_dis [gg::dbLayerNumEnts $layer -disabled_only] set n_tot [expr $n_able + $n_dis] puts $fileID [format "%5d %24s %7d %8d %5d" $layer $descrip $n_able $n_dis $n_tot] } puts $fileID "----- ------------------------ ------- -------- -----" puts $fileID [format "%5d %24s %7d %8d %5d" $n_layers_used "" $n_enabled $n_disabled $n_entities] puts $fileID "" ######################################################################## # initialize entity type count set n_type(bcurve) 0 set n_type(boundary) 0 set n_type(boundsurf) 0 set n_type(bsurface) 0 set n_type(circle) 0 set n_type(color) 0 set n_type(composite) 0 set n_type(conesurf) 0 set n_type(conic) 0 set n_type(copius) 0 set n_type(curvonsurf) 0 set n_type(cylsurf) 0 set n_type(group) 0 set n_type(line) 0 set n_type(model) 0 set n_type(name) 0 set n_type(note) 0 set n_type(offcurve) 0 set n_type(offsurf) 0 set n_type(pcurve) 0 set n_type(plane) 0 set n_type(planesurf) 0 set n_type(point) 0 set n_type(psurface) 0 set n_type(quilt) 0 set n_type(ruledsurf) 0 set n_type(shell) 0 set n_type(spheresurf) 0 set n_type(subfig_defn) 0 set n_type(subfig_inst) 0 set n_type(surfrevo) 0 set n_type(tabcyl) 0 set n_type(toroidsurf) 0 set n_type(trimsurf) 0 set n_type(unknown) 0 # count entity types foreach e $DB { set t [gg::dbQuery $e TYPE] switch $t { BCURVE { incr n_type(bcurve) } BOUNDARY { incr n_type(boundary) } BOUNDSURF { incr n_type(boundsurf) } BSURFACE { incr n_type(bsurface) } CIRCLE { incr n_type(circle) } COLOR { incr n_type(color) } COMPOSITE { incr n_type(composite) } CONESURF { incr n_type(conesurf) } CONIC { incr n_type(conic) } COPIUS { incr n_type(copius) } CURVONSURF { incr n_type(curvonsurf) } CYLSURF { incr n_type(cylsurf) } GROUP { incr n_type(group) } LINE { incr n_type(line) } MODEL { incr n_type(model) } NAME { incr n_type(name) } NOTE { incr n_type(note) } OFFCURV { incr n_type(offcurve) } OFFSURF { incr n_type(offsurf) } PCURVE { incr n_type(pcurve) } PLANE { incr n_type(plane) } PLANESURF { incr n_type(planesurf) } POINT { incr n_type(point) } PSURFACE { incr n_type(psurface) } QUILT { incr n_type(quilt) } RULEDSURF { incr n_type(ruledsurf) } SHELL { incr n_type(shell) } SPHERESURF { incr n_type(spheresurf) } SUBFIG_DEFN { incr n_type(subfig_defn) } SUBFIG_INST { incr n_type(subfig_inst) } SURFREVO { incr n_type(surfrevo) } TABCYL { incr n_type(tabcyl) } TOROIDSURF { incr n_type(toroidsurf) } TRIMSURF { incr n_type(trimsurf) } UNKNOWN { incr n_type(unknown) } } } # print entity type count puts $fileID "Entity Count By Type" puts $fileID "---------------------------------" set form1 "%6d %s" puts $fileID " count type" puts $fileID "------ --------------------------" if { $n_type(bcurve) > 0 } { puts $fileID [format $form1 $n_type(bcurve) "B-spline curves"] } if { $n_type(boundary) > 0 } { puts $fileID [format $form1 $n_type(boundary) "Boundaries"] } if { $n_type(boundsurf) > 0 } { puts $fileID [format $form1 $n_type(boundsurf) "Bounded surfaces"] } if { $n_type(bsurface) > 0 } { puts $fileID [format $form1 $n_type(bsurface) "B-spline surfaces"] } if { $n_type(circle) > 0 } { puts $fileID [format $form1 $n_type(circle) "Circles"] } if { $n_type(color) > 0 } { puts $fileID [format $form1 $n_type(color) "Colors"] } if { $n_type(composite) > 0 } { puts $fileID [format $form1 $n_type(composite) "Composite curves"] } if { $n_type(conesurf) > 0 } { puts $fileID [format $form1 $n_type(conesurf) "Conical surfaces"] } if { $n_type(conic) > 0 } { puts $fileID [format $form1 $n_type(conic) "Conic sections"] } if { $n_type(copius) > 0 } { puts $fileID [format $form1 $n_type(copius) "Copious data"] } if { $n_type(curvonsurf) > 0 } { puts $fileID [format $form1 $n_type(curvonsurf) "Curves on surface"] } if { $n_type(cylsurf) > 0 } { puts $fileID [format $form1 $n_type(cylsurf) "Cylindrical surfaces"] } if { $n_type(group) > 0 } { puts $fileID [format $form1 $n_type(group) "Groups"] } if { $n_type(line) > 0 } { puts $fileID [format $form1 $n_type(line) "Lines"] } if { $n_type(model) > 0 } { puts $fileID [format $form1 $n_type(model) "Models"] } if { $n_type(name) > 0 } { puts $fileID [format $form1 $n_type(name) "Names"] } if { $n_type(note) > 0 } { puts $fileID [format $form1 $n_type(note) "Notes"] } if { $n_type(offcurve) > 0 } { puts $fileID [format $form1 $n_type(offcurve) "Offset curves"] } if { $n_type(offsurf) > 0 } { puts $fileID [format $form1 $n_type(offsurf) "Offset surfaces"] } if { $n_type(pcurve) > 0 } { puts $fileID [format $form1 $n_type(pcurve) "Parametric curves"] } if { $n_type(plane) > 0 } { puts $fileID [format $form1 $n_type(plane) "Planes" ] } if { $n_type(planesurf) > 0 } { puts $fileID [format $form1 $n_type(planesurf) "Planar surfaces" ] } if { $n_type(point) > 0 } { puts $fileID [format $form1 $n_type(point) "Points" ] } if { $n_type(psurface) > 0 } { puts $fileID [format $form1 $n_type(psurface) "Parametric surfaces" ] } if { $n_type(quilt) > 0 } { puts $fileID [format $form1 $n_type(quilt) "Quilts" ] } if { $n_type(ruledsurf) > 0 } { puts $fileID [format $form1 $n_type(ruledsurf) "Ruled surfaces" ] } if { $n_type(shell) > 0 } { puts $fileID [format $form1 $n_type(shell) "Shells" ] } if { $n_type(spheresurf) > 0 } { puts $fileID [format $form1 $n_type(spheresurf) "Spherical surfaces" ] } if { $n_type(subfig_defn) > 0 } { puts $fileID [format $form1 $n_type(subfig_defn) "Subfigure definitions" ] } if { $n_type(subfig_inst) > 0 } { puts $fileID [format $form1 $n_type(subfig_inst) "Subfigure instances" ] } if { $n_type(surfrevo) > 0 } { puts $fileID [format $form1 $n_type(surfrevo) "Revolution surfaces" ] } if { $n_type(tabcyl) > 0 } { puts $fileID [format $form1 $n_type(tabcyl) "Tabulated cylinders" ] } if { $n_type(toroidsurf) > 0 } { puts $fileID [format $form1 $n_type(toroidsurf) "Toroidal surfaces" ] } if { $n_type(trimsurf) > 0 } { puts $fileID [format $form1 $n_type(trimsurf) "Trimmed surfaces" ] } if { $n_type(unknown) > 0 } { puts $fileID [format $form1 $n_type(unknown) "Unknown" ] } puts $fileID "---------------------------------" set n_all_types [ expr \ $n_type(bcurve) + $n_type(boundary) + $n_type(boundsurf) + \ $n_type(bsurface) + $n_type(circle) + $n_type(color) + \ $n_type(composite) + $n_type(conesurf) + $n_type(conic) + \ $n_type(copius) + $n_type(curvonsurf) + $n_type(cylsurf) + \ $n_type(group) + $n_type(line) + $n_type(model) + \ $n_type(name) + $n_type(note) + $n_type(offcurve) + \ $n_type(offsurf) + $n_type(pcurve) + $n_type(plane) + \ $n_type(planesurf) + $n_type(point) + $n_type(psurface) + \ $n_type(quilt) + $n_type(ruledsurf) + $n_type(shell) + \ $n_type(spheresurf) + $n_type(subfig_defn) + $n_type(subfig_inst) + \ $n_type(surfrevo) + $n_type(tabcyl) + $n_type(toroidsurf) + \ $n_type(trimsurf) + $n_type(unknown) ] puts $fileID [format $form1 $n_all_types ""] ######################################################################## # detailed summary set form2 "%6d %8s %32s %16s %5d %4d" set form2c "%6s %8s %32s %16s %5s %4s" puts $fileID "" puts $fileID "Detailed List" puts $fileID "--------------------------------------------------------" puts $fileID [format $form2c "number" "ID" "name" "type" "layer" "able"] puts $fileID "--------------------------------------------------------" set i 0 foreach e $DB { incr i set n [gg::dbName $e] set t [gg::dbQuery $e TYPE] set y [gg::dbQuery $e LAYER] set a [gg::dbEnable $e] puts $fileID [format $form2 $i $e $n $t $y $a] } puts $fileID "" puts "Wrote file $fullname" # # DISCLAIMER: # TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, POINTWISE DISCLAIMS # ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED # TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE, WITH REGARD TO THIS SCRIPT. TO THE MAXIMUM EXTENT PERMITTED # BY APPLICABLE LAW, IN NO EVENT SHALL POINTWISE BE LIABLE TO ANY PARTY # FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES # WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF # BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE # USE OF OR INABILITY TO USE THIS SCRIPT EVEN IF POINTWISE HAS BEEN # ADVISED OF THE POSSIBILITY OF SUCH DAMAGES AND REGARDLESS OF THE # FAULT OR NEGLIGENCE OF POINTWISE. #