Bug Report: Adding detail to Layout crashes Rhino (Python)

Hi fellow Rhino users and Developers,

trying to automate a boring task I have found what I believe is a bug in rhino.
The following script starts Grasshopper, loads a script and bakes an object. That all works per se. Object is baked and I can interact with it inside rhino. Commenting out the layout part of the script shows this.
The second part of the script adds a new layout and adds a detail to the layout. Executed by itself - skipping the GH part of the script - it works fine - layout is created, detail added.

Executing them after each other however (as in the script below) crashes Rhino on the line where it should add the detail. I tried switching away from the Layout back to a viewport but that did not help…

import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc

# GRASSHOPPER PART
objPlugin = rs.GetPlugInObject("Grasshopper")
if objPlugin is None:
	print("Error")
	
if objPlugin is not None:
	#objPlugin.LoadEditor()
	objPlugin.ShowEditor()
	doc = objPlugin.OpenDocument("E:\\test.ghx")
	if doc is False:
		print("Error loading doc")
	objPlugin.RunSolver(True)
	objs = []
	objs = objPlugin.BakeDataInObject("e9eb1dcf-92f6-4d4d-84ae-96222d60f56b")

# LAYOUT PART 
a4_height = 297
a4_width = 210 
lay = rs.AddLayout("Teste",(a4_height,a4_width))
if not lay:
	print("Error in creating layout")

# Tried switching away from the layout in order to prevent crash, failed.
rs.CurrentView("Top")

# Crashes on next line
sideview = rs.AddDetail(lay,(0,0),(a4_height,a4_width),"Side View",3)

test.ghx (69.7 KB)
BugReport_AddLayout.py (822 Bytes)

Does anyone have an idea what could provoke this? I have included an .GHX file that creates 10 cones called test.ghx, put it somewhere and change the path in the python script to reproduce. I think the GUID for the component to be baked should remain the same.

Rhino Version is 7 SR23 . It crashes without a “Report crash window”.

Any hints as to what I may do to resolve this issue (updating some obscure object table before adding detail or what not…) would be greatly appreciated!
Thank you very much and best regards
Malte

It fails at line 10 in the AddDetail function.

layout_id should be valid for all I know as all the checks below have not given any reason to suspect otherwise.

lay = rs.AddLayout("TestLayout",(a4w,a4h))
if not lay:
	print("Error in creating layout")
	
ret = rs.IsLayout(lay)
if ret == True:
	print("Is a layout")
	sideview = rs.AddDetail(lay,(0,0),(a4w/2,a4h),"Side View",3)
	frontview = rs.AddDetail(lay,(a4w/2,0),(a4w,a4h),"Front view",1)

So IsLayout returns True and then in the AddDetail the :

    layout = scriptcontext.doc.Views.Find(layout_id)

Line causes the crash…

I have tried saving the file after the GH bake, opening a new one and then loading the saved file… does not work either. BUT… if i open a new rhino instance, load the saved file and execute the layout part it works… I’m really “at the end of my latin” here :smile:

Best regards
M.

Hi @m112,

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

Also, when Rhino crashed, did it ask you if you wanted to submit the crash for analysis?

Thanks,

– Dale

Hi @dale ,
thanks for having a peek into it :).

Rhino 7 SR23 2022-10-9 (Rhino 7, 7.23.22282.13001, Git hash:master @ a931168ca9426920ae6aa97218710b662f17fc39)
License type: Educational, build 2022-10-09
License details: Cloud Zoo

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

Computer platform: DESKTOP 

Standard graphics configuration.
  Primary display and OpenGL: NVIDIA GeForce RTX 2070 (NVidia) Memory: 8GB, Driver date: 12-29-2021 (M-D-Y). OpenGL Ver: 4.6.0 NVIDIA 511.09
    > Accelerated graphics device with 4 adapter port(s)
        - Windows Main Display attached to adapter port #0
        - Secondary monitor attached to adapter port #1
        - Secondary monitor attached to adapter port #2

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: 4x
  Mip Map Filtering: Linear
  Anisotropic Filtering Mode: High
  
  Vendor Name: NVIDIA Corporation
  Render version: 4.6
  Shading Language: 4.60 NVIDIA
  Driver Date: 12-29-2021
  Driver Version: 30.0.15.1109
  Maximum Texture size: 32768 x 32768
  Z-Buffer depth: 24 bits
  Maximum Viewport size: 32768 x 32768
  Total Video Memory: 8 GB

Rhino plugins that do not ship with Rhino
  C:\Users\Teknix\AppData\Roaming\McNeel\Rhinoceros\packages\7.0\EleFront\4.2.2\ElefrontProperties.rhp	"ElefrontProperties"	1.0.0.0
  C:\Users\Teknix\AppData\Roaming\McNeel\Rhinoceros\packages\7.0\Bullant\1.5.11.0\bullant.rhp	"bullant"	1.5.11.0

Rhino plugins that ship with Rhino
  C:\Program Files\Rhino 7\Plug-ins\Commands.rhp	"Commands"	7.23.22282.13001
  C:\Program Files\Rhino 7\Plug-ins\rdk.rhp	"Renderer Development Kit"	
  C:\Program Files\Rhino 7\Plug-ins\RhinoRenderCycles.rhp	"Rhino Render"	7.23.22282.13001
  C:\Users\Teknix\AppData\Roaming\McNeel\Rhinoceros\packages\7.0\PanelingTools\2020.12.9.865\PanelingTools.rhp	"PanelingTools"	
  C:\Program Files\Rhino 7\Plug-ins\rdk_etoui.rhp	"RDK_EtoUI"	7.23.22282.13001
  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\RhinoCycles.rhp	"RhinoCycles"	7.23.22282.13001
  C:\Program Files\Rhino 7\Plug-ins\Toolbars\Toolbars.rhp	"Toolbars"	7.23.22282.13001
  C:\Program Files\Rhino 7\Plug-ins\3dxrhino.rhp	"3Dconnexion 3D Mouse"	
  C:\Program Files\Rhino 7\Plug-ins\Displacement.rhp	"Displacement"	

Sadly it does not offer me that option, it just dies all silently and doesn’t even offer file recovery or anything else… it is just gone :).
Super interested to hear what you think about it :slight_smile:
Best regards
Malte

Hi @m112,

So far, I am not able to repeat the crash. Can you repeat it? If so, can you provide a dumbed down script that I can run here that exhibits the crash?

Thanks,

– Dale

Hi @dale,

sure, here is a dumbed down script and i reattached the GHX file as well below I will outline the exact steps.

import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc

# GRASSHOPPER PART
objPlugin = rs.GetPlugInObject("Grasshopper")
if objPlugin is None:
	print("Error")
	
if objPlugin is not None:
	#objPlugin.LoadEditor()
	objPlugin.ShowEditor()
	doc = objPlugin.OpenDocument("E:\\test.ghx")
	if doc is False:
		print("Error loading doc")
	objPlugin.RunSolver(True)
	objs = []
	objs = objPlugin.BakeDataInObject("a54c048f-08a2-4799-a03b-c22eb64f36eb")


rs.Command("_-SaveAs "+chr(34)+"E:\\BakedObjs.3dm"+chr(34)+" _Enter",False)
rs.Command("_-New "+chr(34)+"Small Objects - Millimeters.3dm"+chr(34)+" _Enter",False)
rs.Command("_-Open "+chr(34)+"E:\\BakedObjs.3dm"+chr(34)+" _Enter",False)

# LAYOUT PART 
a4_height = 297
a4_width = 210 
lay = rs.AddLayout("Teste",(a4_height,a4_width))
if not lay:
	print("Error in creating layout")

# Tried switching away from the layout in order to prevent crash, failed.
rs.CurrentView("Top")

# Crashes on next line
ret = rs.IsLayout(lay)
if ret == True:
	print("Is a layout shouldnt crash :(")
	sideview = rs.AddDetail(lay,(0,0),(a4_height,a4_width),"Side View",3)
  • Open a fresh Rhino
  • Load the Python Script Editor
  • Paste the script (save it for convenvience)
  • Set a breakpoint on the sideview = AddDetail line (optional - crashes in debug and not debug mode)
  • Execute the python script
    (GH Loads, GH opens the test file, bakes objects, saves file etc.)
  • Continue at the breakpoint / or direct crash (if not debug mode)

→ The bakedObjects.3dm file contains the cones
→ Loading that file in a fresh Rhino and only running (comment out all the grasshopper stuff in the beginning and start with loading the file BakedObjs.3dm) the Layout part works → Layout is created no crash…

Hope that helps to reproduce it… if not let me know because it is really driving me crazy :smiley: (all the tests I could do point to a non understandable issue for me).

Thanks and best regards
Malte
test.ghx (70.6 KB)