forked from advocateddrummer/PointwiseGetBoundingBox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetBBox.glf
More file actions
66 lines (54 loc) · 1.64 KB
/
getBBox.glf
File metadata and controls
66 lines (54 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package require PWI_Glyph 2.17.1
puts "Beginning getBBox script..."
set mask [pw::Display createSelectionMask \
-requireConnector {} \
-requireDomain {} \
-requireBlock {}];# \
-requireDatabase {} \
-requireDatabaseBoundary {}]
if { [pw::Display selectEntities \
-selectionmask $mask \
-description "Select entities for bounding box" \
selected] } {
#puts "--Successfully selected entities..."
set xMin 1e100
set yMin 1e100
set zMin 1e100
set xMax -1e100
set yMax -1e100
set zMax -1e100
foreach {n things} [array get selected] {
#puts "--$n: $things [llength $things]"
for {set i 0} {$i < [llength $things]} {incr i} {
set thing [lindex $things $i]
#puts "----$thing"
#puts "----[$thing getName]"
set ent [pw::GridEntity getByName [$thing getName]]
set nPoints [$ent getPointCount]
#puts "----$ent"
#puts "----$nPoints"
for {set j 1} {$j <= $nPoints} {incr j} {
set xyz [$ent getXYZ -grid $j]
set x [pwu::Vector3 index $xyz 0]
set y [pwu::Vector3 index $xyz 1]
set z [pwu::Vector3 index $xyz 2]
set xMin [::tcl::mathfunc::min $xMin $x]
set yMin [::tcl::mathfunc::min $yMin $y]
set zMin [::tcl::mathfunc::min $zMin $z]
set xMax [::tcl::mathfunc::max $xMax $x]
set yMax [::tcl::mathfunc::max $yMax $y]
set zMax [::tcl::mathfunc::max $zMax $z]
}
}
}
} else {
puts "Error: Unsuccessfully selected entities... exiting"
exit
}
puts ""
puts "Bounding box is:"
puts "($xMin, $yMin, $zMin) -> ($xMax, $yMax, $zMax)"
puts ""
puts "Completed getBBox script..."
exit
# vim: filetype=tcl