Rhino script executes correctly but not as background process

I’ve created a script that opens a file, selects a region, deletes everything else, and saves it, and it works fine when I execute it using the rhino command line or pasting it in command prompt (still opens up the gui) but if I run it with python using os.system or subprocess it runs in the background and doesn’t finish executing the script.

If I use different script commands like ‘SelSrf Delete SaveAs’ it runs properly in the background, but maybe there is something about the SelCircular command that won’t run without a gui?

Here’s the script:

“C:/Program Files/Rhino 7/System/Rhino.exe” /nosplash /runscript=“_-SelCircular 984365.8781,214434.5225 1000 _Invert _Delete _-SaveAs test.3dm _-Exit” “original model.3dm”

As fas as I understood, things like SelWindow, SelCircular etc. are pixel-based and thus may not do anything without the selection boundary actually on-screen.

Thanks, good to know, is there a way I can force it to run on screen from python?

Hi @Colin_Hofer,

Try running Rhino inside of CPython.

Rhino inside Python

GitHub - mcneel/rhino.inside-cpython

rhinoinside · PyPI

– Dale

I would approach it from another direction, that is how to find objects inside a volume (geometrically) without having to have anything showing on the screen. That is what the script does in the other thread you posted on a similar subject…

One cheap (script-wise) method is to mesh each object and check each mesh vertex if it is inside the volume; if one is found that isn’t, remove the object from the selection and go to the next one. It may be computationally expensive with large numbers of objects.