Change "Display Colour" to "By Parent" within multiple files Via Script

Hi,
I am new to Rhino and I am looking for some assistance.
I’ve got 1489 Library items which have “Display Colour” set to “By Layer”, when I insert any of these items into a model as a block they keep their original colour. I was hoping that someone may have a script which will run through all the Library files and change “Display Colour” to “By Parent”.

Many thanks
Leigh

Hi Leigh - this script will ‘ByParentize’ all blocks in the current file. To use the script, save it someplace sensible on your machine and then drag and drop from there onto Rhino - from then on, you should be able to type (or put on a button) ‘ByParentize’ and have it run.

ByParentize.rvb (1.2 KB)

-Pascal

1 Like

Hi Pascal,
Thanks very much for that, but I will be creating many models which will make use of these library models and therefore I was hoping that I could get a script that will individually open each of the Library Files and make the change to By Parent at that level.

Thanks again
Leigh

You could modify this script to do that:

Hi Gijs,
I am not all that familiar with preparing scripts but I will give it a shot at changing the commands as required, thanks very much for your help.

Leigh

It shouldn’t be that hard. Just replace the last three Rhino.Command … with
Rhino.Command “ByParentize”

At least I think that’s how it should work. Can’t test right now

Hi Forum,

I have tried a combination of the above files but have been unable to build a script to run through my models and “ByParentize” the Colour of each of my individual models. Please note the models I am trying to process do not contain Blocks.

Apologies for my incompetence, but I am new to Rhino.

Thanks again for your help.
Leigh

you can probably achieve it then with the attached script. Note this is not a vbscript, but a python script. To run it, save it to a location of choice, use RunPythonscript and browse to the script location. Though I tested it, please test it yourself on a test-folder first.

byParent.py (1.1 KB)

Hi Gijs,
I have tried the attached Python Script, I certainly runs through all the files but doesn’t seem to carry out any processing - see below from Command Line.

sorry, try the modified (in my original post above)

forgot to add ‘Save’ :grimacing:

That certainly sets the material to “Use Object Parent”, however when I open a new model and insert any of the processed models they still come in displaying their original colour and do not take the colour from the layer that they are inserted on. Any advise?

Thanks in advance.

Hi Pascal,
I have still not managed to process my files.

See Gijs’ Python script below, this is the type of process I need but it has not set the Colour to “By Parent” in the Library files.

Note: The library files will be inserted into new models as Blocks and will need to display the colour of the New Layer on which they are inserted.

Thanks
Leigh

Hi Leigh,

I have modified one line in @Gijs python script to set the Color by Parent (not Material).
See attached, maybe that will work for you.

BatchColorbyParent.py (1.1 KB)

Please note, in that code if any of your objects are already inside blocks, they will not be set to ByParent. AFAIK the rs.AllObjects does not return objects inside block definitions - it would need a few more lines of code to make it work if your files to be processed contain any blocks.

hth,

–jarek

Hi Jarek,

Perfect thanks to you @Gijs and @pascal that is my issue sorted, many thanks.

Regards
Leigh

Hi Pascal,

Is there a way to do a script that can do the same but just changing the object properties for block to “by layer” instead of “by parent”?