Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 48 lines (35 sloc) 1.677 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
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' MatchText.rvb -- July 2009
' If this code works, it was written by Dale Fugier.
' If not, I don't know who wrote it.
' Works with Rhino 4.0 and 5.0
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Option Explicit

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Matches the properties of text objects.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub MatchText()
  
  Dim objects, source, match, items, values, i
  Dim font, height, style
  
  objects = Rhino.GetObjects("Select text objects to modify", 512,, True)
  If IsNull(objects) Then Exit Sub
    
  source = Rhino.GetObject("Select source object", 512)
  If IsNull(source) Then Exit Sub
  
  items = Array("Font", "Height", "Style")
  values = Array(True, True, True)
  match = Rhino.CheckListBox(items, values, "Properties to match:", "Match Text")
  If IsNull(match) Then Exit Sub

  font = Rhino.TextObjectFont(source)
  height = Rhino.TextObjectHeight(source)
  style = Rhino.TextObjectStyle(source)
  
  Call Rhino.EnableRedraw(False)
  
  For i = 0 To UBound(objects)
    If match(0) = True Then Call Rhino.TextObjectFont(objects(i), font)
    If match(1) = True Then Call Rhino.TextObjectHeight(objects(i), height)
    If match(2) = True Then Call Rhino.TextObjectStyle(objects(i), style)
  Next
  
  Call Rhino.EnableRedraw(True)
  
End Sub

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Rhino.AddStartupScript Rhino.LastLoadedScriptFile
Rhino.AddAlias "MatchText", "_NoEcho _-RunScript (MatchText)"
Something went wrong with that request. Please try again.