forked from mcneel/MOVED-rhinoscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BlockUtilities.rvb
62 lines (47 loc) · 2.14 KB
/
BlockUtilities.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
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' BlockUtilities.rvb -- November 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.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Script to update all linked blocks
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub UpdateAllLinkedBlocks()
Call Rhino.Command("_-BlockManager _Update _All _Enter _Enter _Enter", 0)
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Script to insert multiple files as linked blocks
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub InsertMultipleFilesAsBlocks()
Dim arrFiles, strFiles
arrFiles = Rhino.OpenFileNames("Insert", "Rhino 3D Models (*.3dm)|*.3dm|All Files (*.*)|*.*||")
If IsArray(arrFiles) Then
For Each strFile In arrFiles
Call Rhino.Command("_-Insert _File=_Yes " & strFile & " _Block _Pause _Enter _Enter", 0)
Next
End If
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Script to export select and then insert as linked block
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub Externalize()
Dim arrObjects, arrPoint, strFile
Dim arrCopy, strPoint
arrObjects = Rhino.GetObjects("Select objects to define block")
If IsNull(arrObjects) Then Exit Sub
arrPoint = Rhino.GetPoint("Block base point")
If IsNull(arrPoint) Then Exit Sub
strFile = Rhino.SaveFileName("Save", "Rhino 3D Model (*.3dm)|*.3dm||")
If IsNull(strFile) Then Exit Sub
Call Rhino.EnableRedraw(False)
arrCopy = Rhino.CopyObjects(arrObjects, arrPoint, Array(0,0,0))
Call Rhino.SelectObjects(arrCopy)
Call Rhino.Command("_-Export " & Chr(34) & strFile & Chr(34), 0)
strPoint = Rhino.Pt2Str(arrPoint)
Call Rhino.Command("_-Insert _File=_Yes " & strFile & " _Block " & strPoint & " _Enter _Enter", 0)
Call Rhino.DeleteObjects(arrCopy)
Call Rhino.DeleteObjects(arrObjects)
Call Rhino.EnableRedraw(True)
End Sub