I’ve written a programm that loops through several Rhino Files, in each file deletes several geometries and layouts.

I do this by opening a file and overwriting the RhinoDoc doc with RhinoDoc.ActiveDoc

Generally the programm works. However after a while (3-4 loops) I get an Error

One of the PageViews gets an AccessViolationException (see Screenshot below)

The programm also uses several RunScript Commands inside (DWG-Export)

Now I wonder, what the reason for that might be and how I could avoid that. (Is there a way to catch this?)

Interestingly enough, If I minimize Rhino it seems to be working better (Error still occurs though after a few more loops)


Here are a few Screenshots:

Hi Martin,

FWIW jyst thinking out loud
Could it be the program is too fast…
What happens if you build in some pauses. If you are exporting to DWG via rhinoscript commands there is a good chance the exporter is still running or the exported files are handled in the background while your program already moves on. Maybe you can find a way to see of the DWG is written to file and ‘finalized’ before your program progresses to the next steps.


Hi Willem,

that might have been the Problem.

I added this after every File Export:

while (!System.IO.File.Exists(tempFilePath))
if (startTime + TimeSpan.FromSeconds(10) > DateTime.Now)
RhinoApp.WriteLine(“Timeout waiting for dwg Creation”);

Seems to work better. Didn’t check it with 1000 Files yet - but I’ll do that in the future soon.


1 Like