Script below keeps crashing the model. Make2D command works fine.
from Rhino.DocObjects import ObjectType
from Rhino.Display import RhinoPageView
import scriptcontext as sc
import rhinoscriptsyntax as rs
selected_page_names = rs.MultiListBox([i.PageName for i in sc.doc.Views.GetPageViews()])
if selected_page_names == None:
selected_pages = [i for i in sc.doc.Views.GetPageViews() if i.PageName in selected_page_names]
for selected_page in selected_pages:
detail_views = RhinoPageView.GetDetailViews(selected_page)
for detail_view in detail_views:
if detail_view.Name == None:
if "CGeo" in detail_view.Name:
first_corner = Rhino.Geometry.Point2d(detail_view.Viewport.Bounds.Left, detail_view.Viewport.Bounds.Bottom)
second_corner = Rhino.Geometry.Point2d(detail_view.Viewport.Bounds.Right, detail_view.Viewport.Bounds.Top)
detail_view.IsActive = True
rhino_objects = sc.doc.Objects.FindByCrossingWindowRegion(detail_view.Viewport,
parameters = Rhino.Geometry.HiddenLineDrawingParameters()
parameters.AbsoluteTolerance = sc.doc.ModelAbsoluteTolerance
parameters.Flatten = True
parameters.IncludeHiddenCurves = False
parameters.IncludeTangentEdges = False
parameters.IncludeTangentSeams = False
for obj in rhino_objects:
# find a corresponding detail view - one with '-CGeo' suffix in the name
for vp in detail_views:
if vp.Name and detail_view.Name in vp.Name and "CGeo" in vp.Name:
cgeo_viewport = vp.Viewport
cgeo_viewport_plane = Rhino.Geometry.Plane(cgeo_viewport.CameraTarget,
xform = Rhino.Geometry.Transform.PlaneToPlane(Rhino.Geometry.Plane.WorldXY, cgeo_viewport_plane)
hld = Rhino.Geometry.HiddenLineDrawing.Compute(parameters, True)
for hld_curve in hld.Segments:
if not hld_curve:
if not hld_curve.ParentCurve:
if hld_curve.ParentCurve.SilhouetteType == Rhino.Geometry.SilhouetteType.None:
if hld_curve.SegmentVisibility == Rhino.Geometry.HiddenLineDrawingSegment.Visibility.Visible:
source_obj_attribs = rs.coercerhinoobject(hld_curve.ParentCurve.SourceObject.Tag).Attributes
curve = hld_curve.CurveGeometry.DuplicateCurve()
I’ve tried it again on another machine and Make2D stopped crashing:
Changing unit absolute tolerance from 0.001 to 1 made a huge difference in the output - I think this might have caused the crashes…
Interestingly though blocks were not being processed by the script, but they did work in the Make2D command. I’ve exploded them and the script worked fine. It would be useful though to find why blocks are being ignored to avoid the step of exploding them
It’s the same Rhino version though (WIP 8 8.0.23010.12305, 2023-01-10).
Thanks for letting me know, you are right 0.01 works even better.
There may still be an issue though with Making2D of linked blocks when run from a script (example 3dm file with a simple box and a sheet linking it attached here). It does work when run from “Make2D” command.
If you knew what might be causing it please let me know.
I see your crashing in the Rhino 8 WIP. Can you repeat the crash in Rhino 7?
I can see you’ve reported two crashes under the email of firstname.lastname@example.org, fwiw.
One of the crashes occurs deep in the .NET framework in what looks like a text (glyph) drawing routine. The crash occurs pretty far away from any Rhino function call. I’d suggest running Windows Updates and install all of them, expecially any .NET Framework or .NET Core updates.
The other crash is incomplete and, thus, inconclusive. But it does appear to be related to drawing.
It may be a bit tricky, there are many linked blocks that will need to be saved as Rhino 7…
There should be one more crash under email@example.com from earlier today - I will try to use this email from now on to avoid confusion.
That is really good to know - thank you. I will look for the latest updates then.
A follow up question: Is this type of diagnostic something that a user can do as well (using for example dotMemory/dotPeek/dotTrace or similar tools)? Or does it usually require the core source code? It sounds like a really useful technique that might explain a lot of crashes.
That’s true, there were some crashes even before installing vray, but if .NET Updates won’t help I will try removing plugins.
A bigger concern for me though is that make2d from the above python script doesn’t produce correct results in combination with clipping planes - solving this would really bring value for us now (model on the left, make2d(HiddenLineDrawing.Compute()) results on the right):
Well, you should try the Make2d command first. It is written in C# and calls the same APIs that are available to you. So if it works and your code does not, then there is something missing from your implementation.
Thanks for checking this. It’s good to hear that it’s reproducible. If you find out more please do update us. Due to many linked blocks moving back to Rhino 7 isnt straightforward, so hopefully some way to fix it will come up as well