Parametric layouts from Grasshopper

Hello

I need to export about 1300 drawings, each A4 PDF in scale, contains some baked geometry. I was trying to use FabTools for Grasshopper but it’s crashing my Rhino as it’s not suitable for Rhino 6. Is there a way how to use RhinoScriptSyntax or some different workaround? Does anyone have an experience with that? How are you guys exporting data for fabrication if that requires piece-by-page layouts?

Thanks

1 Like

do you have the 1300 layouts already mapped out in Rhino?
image (more like 1301 layouts here…)
if so you can try a SheetDump component in this
but I do notice that anything above 1000 in number is likely causing some major slow down, if not crash…

Thanks for suggestion. I will definitely try it. But my layouts are not mapped yet. I only were able to generate 1300 layouts using rs.AddLayout(), but now I am struggling with adding details (I am quite newbie in Python).

So far I am getting crash whenever I try to add detail to layout:

import rhinoscriptsyntax as rs

layouts = []

if run==True:
    for i in range(len(target)):
        layout = rs.AddLayout(title=str(i),size=[210,297])
        layouts.append(str(layout))
     
    for l in layouts:
        detail = rs.AddDetail(l,(0,0),(210,297),title="D1",projection=1)

https://developer.rhino3d.com/api/RhinoScriptSyntax/#collapse-AddDetail

it seems that you can eliminate the str(layout) and simply add the Guid object into your layouts. rs.AddDetail() first input parameter is a Guid, not a str.

Also try doing 20 layouts first. Maybe it’s the sheer number that crashes Rhino.

Still crashing even with 5 layouts and even without iteration.

import rhinoscriptsyntax as rs

if run==True:
        layout = rs.AddLayout("layout", size=[210,297])
        if layout:
            rs.AddDetail(layout, (5,5), (205,292), None, 1)

Try using rhinocommon directly:

import Rhino
Rhino.RhinoDoc.ActiveDoc.Views.AddPageView("A4_001", 297, 210)

I made a few components for this a while back. Let me know what you think of these. I haven’t found a way to reference layouts and details to modify them sensibly without deleting and recreating.


Example_layouts.gh (113.6 KB)

26 Likes

Thanks for sharing, @dharman, this works very well! I generated all 1356 of them.
As I tried to figure it out by myself, I guess there’s somethig wrong with AddDetail() of RhinoScriptSyntax. I am still curious how to make it work with AddDetail().

1 Like

Glad that worked for you. You might find more info here: https://github.com/mcneel/rhinoscriptsyntax/blob/rhino-6.x/Scripts/rhinoscript/view.py
This is a peak under the hood of rhinoscriptsyntax. see on line 53. The extensive comments might help you understand.

    corner1 = rhutil.coerce2dpoint(corner1, True)
    corner2 = rhutil.coerce2dpoint(corner2, True)
    if projection<1 or projection>7: raise ValueError("projection must be a value between 1-7")
    layout = scriptcontext.doc.Views.Find(layout_id)
    if not layout: raise ValueError("no layout found for given layout_id")
    projection = System.Enum.ToObject(Rhino.Display.DefinedViewportProjection, projection)
    detail = layout.AddDetailView(title, corner1, corner2, projection)
    if not detail: return scriptcontext.errorhandler()
    scriptcontext.doc.Views.Redraw()
    return detail.Id
3 Likes

One quick thing, I had to graft the layout names so that it wouldn’t hang/freeze GH. Thanks again for the great script.

1 Like

Thank you for these components. Unfortunately, the first one doesn’t work for me : it creates the layout views but without considering the name and the size (They are all named “Viewport” and have a weird size of 21.6 x 27.9 cm). I tried to edit the component without success. (I’m on Rhino V7 Mac). Do you know how to solve this ? Thank you again

Maybe share the part of your script that doesn’t work? I don’t have Rhino Mac to test.

Hi @dharman thanks for sharing I tested your example on Mac too and the Layout-Python component doesn’t work properly, all layouts are named Viewport and use the default paper size(Letter). This happens even when N is empty. and also I tried with internal values
Rhino.RhinoDoc.ActiveDoc.Views.AddPageView(“A4_001”, 297, 210)
and again Viewport name and Letter size.

The other python works well after renaming it one by one.

On WINDOWS all run pretty fine, please could you help me to clone “n” times an existing Layout?
and your AddDetail could support perspective view? thank you!

1 Like

Thanks for posting this! It was very helpful in learning how to automate layouts. Do you know if there is any way I can load a title block into these layouts? From what I can tell Rhino.RhinoDoc.ActiveDoc.Views.AddPageView method does not allow for this. I looked through the Rhino dev docs but did not seem to find anything.

Hi There,

I’m having an issue with the detail views not aligning with the layouts. Any help as to why this is happening?

Thanks
Create Layouts_Test.gh (93.4 KB)
Layout_Test.3dm (204.2 KB)

Many thanks for your wounderful work.
You have saved me from a major headache that is printing layouts from autocad.

Hello
I am using your script. Thanks a lot!

everything was fine but then I needed to print in color pdf. and for some reason not all colors are found in pdf?

Try enabling RasterMode for your layout:

#code before

settings = Rhino.Display.ViewCaptureSettings(view, size, dpi)
Rhino.Display.ViewCaptureSettings.RasterMode.SetValue(settings, True)

#code after
1 Like

Thanks a lot !!! Rays of gratitude. helped!

Hi, pretty cool components! I have 2 more questions:

  1. Is it somehow possible to select the namedView (Wireframe,Shaded,…) that will be displayed in the details?
  2. I don’t want to show all objects that are baked in rhino. Would be great if one could manage layer visibility in the details from grasshopper.