CTB-like layout print widths with Rhinoscript

Hello,

I’m using this script, which is very useful : AutoCAD CTB to Rhino [McNeel Wiki]
It works fine, but I’m trying to enhance it for my own practice:

What I’m trying to do is to change the Layout Print Width and the Layout Print Color with the script, instead of changing the Print Width and Print Color.

This way, I would like to be able to have specific print widths according to each layout, and to be able to batch plot all my layouts without having to reload SetAcadPrintInfo for each layout.

I didn’t find the corresponding method in the RhinoScript documentation. Is there a way to achieve this?

Thanks a lot,

Hi @antoine3,

Legacy RhinoScript does not have methods to get/set per-layout or per-detail layer properties. For this, you will need to migrate to Python.

Hope this helps.

– Dale

Hello @dale,
Thank you for your answer. I checked the RhinoPython documentation, and only found methods like LayerPrintWidth and LayerPrintColor, which seems similar to what has been used in the RhinoScript I was referring to.
No problem to migrate to Python, but could you enlighten me on the right method to get/set per-layout or per-detail layer properties with Python please?
Thank you!

Hi @antoine3,

Rhino.Python’s rhinoscriptsyntax library is just a library of Python functions that are designed to emulate legacy RhinoScript. So it makes sense that rhinoscriptsyntax does not contain what you are looking for (either).

Note, rhinoscriptsyntax just makes calls into RhinoCommon. You can vifew the source code to rhinoscriptsyntax here.

To set the per-viewport layer properties, you’ll need to go to RhinoCommon directly. Here are a few methods that will be useful to you.

Layer.PerViewportPlotColor
Layer.SetPerViewportPlotColor

Layer.PerViewportPlotWeight
Layer.SetPerViewportPlotWeight

Here is a simple example:

import Rhino
import scriptcontext as sc
import System

def test_per_viewport_layer_settings():
    
    layer = sc.doc.Layers.CurrentLayer
    if not layer:
        return
    
    color = System.Drawing.Color.Chartreuse
    weight = 0.25
    
    layer.PlotColor = color
    layer.PlotWeight = weight
    
    view = sc.doc.Views.ActiveView
    if isinstance(view, Rhino.Display.RhinoPageView):
        details_views = view.GetDetailViews()
        for detail in details_views:
            layer.SetPerViewportPlotColor(detail.Viewport.Id, color)
            layer.SetPerViewportPlotWeight(detail.Viewport.Id, weight)
    
    sc.doc.Views.Redraw()
    
if __name__ == "__main__":
    test_per_viewport_layer_settings()

Hope this helps.

– Dale

2 Likes