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

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)

3 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