-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgetBBox.glf
67 lines (54 loc) · 1.62 KB
/
getBBox.glf
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
67
package require PWI_Glyph 2.17.1
puts "Beginning getBBox script..."
set mask [pw::Display createSelectionMask \
-requireConnector {} \
-requireDomain {} \
-requireBlock {} \
-requireSource {} \
-requireDatabase {} \
-requireDatabaseBoundary {}]
#
# Use selected entity(ies) or prompt user for selection if nothing is selected
# at run time.
#
if { !([pw::Display getSelectedEntities -selectionmask $mask selected]) } {
if { !([pw::Display selectEntities \
-selectionmask $mask \
-description "Select entities for bounding box" \
selected]) } {
puts "Error: Unsuccessfully selected entities... exiting"
exit
}
}
#puts "--Successfully selected entities..."
set bbox [pwu::Extents empty]
foreach {n things} [array get selected] {
#puts "--$n: $things [llength $things]"
if { $n == "Boundaries" } {
set curves [list]
foreach thing $things {
lappend curves [pw::Database getCurve $thing]
}
set things $curves
}
foreach thing $things {
set bbox [pwu::Extents enclose $bbox [$thing getExtents]]
}
}
set bboxMin [pwu::Extents minimum $bbox]
set bboxMax [pwu::Extents maximum $bbox]
set bboxDeltas [pwu::Vector3 subtract $bboxMax $bboxMin]
set bboxCentroid [pwu::Vector3 scale [pwu::Vector3 add $bboxMax $bboxMin] 0.5]
puts ""
puts "Bounding box is:"
puts "$bboxMin -> $bboxMax"
puts ""
puts "Bounding box deltas:"
puts "$bboxDeltas"
puts ""
puts "Bounding box centroid:"
puts "$bboxCentroid"
puts ""
puts "Completed getBBox script..."
exit
# vim: filetype=tcl