forked from mcneel/MOVED-rhinoscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExportBlocksToExcel.rvb
64 lines (50 loc) · 1.75 KB
/
ExportBlocksToExcel.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
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' ExportBlocksToExcel.rvb -- February 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
Sub ExportBlocksToExcel
Const rhBlock = 4096
Dim arrBlocks
arrBlocks = Rhino.ObjectsByType(rhBlock)
If Not IsArray(arrBlocks) Then
Rhino.Print "No blocks found to export."
Exit Sub
End If
Dim objXL
Set objXL = CreateObject("Excel.Application")
objXL.Visible = True
objXL.WorkBooks.Add
objXL.Columns(1).ColumnWidth = 40
objXL.Columns(2).ColumnWidth = 40
objXL.Columns(3).ColumnWidth = 40
objXL.Columns(5).ColumnWidth = 40
objXL.Columns(5).ColumnWidth = 40
objXL.Cells(1, 1).Value = "Name"
objXL.Cells(1, 2).Value = "Description"
objXL.Cells(1, 3).Value = "URL Tag"
objXL.Cells(1, 4).Value = "URL"
objXL.Cells(1, 5).Value = "Point"
objXL.Range("A1:E1").Select
objXL.Selection.Font.Bold = True
objXL.Selection.Interior.ColorIndex = 1
objXL.Selection.Interior.Pattern = 1 'xlSolid
objXL.Selection.Font.ColorIndex = 2
Dim intIndex
intIndex = 2
Dim strBlock, strName
For Each strBlock In arrBlocks
strName = Rhino.BlockInstanceName(strBlock)
objXL.Cells(intIndex, 1).Value = strName
objXL.Cells(intIndex, 2).Value = Rhino.BlockDescription(strName)
objXL.Cells(intIndex, 3).Value = Rhino.BlockURLTag(strName)
objXL.Cells(intIndex, 4).Value = Rhino.BlockURL(strName)
objXL.Cells(intIndex, 5).Value = Rhino.Pt2Str(Rhino.BlockInstanceInsertPoint(strBlock))
intIndex = intIndex + 1
Next
objXL.UserControl = True
End Sub
' Run the darn thing...
ExportBlocksToExcel