Object and Layer print width swap

Hi there,

Is there a way to set a layer’s print width from the objects it holds?
E.g., if one layer had 100 curves each set to 0.1mm, is there a command which can assign 0.1mm to the layer? Perhaps it could take the average, min or max print width.

Likewise, is there a command which can assign a layer’s print width to all of its contained objects?

Cheers,
Jeremy

Both of those are easily scripted, the second one being simpler because there is only one value to consider. For the first you would need to decide between the choices you outlined if the pw values are not all the same. Also as object settings override layer settings, going from by object to by layer would require removing the individual objects’ pw settings permanently… or maybe not, it could assign the value to the layer, but leave the individual overrides.

1 Like

Hi Helvetosaur;
The way you responded sounds logical indeed. I was also thinking of the object level overrides.
Can you direct me on where I should start on how to learn to script like this? They haven’t taught us custom scripting at our school haha.

Best,
Jeremy

I wish I had the time this morning to script it and explain, unfortunately, I’m traveling for the next few days. I can look at it tonight when I get where I’m going, or perhaps someone else in here will respond before that.

Has a couple of minutes to spare, here are two starter scripts:

LayerPWToObjs.py (727 Bytes)
AvgObjPWToLayer.py (909 Bytes)

Not tested extensively, can of course modify to suit…

1 Like

Thanks Helvetosaur for making these scripts!

The primary reason for the object to print width was to be able to automatically take print widths of objects when importing/opening a RhinoPDF, and assign them back to the layers which were used when creating the PDF.

The layer to object script was to try to simplify the GH Print Width Preview script; and both together would allow seamless transition between both.

E.g., this was a section perspective exported to RhinoPDF at 1:50. When I import that same pdf; scale it back up 50x, the print widths on the objects are retained. But the layer print widths are reset to Default, and the layer colours use what were the print colours of the original export.

In the future, if you have some time, possibly some script enhancements

  • Apply either scripts to layers of selected objects?
  • Or apply to multiple selected or all layers at once?

Cheers,
Jeremy

Hi Helvetosaur,

Was wondering if there’s a chance of developing this script to be able to handle multiple objects/layers?

Best,
Jeremy

I added a multi-layer selection and loop, try these out… (not tested)

LayersPWToObjs.py (805 Bytes)
AvgObjPWToLayers.py (1023 Bytes)

1 Like

Thank you so much Helvetosaur!

I tested it and it seems to work for many nested layers. The print width is maintained on the objects, but it’s easy to select all and set to By Layer.

Best,
Jeremy

If you open the scripts in a text editor and change the last lines from

LayersPWToObjs() and AvgObjPWToLayer()
to
LayersPWToObjs(True) and AvgObjPWToLayer(True)

(i.e. add the word True inside the parentheses)

The scripts should then remove any pre-existing by-object print widths and set all to by layer automatically.

1 Like

Works a treat… Thanks Helvetosaur