Hi All,
First off, this is my first post here. I’m no Python pro but I’ve written quite some Python and Micro Python code the past few years.
I started this post explaining the whole situation but that got way to complicated so I tried to narrow it down to the actual problem, if you need more info, just ask.
What I’m trying to do:
- I have a script (A) that runs in the virtual environment of Fusion 360
- I would like to call/run a script (B) on my ‘system Python’ from the Fusion script, see code below
The error I’m getting is:
PermissionError: [WinError 5] Access is denied
So my question is, how do I run a script on my main Python installation from within the Fusion 360 environment?
Thanks for your feedback.
My Fusion 360 script:
import adsk.core, adsk.fusion, adsk.cam, traceback
import subprocess
def run(context):
app = adsk.core.Application.get()
ui = app.userInterface
try:
# Run the script and wait for it to complete
python_path = "C:/Users/...../AppData/Local/Programs/Python/Python312"
script_path = "D:/Python_testscript/remote_script.py"
result = subprocess.run([python_path, script_path], capture_output=True, text=True)
# Check if the script ran successfully
if result.returncode == 0:
print("Script ran successfully")
print("Output:", result.stdout)
else:
print("Script encountered an error")
print("Error:", result.stderr)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))