Thanks for the quick responses!
Here is the script in full:
Option Explicit
'Script written by peter harris
'www.peterwhatcreates.com
'Modified By Don Lewis
Call Main()
Sub Main()
Call Rhino.Print("V1.0 - script created by Peter Harris - www.peterwhatcreates.com")
Call Rhino.Print("Modified By Don Lewis")
Dim arrObjects, MaterialOptions, X, Y, Z, Material, DensityTest, CBtext, TextChunk, strObject
Dim ObjectWeight, ObjectMaterial, Density, ObjectName, TestMaterial, arrMP, ObjectVolume, ObjectLayer
Dim TextChunkForClipboard, ObjectNote
'check if file exists - if not, create it
Dim DefaultText
DefaultText = "How To Edit The Materials List:" & _
vbCrLf & "To edit the list, just add your materials, Then an equal sign, and the specific gravity of your material." & _
vbCrLf & "Do Not begin a material name With a number Or other characters - just letters." & _
vbCrLf & "Do Not put In multiple materials that have the same name, and Do Not put spaces In the material names" & _
vbCrLf & "Leave the EditMaterialsList=EditMaterialsList line intact. You can re-arrange the order as much as you would like." & _
vbCrLf & "To add materials for which you do not know the specific gravity, convert them to grams per cubic cm." & _
vbCrLf & "To convert from whatever units you know, go to google and type in something like:" & _
vbCrLf & CHR(34) & "40 pounds per cubic foot in grams per cubic cm" & CHR(34) & " ...and google will return the number to enter here." & _
vbCrLf & "You can also move materials from the MaterialsToHide list to the MaterialsList list and vise-versa," & _
vbCrLf & "which can keep your options simple and customized for you without getting rid of materials that you might need someday." & _
vbCrLf & vbCrLf & "Here are some websites that list specific gravities of various materials:" & _
vbCrLf & "http://www.plasticsusa.com/specgrav2.html" & _
vbCrLf & "http://www.reade.com/Particle_Briefings/spec_gra.html" & _
vbCrLf & "http://www.tesarta.com/www/resources/library/weights.html" & _
vbCrLf & vbCrLf & vbCrLf & "[MaterialsList]" & _
vbCrLf & "ppr=0.900100225" & _
vbCrLf & "abs=1.05082887" & _
vbCrLf & "his=1.03740365" & _
vbCrLf & "eva=0.945868033" & _
vbCrLf & "lpe=0.945868033" & _
vbCrLf & "mis=1.03740365" & _
vbCrLf & "nyl=1.11063214" & _
vbCrLf & "pvc=1.28149863" & _
vbCrLf & "EditMaterialsList=EditMaterialsList" & _
vbCrLf & vbCrLf & vbCrLf & "[MaterialsToHide]" & _
vbCrLf & "water=1" & _
vbCrLf & "Renshape_BM5440=0.55" & _
vbCrLf & "Renshape_BM70=0.7" & _
vbCrLf & "Renshape_450=0.65" & _
vbCrLf & "Renshape_460=0.77" & _
vbCrLf & "Axson_ProLab_65=0.65" & _
vbCrLf & "Gold=19.32" & _
vbCrLf & "Silver=10.5" & _
vbCrLf & "Platinum=21.45"
Dim FileLocation : FileLocation = Rhino.InstallFolder + "MaterialSpecificGravityList.ini"
Set objFso = CreateObject("Scripting.FileSystemObject")
If Not objFso.FileExists(FileLocation) Then
objFso.CreateTextFile(FileLocation)
Set objFso = Nothing
Dim objFSO, objFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
If (objFSO.FileExists(FileLocation)) Then
Set objFile = objFSO.OpenTextFile(FileLocation, 8, True, -2)
Call objFile.Write(DefaultText)
Call objFile.Close()
Set objFile = Nothing
Set objFSO = Nothing
End If
End If
Set objFso = Nothing
' done --------------------------------
MaterialOptions = Rhino.GetSettings(Rhino.InstallFolder & "MaterialSpecificGravityList.ini", "MaterialsList")
If IsArray(MaterialOptions) Then
X = 0
For Each Material In MaterialOptions
ReDim Preserve arrDensity(X)
arrDensity(X) = Rhino.GetSettings(Rhino.InstallFolder & "MaterialSpecificGravityList.ini", "MaterialsList", Material)
DensityTest = EVAL(arrDensity(X))
If DensityTest <= 0 Then arrDensity(X) = 0
X = X + 1
Next
Else
Exit Sub
End If
arrObjects = Rhino.GetObjects("Select objects to create Cut Sheet ", 8 + 16 + 32 + 4096,, True)
If IsArray(arrObjects) Then
'-------------------------------------------------------------------
'figure out conversion factor
Dim CurrentUnits, TotalConversionFactor, LengthConversion
'find out current unit system
CurrentUnits = Rhino.UnitSystemName(, vbtrue)
'convert them all to cubic cm - multiply by this number!
Select Case CurrentUnits
Case "millimeter"
LengthConversion = .001
Case "centimeter"
LengthConversion = 1
Case "meter"
LengthConversion = 1000000
Case "inch"
LengthConversion = 16.387064
Case "foot"
LengthConversion = 28316.8466
Case Else
Msgbox "Sorry - this will not work with your unit system!"
Exit Sub
End Select
TotalConversionFactor = LengthConversion * 0.00220462262
'---------------------------------------------------------------------
Z = 0
CBtext = ""
TextChunk = ""
TextChunkForClipboard = ""
For Each strObject In arrObjects
ObjectMaterial = Rhino.GetObjectData(strObject, "ObjectProperties", "Material")
ObjectNote = Rhino.GetObjectData(strObject, "ObjectProperties", "ObjectNote")
ObjectName = Rhino.ObjectName(strObject)
ObjectLayer = Rhino.ObjectLayer(strobject)
If IsNull(ObjectName) Then
ObjectName = Rhino.ObjectName(strObject)
End If
'get size
Dim BoundBox, ObjectSize, ObjectSizea,ObjectSizeb
BoundBox = Rhino.BoundingBox(strObject)
Dim dimX : dimX = rhino.Distance(BoundBox(0), BoundBox(1))
Dim dimY : dimY = rhino.Distance(BoundBox(0), BoundBox(3))
Dim dimZ : dimZ = rhino.Distance(BoundBox(0), BoundBox(4))
'Sort size smallest to largest
dimX = ROUND((dimX), 3)
dimY = ROUND((dimY), 3)
dimZ = ROUND((dimZ), 3)
ObjectSizea = Array(dimX, dimY, dimZ)
ObjectSizeb = Rhino.SortNumbers(ObjectSizea)
ObjectSize = Objectsizeb(0) & ", " & Objectsizeb(1) & ", " & Objectsizeb(2)
If IsNull(ObjectName) Then
ObjectName = "unnamed"
End If
'Object details
If Rhino.ObjectName(strObject) = "SG" Then
TextChunkForClipboard = ObjectName & CHR(9) & ObjectSizeb(0) & CHR(9) & ObjectSizeb(1) & CHR(9) & ObjectSizeb(2) & CHR(9) & ObjectLayer
ElseIf Rhino.ObjectName(strObject) = "LG" Then
TextChunkForClipboard = ObjectName & CHR(9) & ObjectSizeb(0) & CHR(9) & ObjectSizeb(2) & CHR(9) & ObjectSizeb(1) & CHR(9) & ObjectLayer
Else
TextChunkForClipboard = ObjectName & CHR(9) & ObjectSizeb(0) & CHR(9) & ObjectSizeb(1) & CHR(9) & ObjectSizeb(2) & CHR(9) & ObjectLayer
End If
If Z > 0 Then
'Make Every Line After First Line
CBtext = CBtext & vbCrLf & TextChunkForClipboard
Else
'Make Header and First Line
CBtext = "Name" & CHR(9) & "Thickness" & CHR(9) & "Width" & Chr(9) & "Length" & Chr(9) & "Material" & vbCrLf & TextChunkForClipboard
End If
Z = Z + 1
Next
'Copy text to clipboard
Rhino.ClipboardText CBtext
'Call Excel sub
SendToExcel(CBtext)
Else
Rhino.Print "nothing selected"
End If
End Sub
Sub SendToExcel(CBtext)
Dim LineAdder, X, PageTitle, app, wb, xlSheet, xlCenter
' -------------------- Launch Excel --------------------
'create excel object
Set app = CreateObject("Excel.Application")
app.Visible = True
'Add a new workbook
Set wb = app.workbooks.add
With app.Worksheets("Sheet1")
Set xlSheet = app.Worksheets("Sheet1")
xlSheet.Activate 'The sheet needs to be active
xlSheet.Range("A1").Select
xlSheet.Paste
' --------------------------- format cells ---------------------------
For X = 1 To 8
.Cells(1, X).EntireColumn.AutoFit
Next
End With
' ---------------------------- end format -----------------------------
' Clean up
Set wb = Nothing
Set app = Nothing
End Sub
I’ve tried loading from the plugin/script menu, and also from a button that i created with the text in it.
I’ve looked at the script at line 64, but not sure what it is up to! I’m not an expert with scripts, I’m afraid.
Hope this helps.