forked from mcneel/MOVED-rhinoscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DimScaleText.rvb
66 lines (49 loc) · 1.92 KB
/
DimScaleText.rvb
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
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' DimScaleText.rvb -- July 2007
' If this code works, it was written by Dale Fugier.
' If not, I don't know who wrote it.
' Works with Rhino 4.0.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Scales all text objects by the document's dimension scale
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub DimScaleText
' Dim local variables
Dim arrObjects, strObject, arrPlane, dblScale
' Get document's dimension scale
dblScale = Rhino.DimScale
If dblScale = 1.0 Then
Rhino.Print "Dimension scale set to 1.0."
Exit Sub
End If
' Get ids of all annotation objects
arrObjects = Rhino.ObjectsByType(512)
If Not IsArray(arrObjects) Then
Rhino.Print "No text objects to scale."
Exit Sub
End If
' Turn off viewport redrawing (faster)
Rhino.EnableRedraw vbFalse
' Save current view's construction plane
arrPlane = Rhino.ViewCPlane(Rhino.CurrentView)
' Process each object
For Each strObject In arrObjects
' Verify object is a text object
If Rhino.IsText(strObject) And Rhino.IsObjectSelectable(strObject) Then
' Set the current view's construction plane to plane
' that defines the position and orientatio of the text
Rhino.ViewCPlane Rhino.CurrentView, Rhino.TextObjectPlane(strObject)
' Select the object
Rhino.SelectObject strObject
' Scale the object by the dimension scale
Rhino.Command "_-Scale 0,0,0 " & CStr(dblScale), False
' Unselect the object
Rhino.UnselectObject strObject
End If
Next
' Restore current view's construction plane
Rhino.ViewCPlane Rhino.CurrentView, arrPlane
' Turn on viewport drawing
Rhino.EnableRedraw vbTrue
End Sub