Select by Print Color

Hello,
I wonder if there is a way to select by print color ?
If no, this could be handy to change white colors to black for print.

I have this script from my library, see if it works for you…

SelObjsByPrintColor.py (2.3 KB)

–Mitch

Thank you so much Helvetosaur, It works. I won’t ask you the impossible, this function could be implemented as independent or native startup script.
Thanks again.

Well, I think the best thing to do would be the following:

  1. Save the script somewhere where you can easily retrieve it. The “usual” place is:
    C:\Users\<username>\AppData\Roaming\McNeel\Rhinoceros\5.0\Scripts

  2. Create an alias such as ‘SelByPrintColor’ with the following as the command part:
    ! _-RunPythonScript "fullpathtoscript\scriptfilename"
    Example:
    ! _-RunPythonScript "C:\Users\yourname\AppData\Roaming\McNeel\Rhinoceros\5.0\Scripts\SelObjsByPrintColor"

  3. Any time you type the alias and Enter, the script will run, so it’s like an installed command.

  4. If you want a toolbar button for it, simply create a new one and paste the same thing as the alias command in the macro section.

HTH, --Mitch

1 Like

Thank you so much!

Hi Mitch,

I just tried your script and I am getting this error, which is strange because I believe it has worked on my system before.
any tip what might be goining on here?
image

thanks!!
Daniel

If you are getting an error message like that, it’s likely that the script encountered a case that I didn’t predict - let me look…

Hmm, the function that gets an object print color source - which is set either by layer or by object - is failing. OK, I see what is likely the case - looks I had not considered blocks, which can have a print color source by parent. That unfortunately complicates things, it’s not an easy fix, as in that case different objects inside a block might have different print colors. And you can’t individually select objects inside a block. The easy fix I can do now is exclude blocks… probably doesn’t help you though.

many thanks Mitch for the swift response and for looking into it!

after all I think excluding blocks is totally fine… I wasn’t really expecting this to work on blocks at all :slight_smile:

whenever you get to it :wink:

cheers,
Daniel

I see that I have another script that selects objects by print width that I had modified/updated to accommodate blocks. The procedure is virtually identical. So I can use that as a model. There is one choice to make however:

either

  • if any object in the block instance has the corresponding color - select the block instance.
    or
  • only if all objects inside the block have the corresponding print color - select the block instance.

What do you think?

cool.

I think the latter makes more sense. because if the script selects the block, to change individual object’s print colour, would require a block edit. but changing print colour on the entire block can be done directly from “outside” by using your function.

That would be possible, but in the case of block instance color ‘by parent’ you would also have to reset that to ‘by layer’ or ‘by object’ first. In any case blocks do complicate things like this enormously, I see that the script for print width which accepts blocks is 50% longer than the one for print color that doesn’t…

ah yes… I get you now. personally I don’t use by parent at all. just by layer.

but I think the script would do a great job if it would just work on objects and exclude blocks.
we can always do a blockEdit, and use it while being in the edit, or?

Oooh, I’m not certain I would want to run a script while in BlockEdit… Maybe it works, but considering how delicate BlockEdit already is, I think that’s playing with :fire:

ok ok… thanks for the warning! :fire_extinguisher:

OK, took longer than i thought because I had some stupid bugs that were hard to find… So, try out the one below. By default, only if a block object has elements with all the same print color that matches the target print color, will it select. However, if you add an additional False argument to the last line - SelObjsByPrintColor(False) - it will also select block instances that have at least one of their elements having the target print color, but not necessarily all.

Let me know if you find bugs in this one…

SelObjsPlusBlocksByPrintColor.py (4.2 KB)

2 Likes

:pray:
thanks man, very nice of you.

I see, this is even the luxury version :diamond_shape_with_a_dot_inside: with the block option included

just came back to the computer, looks like its working on the file that showed the error before :+1:

I will keep you updated if I encounter anything else.

many cheers,
Daniel