<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Run a extern batch file Python in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/run-a-extern-batch-file-python/m-p/9796437#M18990</link>
    <description>&lt;P&gt;I am trying to do the same thing.&lt;/P&gt;&lt;P&gt;What is the subprocess module you you mentioned here?&lt;/P&gt;&lt;P&gt;I tried this which was suggested by another contributor:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;FONT color="#FF0000"&gt;&amp;nbsp;&lt;SPAN style="font-family: inherit;"&gt;subprocess.run([sys.executable,&amp;nbsp;'SHCS'])&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;SPAN style="font-family: inherit;"&gt;but nothing happened.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;SPAN style="font-family: inherit;"&gt;Thanks for any help.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 11 Oct 2020 16:10:54 GMT</pubDate>
    <dc:creator>brad.bylls</dc:creator>
    <dc:date>2020-10-11T16:10:54Z</dc:date>
    <item>
      <title>Run a extern batch file Python</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/run-a-extern-batch-file-python/m-p/6701104#M18988</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;i have a external bat file in a external folder for example c:\test\test.bat&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. now i have a custom Button in Fusion now my question how can i start the bat file in the Folfer???&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 21:32:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/run-a-extern-batch-file-python/m-p/6701104#M18988</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-11-21T21:32:02Z</dc:date>
    </item>
    <item>
      <title>Re: Run a extern batch file Python</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/run-a-extern-batch-file-python/m-p/6701174#M18989</link>
      <description>&lt;P&gt;You can use the Python &lt;STRONG&gt;os&lt;/STRONG&gt; module, particularly the &lt;STRONG&gt;startfile&lt;/STRONG&gt; function (see &lt;A href="https://docs.python.org/3.3/library/os.html#os.startfile).&amp;nbsp;" target="_blank"&gt;https://docs.python.org/3.3/library/os.html#os.startfile).&amp;nbsp;&lt;/A&gt; Note that this is Windows only; if you also wanted to support scripts on Mac, it looks like you can use the &lt;STRONG&gt;system&lt;/STRONG&gt; function (docs available on the same page as startfile).&amp;nbsp; Or, you can use the &lt;STRONG&gt;subprocess&lt;/STRONG&gt; module (I've used this and know it works for opening files in their default program).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 22:05:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/run-a-extern-batch-file-python/m-p/6701174#M18989</guid>
      <dc:creator>jesse</dc:creator>
      <dc:date>2016-11-21T22:05:16Z</dc:date>
    </item>
    <item>
      <title>Re: Run a extern batch file Python</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/run-a-extern-batch-file-python/m-p/9796437#M18990</link>
      <description>&lt;P&gt;I am trying to do the same thing.&lt;/P&gt;&lt;P&gt;What is the subprocess module you you mentioned here?&lt;/P&gt;&lt;P&gt;I tried this which was suggested by another contributor:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;FONT color="#FF0000"&gt;&amp;nbsp;&lt;SPAN style="font-family: inherit;"&gt;subprocess.run([sys.executable,&amp;nbsp;'SHCS'])&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;SPAN style="font-family: inherit;"&gt;but nothing happened.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;SPAN style="font-family: inherit;"&gt;Thanks for any help.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2020 16:10:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/run-a-extern-batch-file-python/m-p/9796437#M18990</guid>
      <dc:creator>brad.bylls</dc:creator>
      <dc:date>2020-10-11T16:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: Run a extern batch file Python</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/run-a-extern-batch-file-python/m-p/9796517#M18991</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;i don't longer use Fusion 360 I was changed to Alibre because of the&lt;BR /&gt;conditions of terms of Autodesk changes to much and the Data from my clients&lt;BR /&gt;is better local storage nothing in the cloud.&lt;BR /&gt;&lt;BR /&gt;I hope you find a solution.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 11 Oct 2020 17:47:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/run-a-extern-batch-file-python/m-p/9796517#M18991</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-10-11T17:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: Run a extern batch file Python</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/run-a-extern-batch-file-python/m-p/9798100#M18992</link>
      <description>&lt;P&gt;Hey Brad,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are the docs for the subprocess module:&amp;nbsp;&lt;A href="https://docs.python.org/3/library/subprocess.html" target="_blank"&gt;https://docs.python.org/3/library/subprocess.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think you're on the right track with that, but it probably needs to be tweaked to meet your specific situation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first argument to run is a list (e.g. [...]) which is the command line you want to run.&amp;nbsp; So for example, if, in a Windows terminal, you would type "SHCS" and hit enter and it would run, you might be able to use:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;subprocess.run(['SHCS'])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this doesn't work, you may need to add the full directory path, e.g.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;subprocess.run(['C:\path\to\file\SHCS'])&lt;/P&gt;&lt;P&gt;(where the dummy path here is replaced with the actual directory path to the file)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If it is a batch file called SHCS, and that still isnt working, try:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;subprocess.run(['cmd', '/c', 'C:\path\to\file\SHCS'])&lt;/P&gt;&lt;P&gt;(same as above re the dummy path)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 15:27:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/run-a-extern-batch-file-python/m-p/9798100#M18992</guid>
      <dc:creator>jesse</dc:creator>
      <dc:date>2020-10-12T15:27:20Z</dc:date>
    </item>
    <item>
      <title>Re: Run a extern batch file Python</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/run-a-extern-batch-file-python/m-p/9798651#M18993</link>
      <description>&lt;P&gt;Jesse,&lt;/P&gt;&lt;P&gt;I started with this:&amp;nbsp;&amp;nbsp;supprocess.run(['SHCS.py'])&lt;/P&gt;&lt;P&gt;Error messages in debug terminal&lt;BR /&gt;At line:1 char:17&lt;BR /&gt;+ supprocess.run(['SHCS.py'])&lt;BR /&gt;+ ~&lt;BR /&gt;Missing type name after '['.&lt;BR /&gt;+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException&lt;BR /&gt;+ FullyQualifiedErrorId : MissingTypename&lt;/P&gt;&lt;P&gt;================================================================&lt;/P&gt;&lt;P&gt;Then I tried:&amp;nbsp; filepath =&amp;nbsp;&lt;SPAN style="font-family: inherit;"&gt;os.path.dirname(os.path.realpath(&lt;/SPAN&gt;&lt;SPAN style="font-family: inherit;"&gt;__file__&lt;/SPAN&gt;&lt;SPAN style="font-family: inherit;"&gt;))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;supprocess.run(['cmd', filepath + '\\SHCS.py'])&lt;/P&gt;&lt;P&gt;Error in debug terminal:&lt;BR /&gt;At line:1 char:17&lt;BR /&gt;+ supprocess.run(['cmd', filepath + '\\SHCS.py'])&lt;BR /&gt;+ ~&lt;BR /&gt;Missing type name after '['.&lt;BR /&gt;At line:1 char:22&lt;BR /&gt;+ supprocess.run(['cmd', filepath + '\\SHCS.py'])&lt;BR /&gt;+ ~&lt;BR /&gt;Missing argument in parameter list.&lt;BR /&gt;+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException&lt;BR /&gt;+ FullyQualifiedErrorId : MissingTypename&lt;/P&gt;&lt;P&gt;=====================================================================&lt;/P&gt;&lt;P&gt;filepath =&amp;nbsp;&lt;SPAN style="font-family: inherit;"&gt;os.path.dirname(os.path.realpath(&lt;/SPAN&gt;&lt;SPAN style="font-family: inherit;"&gt;__file__&lt;/SPAN&gt;&lt;SPAN style="font-family: inherit;"&gt;))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;When I use:&amp;nbsp; supprocess.run([filepath + '\\SHCS.py'])&lt;/P&gt;&lt;P&gt;Error in debug terminal:&lt;BR /&gt;At line:1 char:25&lt;BR /&gt;+ supprocess.run([filepath + '\\SHCS.py'])&lt;BR /&gt;+ ~&lt;BR /&gt;Missing ] at end of attribute or type literal.&lt;BR /&gt;At line:1 char:39&lt;BR /&gt;+ supprocess.run([filepath + '\\SHCS.py'])&lt;BR /&gt;+ ~&lt;BR /&gt;Unexpected token ']' in expression or statement.&lt;BR /&gt;At line:1 char:39&lt;BR /&gt;+ supprocess.run([filepath + '\\SHCS.py'])&lt;BR /&gt;+ ~&lt;BR /&gt;Missing closing ')' in expression.&lt;BR /&gt;At line:1 char:40&lt;BR /&gt;+ supprocess.run([filepath + '\\SHCS.py'])&lt;BR /&gt;+ ~&lt;BR /&gt;Unexpected token ')' in expression or statement.&lt;BR /&gt;+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException&lt;BR /&gt;+ FullyQualifiedErrorId : EndSquareBracketExpectedAtEndOfAttribute&lt;/P&gt;&lt;P&gt;===================================================================&lt;/P&gt;&lt;P&gt;And when I run:&amp;nbsp;&amp;nbsp;supprocess.run(['cmd', '/c', filepath + '\\SHCS.py'])&lt;/P&gt;&lt;P&gt;Error messages in debug terminal:&lt;BR /&gt;At line:1 char:17&lt;BR /&gt;+ supprocess.run(['cmd', '/c', filepath + '\\SHCS.py'])&lt;BR /&gt;+ ~&lt;BR /&gt;Missing type name after '['.&lt;BR /&gt;At line:1 char:22&lt;BR /&gt;+ supprocess.run(['cmd', '/c', filepath + '\\SHCS.py'])&lt;BR /&gt;+ ~&lt;BR /&gt;Missing argument in parameter list.&lt;BR /&gt;+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException&lt;BR /&gt;+ FullyQualifiedErrorId : MissingTypename&lt;/P&gt;&lt;P&gt;==============================================================&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 20:23:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/run-a-extern-batch-file-python/m-p/9798651#M18993</guid>
      <dc:creator>brad.bylls</dc:creator>
      <dc:date>2020-10-12T20:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: Run a extern batch file Python</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/run-a-extern-batch-file-python/m-p/9798679#M18994</link>
      <description>&lt;P&gt;Hey Brad,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It looks like you maybe be running these commands from a PowerShell command line, which is where the errors about missing type name and so forth are coming from.&amp;nbsp; The subprocess module must be used inside of a Python process, either as part of a Fusion script or add-in, or by running Python from your PowerShell command line first.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I might do if I were you is this: go to Fusion, and click on File (at the top left, to the right of the A360 data panel), then hover over View, and look for Show Text Commands.&amp;nbsp; If it's there, click it to show a text command window at the bottom of Fusion; if it says Hide Text Commands, then the window is already opened somewhere.&amp;nbsp; On that window, there's a radio selector in the bottom right: Text, Py, and Js.&amp;nbsp; When Py is selected, you can type Python commands in there to be executed using Fusion's Python interpreter.&amp;nbsp; From there, you can&amp;nbsp;&lt;STRONG&gt;import subprocess&lt;/STRONG&gt; and then try&amp;nbsp;&lt;STRONG&gt;subprocess.run(...)&lt;/STRONG&gt; with one of the argument sets I mentioned above.&amp;nbsp; Since you are using a python script SHCS.py, sys.executable might be what you want instead of cmd.exe after all; you can test that in here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The nice thing about this is once you have your python commands figured out here, they can go right into a Fusion 360 script (Tools -&amp;gt; Addins -&amp;gt; Scripts &amp;amp; Addins, then press Create when Scripts is selected) that can be run repeatedly from within Fusion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that helps!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 20:47:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/run-a-extern-batch-file-python/m-p/9798679#M18994</guid>
      <dc:creator>jesse</dc:creator>
      <dc:date>2020-10-12T20:47:41Z</dc:date>
    </item>
    <item>
      <title>Re: Run a extern batch file Python</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/run-a-extern-batch-file-python/m-p/9798770#M18995</link>
      <description>&lt;P&gt;sys.executable might be it, but the sysntax is just to complicated for this newbie.&lt;/P&gt;&lt;P&gt;Thanks though.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 21:48:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/run-a-extern-batch-file-python/m-p/9798770#M18995</guid>
      <dc:creator>brad.bylls</dc:creator>
      <dc:date>2020-10-12T21:48:38Z</dc:date>
    </item>
    <item>
      <title>Re: Run a extern batch file Python</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/run-a-extern-batch-file-python/m-p/9800745#M18996</link>
      <description>&lt;P&gt;Hey Jesse,&lt;/P&gt;&lt;P&gt;Sorry, none of your suggestions worked.&lt;/P&gt;&lt;P&gt;After some more research on line and in the forums, I found out what did work.&lt;/P&gt;&lt;P&gt;I set the external file up as a function and then in the main program and call the function.&lt;/P&gt;&lt;P&gt;During debugging I see that it starts running the external script and I can follow it along.&lt;/P&gt;&lt;P&gt;The problem I'm having now is that the external file doesn't work at one point, even though it did when it was just a plain script file.&lt;/P&gt;&lt;P&gt;I have to keep plugging along.&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 18:14:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/run-a-extern-batch-file-python/m-p/9800745#M18996</guid>
      <dc:creator>brad.bylls</dc:creator>
      <dc:date>2020-10-13T18:14:05Z</dc:date>
    </item>
  </channel>
</rss>

