AddDetail script crashing Rhino

I can’t figure out why my script is crashing rhino. I can successfully complete the layout but not the detail.
The instant before rhino crashes a white rectangle appears on top of all four rhino viewports. Its definitely something that I am doing wrong. Not a rhino problem.


Layout.py (852 Bytes)

Hi @Ryan14,

Do you crash if you run the script in Rhino and not Grasshopper?

– Dale

Here is the message I got.

Looks like there is a similar post to mine, without an answer.

Hi @Ryan14,

Here is a working sample. Perhaps you can adapt it to your requirements.

import Rhino
import scriptcontext

def AddLayout():
    scriptcontext.doc.PageUnitSystem = Rhino.UnitSystem.Millimeters
    page_views = scriptcontext.doc.Views.GetPageViews()
    page_number = 1
    if page_views: page_number = len(page_views) + 1
    pageview = scriptcontext.doc.Views.AddPageView("A0_{0}".format(page_number), 1189, 841)
    if pageview:
        top_left = Rhino.Geometry.Point2d(20,821)
        bottom_right = Rhino.Geometry.Point2d(1169, 20)
        detail = pageview.AddDetailView("ModelView", top_left, bottom_right, Rhino.Display.DefinedViewportProjection.Top)
        if detail:
            pageview.SetActiveDetail(detail.Id)
            detail.Viewport.ZoomExtents()
            detail.DetailGeometry.IsProjectionLocked = True
            detail.DetailGeometry.SetScale(1, scriptcontext.doc.ModelUnitSystem, 10, scriptcontext.doc.PageUnitSystem)
            # Commit changes tells the document to replace the document's detail object
            # with the modified one that we just adjusted
            detail.CommitChanges()
        pageview.SetPageAsActive()
        scriptcontext.doc.Views.ActiveView = pageview
        scriptcontext.doc.Views.Redraw()

if __name__=="__main__":
    AddLayout()

– Dale

1 Like

Good morning @dale

I will see what I can do with that. Thanks for your help!

-Ryan Grossmann

@dale
:cry:
I still can’t figure out where I am going wrong.
I copied your code while inputting the gh variables in place of the things that I wanted to change to no avail. I also change the document settings from mills to inches.
Here’s the result.

Still no thoughts on this?

Hi @Ryan14,

Can you post a .gh file that isn’t working?

Thanks,

– Dale

Good Morning @dale
Here is the Gh File I cannot get to work.
Layout bounding box.gh (8.9 KB)
Thank you for your patients with me. It is much appreciated.

  • Ryan

Hi @Ryan14,

Does this work any better?

test_ryan.gh (5.1 KB)

– Dale

Just tried it. Instant crash. :sob:

@dale
Something interesting. If you watch the last second of the capture the It shows the default 4 view (Unintentionally) and there is a little grey viewport tab right behind the (Top) Viewport Tab.


Also, Just tried with Details set to 0. It successfully created a layout. Just with no Details.

Hi @Ryan14,

Can you run Rhino’s SystemInfo command and post the results?

Thanks,

– Dale

@dale
Sure Thing!

Rhino 7 SR29 2023-4-17 (Rhino 7, 7.29.23107.03001, Git hash:master @ 5f05ef3a2eea3d910c4c2fb79ccc75b413d33ca7)
License type: Commercial, build 2023-04-17
License details: Cloud Zoo

Windows 10 (10.0.19045 SR0.0) or greater (Physical RAM: 32Gb)

Computer platform: DESKTOP

Standard graphics configuration.
Primary display and OpenGL: NVIDIA GeForce RTX 2060 (NVidia) Memory: 6GB, Driver date: 7-21-2022 (M-D-Y). OpenGL Ver: 4.6.0 NVIDIA 516.94
> Accelerated graphics device with 4 adapter port(s)
- Windows Main Display attached to adapter port #0

OpenGL Settings
Safe mode: Off
Use accelerated hardware modes: On
Redraw scene when viewports are exposed: On
Graphics level being used: OpenGL 4.6 (primary GPU’s maximum)

Anti-alias mode: None
Mip Map Filtering: Linear
Anisotropic Filtering Mode: High

Vendor Name: NVIDIA Corporation
Render version: 4.6
Shading Language: 4.60 NVIDIA
Driver Date: 7-21-2022
Driver Version: 31.0.15.1694
Maximum Texture size: 32768 x 32768
Z-Buffer depth: 24 bits
Maximum Viewport size: 32768 x 32768
Total Video Memory: 6 GB

Rhino plugins that do not ship with Rhino
C:\Program Files\Rhino 7\Plug-ins\Tibidabo\VisualARQ.rhp “VisualARQ”
C:\Program Files\Rhino 7\Plug-ins\Tibidabo\Tibidabo.rhp “Tibidabo”
C:\Program Files\Scan&Solve Pro for Rhino 6 & 7\SnSPro_Rhino_6+7.rhp “Scan&Solve Pro for Rhino” 1.0.0.0

Rhino plugins that ship with Rhino
C:\Program Files\Rhino 7\Plug-ins\Commands.rhp “Commands” 7.29.23107.3001
C:\Program Files\Rhino 7\Plug-ins\rdk.rhp “Renderer Development Kit”
C:\Program Files\Rhino 7\Plug-ins\RPC.rhp “RPC”
C:\Program Files\Rhino 7\Plug-ins\AnimationTools.rhp “AnimationTools”
C:\Program Files\Rhino 7\Plug-ins\RhinoRenderCycles.rhp “Rhino Render” 7.29.23107.3001
C:\Program Files\Rhino 7\Plug-ins\RhinoRender.rhp “Legacy Rhino Render”
C:\Program Files\Rhino 7\Plug-ins\rdk_etoui.rhp “RDK_EtoUI” 7.29.23107.3001
C:\Program Files\Rhino 7\Plug-ins\rdk_ui.rhp “Renderer Development Kit UI”
C:\Program Files\Rhino 7\Plug-ins\NamedSnapshots.rhp “Snapshots”
C:\Program Files\Rhino 7\Plug-ins\IronPython\RhinoDLR_Python.rhp “IronPython” 7.29.23107.3001
C:\Program Files\Rhino 7\Plug-ins\RhinoCycles.rhp “RhinoCycles” 7.29.23107.3001
C:\Program Files\Rhino 7\Plug-ins\Grasshopper\GrasshopperPlugin.rhp “Grasshopper” 7.29.23107.3001
C:\Program Files\Rhino 7\Plug-ins\Toolbars\Toolbars.rhp “Toolbars” 7.29.23107.3001
C:\Program Files\Rhino 7\Plug-ins\3dxrhino.rhp “3Dconnexion 3D Mouse”
C:\Program Files\Rhino 7\Plug-ins\Displacement.rhp “Displacement”
C:\Program Files\Rhino 7\Plug-ins\Calc.rhp “Calc”

Thanks @Ryan14,

GH isn’t all that happy about layouts being created from a solution. I’ve created an issue so we can investigate further.

https://mcneel.myjetbrains.com/youtrack/issue/RH-75083

Thanks,

– Dale

1 Like

@dale
You are amazing. Thank you for your time and for looking into this for me. Let me know if you ever find an answer.

Thanks
-Ryan Grossmann

I know I am tacking onto an older post, still this year though.
I am running into this same exact issue. I can create the layouts in gh no problem, as soon as I try to use the AddDetail function Rhino crashes.

any headway on this in Rhino 7?

What does this comment mean?
Giulio Piacentino commented 24 Aug 2023 05:53
@Dale Fugier this is the old GhPython. I’ve fixed this, but I’m not sure about the new Python plans.
https://mcneel.myjetbrains.com/youtrack/issue/RH-75083/GhViewTable.Find-causes-System.StackOverflowException-exception#focus=Comments-74-391961.0-0

After creating the layouts in gh, I can select things in rhino and on the gh canvas, which is different from a comment in the issue.

Oh! in the issue it references 7.34 as the release target. I’m on 7.33

1 Like