Forgot password?

Create an account!


« back

RhinoScript – Applying material inside blocks


Please log in to write a message.

  • 5. ledisnomad (Feb 23, 2012 16.06):

    That's a very complex looking model! A lot of work to fix each block manually. Hope it all works out for you.

  • 4. scooterlord (Feb 23, 2012 01.47):

    Hello and thanks for the reply! I am at work atm and can't check it, will do so later on...

    ...however, I was too impatient to wait that I manually fixed ALL those blocks one by one. It was tough but it's done.

    I will certainly keep the code just in case. :)

    As for he materials by layer, it would be tough. The project I'm working on was mars rover, and it was made out of hundreds of parts, and wanted to keep them grouped to their respective layers. > just to get the idea..

    Again, a million thanks for spending some time to help!

  • 3. ledisnomad (Feb 21, 2012 21.38):

    Hey, scooterlord.

    This may not be an option, but have you considered applying materials by layer instead? A suggestion, if not for this project, perhaps for a future project.

    As for working with blocks, you can query objects in a block with Rhino.BlockObjects(strBlock). Following along with this, you'd probably have to iterate through all blocks, maybe using Rhino.BlockNames(), then BlockObjects, then apply to those objects within the block. So maybe something like this (this is completely untested code):

    Dim arrBlocks, strBlock
    Dim arrObjs, strObjs
    arrBlocks = Rhino.BlockNames(True)

    If IsArray(arrBlocks) Then

        For Each strBlock In arrBlocks
            arrObjs = Rhino.BlockObjects(strBlock)

            For Each strObj In arrObjs
                If ('material of strObj matches your material) Then
                    'apply new material
                End If
    End If

    Let me know if that works! Like I said, I didn't test the code, just typed it here so it may be worthless, but it's a starting point.

  • 2. scooterlord (Feb 20, 2012 14.44):

    Anyone? :)

  • 1. scooterlord (Feb 19, 2012 03.28):


    Can anyone help me with a script that does the following:

    a) Selects all blocks (and nested blocks if possible)
    b) select objects with a specific material name
    c) re-apply the same material the rhino beta I am having problems with materials (maxwell render materials) being corrupt from my surfaces and have to re-apply them. By corrupt I mean one of the material maps is placed on the color map and every other property is gone (reflection, bump, etc)

    I am working on a multiple-thousand object project and when a material fails I have to select ALL of them and re-apply the material. The good thing turned out to be that it keeps the material's name.

    I was doing this one-by-one until I realised there was this command SelMaterialName, but does not look inside blocks - and I have hundreds of them. I would really appreciate the help, will save me tons of time.. and tons of anxiety..


Why are these buttons gray?