Over the years I’ve created some useful python commands by following this tutorial.
The other day I tried to use an f-string in my code and got some issues. I’d been using cpython3 heavily for rhino scripting via the ScriptEditor, etc. I didn’t realize that python commands are still running in ironpython 2.7 . This made me wonder, is it possible to have commands from the python plugin structure trigger python3 scripts?
I tried the shebang trick just to confirm:
#! python3
import sys
__commandname__ = "CommandPythonVersion"
def RunCommand( is_interactive):
print('Rhino Command Python Version:')
print(sys.version)
Which gave this output:
Command: CommandPythonVersion
Rhino Command Python Version:
2.7.12 (2.7.12.1000)
[.NETCoreApp,Version=v3.1 on .NET 7.0.0 (64-bit)]
I can run python 3 scripts using !-RunPythonScript "/Users/tristanryerparke/version.py"
which could be linked to an alias, but the plugin package structure I find is so simple and nice to use.
Is it possible to do this?
version.py:
#! python3
import sys
print('Rhino Python Version:')
print(sys.version)
output:
Command: -RunPythonScript
Python Script </Users/tristanryerparke/version.py> ( ResetEngine )"/Users/tristanryerparke/version.py"
Rhino Python Version:
3.9.10 (v3.9.10:f2f3f53782, Jan 13 2022, 16:55:45)
[Clang 13.0.0 (clang-1300.0.29.30)]
Cheers,
T