-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathExportBlocks.rvb
52 lines (42 loc) · 1.45 KB
/
ExportBlocks.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
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' ExportBlocks.rvb -- March 2011
' 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
Sub ExportBlocks
' Local constants
Const METERS = 4
' Local variables
Dim strPath, strName
Dim arrBlocks, strBlock, strText
Dim nOldUnits
' Get the current file's path and name
strPath = Rhino.DocumentPath
strName = Rhino.DocumentName
If IsNull(strPath) Or IsNull(strName) Then
Call Rhino.Print("Please save your model before running this script.")
Exit Sub
End If
' Get the names of the block definitions
arrBlocks = Rhino.BlockNames
If IsNull(arrBlocks) Then
Call Rhino.Print("No block definitions to export.")
Exit Sub
End If
' We want to export in meters, so change unit system of necessary
nOldUnits = Rhino.UnitSystem
If (nOldUnits <> METERS) Then
Call Rhino.UnitSystem(METERS, True)
End If
' Export each block
For Each strBlock In arrBlocks
strText = Chr(34) & strBlock & Chr(34) & " " & Chr(34) & strPath & strBlock & ".igs" & Chr(34)
Call Rhino.Command("_-BlockManager _Export " & strText & " _Enter _Enter")
Next
' Reset the unit system, if necessary
If (Rhino.UnitSystem <> nOldUnits) Then
Call Rhino.UnitSystem(nOldUnits, True)
End If
End Sub