Forgot password?

Create an account!


« back

RhinoScript – assign materials to different objects and render multiple vies


Please log in to write a message.

  • 3. cadkarthick (Feb 27, 2013 06.37):

    Hi Send me your mail id i will help u in this i have something same like this..

  • 2. ledisnomad (Dec 05, 2011 21.22):


    The material methods are not very comprehensive. I would like to help, but I don't see an easy way to apply a material by name to an object. Would it be an acceptable solution to assign materials to layers of the same name then switch objects those layers?

    From the Rhino developer website -- -- I found this nice function that should start you out by reading the Excel file into a 2-dimensional array:

    Function ReadExcelFile(ByVal strFile)
            ' Local variable declarations
            Dim objExcel, objSheet, objCells
            Dim nUsedRows, nUsedCols, nTop, nLeft, nRow, nCol
            Dim arrSheet()
            ' Default return value
            ReadExcelFile = Null
            ' Create the Excel object
            On Error Resume Next
            Set objExcel = CreateObject("Excel.Application")
            If (Err.Number <> 0) Then
                    Exit Function
            End If
            ' Don't display any alert messages
            objExcel.DisplayAlerts = 0  
            ' Open the document as read-only
            On Error Resume Next
            Call objExcel.Workbooks.Open(strFile, False, True)
            If (Err.Number <> 0) Then
                    Exit Function
            End If
            ' If you wanted to read all sheets, you could call
            ' objExcel.Worksheets.Count to get the number of sheets
            ' and the loop through each one. But in this example, we
            ' will just read the first sheet.
            Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
            ' Get the number of used rows
            nUsedRows = objSheet.UsedRange.Rows.Count
            ' Get the number of used columns
            nUsedCols = objSheet.UsedRange.Columns.Count
            ' Get the topmost row that has data
            nTop = objSheet.UsedRange.Row
            ' Get leftmost column that has data
            nLeft = objSheet.UsedRange.Column
            ' Get the used cells
            Set objCells = objSheet.Cells
            ' Dimension the sheet array
            ReDim arrSheet(nUsedRows - 1, nUsedCols - 1)
            ' Loop through each row
            For nRow = 0 To (nUsedRows - 1)
                    ' Loop through each column
                    For nCol = 0 To (nUsedCols - 1)
                            ' Add the cell value to the sheet array
                            arrSheet(nRow, nCol) = objCells(nRow + nTop, nCol + nLeft).Value
            ' Close the workbook without saving
            Call objExcel.ActiveWorkbook.Close(False)
            ' Quit Excel
            ' Return the sheet data to the caller
            ReadExcelFile = arrSheet
    End Function
  • 1. chakomako (Nov 29, 2011 07.53):


    i have an excel file which has following values :

    part no. metal1 metal2 metal3
    abc rose rose silver
    xyz yellow rose yellow
    111 yellow silver silver

    Now here abc, xyz, 111 will be the name of file, i already have script for rendering multiple views, but now i want to automate material assignment too it should pickup values from my excel column metal1, metal2 and metal3 and then render 5 different saved views and assign file name as

    abc_image1, abc_image2, abc_image3, abc_image4 and abc_image5 , these render will have material rose , rose and silver to 3 different objects on 3 different layers.

    can any one help ?


Why are these buttons gray?