Put the _No and _Enter on the same line as your -_Exit:
_Point 0 _Enter
-_Exit _No _Enter
Put the _No and _Enter on the same line as your -_Exit:
_Point 0 _Enter
-_Exit _No _Enter
No, I just used the Macro Editor to run the macro.
Is having the macro in a text file necessary for your use case?
Yes.
My complete process is the following:
So while preparing snippets to show, I ran into an interesting behavior, coherent with the previous attempts.
Here are two python snippets, which I am running from pycharm.
The first one uses an intermediary command file, while the second one does not.
With file
import subprocess
RHINO_PATH = r"Rhino.exe"
instructions = "_-Point 0 _-Enter\n" \
"_-Exit _-No _-Enter\n"
filepath = "RhinoCommandFile.txt"
with open(filepath, "w") as fp:
fp.write(instructions)
rhino_script = f"_-ReadCommandFile {filepath}"
call_script = f'"{RHINO_PATH}" /nosplash /runscript="{rhino_script}"'
subprocess.call(call_script)
Without file
import subprocess
RHINO_PATH = r"Rhino.exe"
instructions = "_-Point 0 _-Enter\n" \
"_-Exit _-No _-Enter\n"
call_script = f'"{RHINO_PATH}" /nosplash /runscript="{instructions}"'
subprocess.call(call_script)
With the file, same result as previously.
Without the file, well, I was not able to screenshot it since it works.
Unfortunately that does not solve my problem, since when my set of instructions becomes too large I get FileNotFoundError: [WinError 206] The filename or extension is too long
.
Thank you for persisting in describing your problem. I now see how you intend to use this.
I see that indeed the _-Exit
does not work, and that any commands after it in the command file do not work.
Note though that you write _-Enter
(dashed version), while it should be just _Enter
.
Thank you @nathanletwory!
Right, I sort of over-dashed everything there!
Same thing with “_-No” which is even not recognized, I forgot to correct it before posting, should be “_No”.
Thanks again
Yup, I fixed that up in my own tests an the bug report (:
Thank you Brian.
To be honest, I’d have liked to see that working with R6. I have read the related discussion on Youtrack though and I get it. I might come back if it becomes very blocking!
Is there any news about that?
Because I still have this problem randomly with rhino 7.
I start rhino from the command line, open a file, run a python script,that ends with an exit:
rs.DocumentModified(False)
rs.Command("-_Exit _No _Enter")
but it seems that closing rhino is a problem , the crazy thing is that sometimes it works and sometimes it doesn’t.
Hi @Pitti,
Does this work?
import ctypes
import Rhino
import scriptcontext
def test_exit_without_saving():
scriptcontext.doc.Modified = False
hWnd = Rhino.RhinoApp.MainWindowHandle()
ctypes.windll.user32.PostMessageW(hWnd, 0x0010, 0, 0)
test_exit_without_saving()
– Dale
@dale
It seems to work, but the problem appears only occasionally, I also want to test it with multiple instances of rhino open.
I thank you for now and will keep you updated.
Resurrecting an old thread here, I know…
I ran into this same problem while trying to close Rhino from inside a Python script. I tried the rs.DocumentModified(False) & rs.Exit() route, but I was still getting the “Save File?” dialogue. Ultimately Dale’s ctypes solution did work, but I was just wondering if this is still the best solution 3 years on.