<?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: In C++  Open a File and Read Write Integer Double String  Data then Close in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/in-c-open-a-file-and-read-write-integer-double-string-data-then/m-p/8239204#M15548</link>
    <description>&lt;P&gt;The Fusion 360 API doesn't have any functionality to open and read or write to files.&amp;nbsp; However, the reason it doesn't have any functionality is that the programming languages themselves (Python and C++) both support that functionality.&amp;nbsp; So you can use the standard C++ libraries to read and write files.&amp;nbsp; Here's one introduction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.cplusplus.com/doc/tutorial/files/&amp;nbsp;&amp;nbsp;" target="_blank"&gt;http://www.cplusplus.com/doc/tutorial/files/&amp;nbsp;&amp;nbsp;&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 01 Sep 2018 00:26:22 GMT</pubDate>
    <dc:creator>BrianEkins</dc:creator>
    <dc:date>2018-09-01T00:26:22Z</dc:date>
    <item>
      <title>In C++  Open a File and Read Write Integer Double String  Data then Close</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/in-c-open-a-file-and-read-write-integer-double-string-data-then/m-p/8238880#M15547</link>
      <description>&lt;DIV&gt;In C++ File Open Read Write Integer Double String Close&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;In Fusion 360 using C++ I would like to,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Open a Read Only text file and Read Integer, Double and String Data, then Close it.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Open a Write text File and Write Integer, Double and String Data, then Close it.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thurai Moorthy&lt;/DIV&gt;</description>
      <pubDate>Fri, 31 Aug 2018 19:50:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/in-c-open-a-file-and-read-write-integer-double-string-data-then/m-p/8238880#M15547</guid>
      <dc:creator>tperam</dc:creator>
      <dc:date>2018-08-31T19:50:54Z</dc:date>
    </item>
    <item>
      <title>Re: In C++  Open a File and Read Write Integer Double String  Data then Close</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/in-c-open-a-file-and-read-write-integer-double-string-data-then/m-p/8239204#M15548</link>
      <description>&lt;P&gt;The Fusion 360 API doesn't have any functionality to open and read or write to files.&amp;nbsp; However, the reason it doesn't have any functionality is that the programming languages themselves (Python and C++) both support that functionality.&amp;nbsp; So you can use the standard C++ libraries to read and write files.&amp;nbsp; Here's one introduction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.cplusplus.com/doc/tutorial/files/&amp;nbsp;&amp;nbsp;" target="_blank"&gt;http://www.cplusplus.com/doc/tutorial/files/&amp;nbsp;&amp;nbsp;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Sep 2018 00:26:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/in-c-open-a-file-and-read-write-integer-double-string-data-then/m-p/8239204#M15548</guid>
      <dc:creator>BrianEkins</dc:creator>
      <dc:date>2018-09-01T00:26:22Z</dc:date>
    </item>
    <item>
      <title>Re: In C++  Open a File and Read Write Integer Double String  Data then Close</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/in-c-open-a-file-and-read-write-integer-double-string-data-then/m-p/8239618#M15549</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I Tried the following&amp;nbsp; C++ Code, which did not work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you post a sample code that works in Fusion 360 please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Thurai&lt;/P&gt;&lt;DIV&gt;&lt;BR /&gt;#include &amp;lt;Core/CoreAll.h&amp;gt;&lt;BR /&gt;#include &amp;lt;Fusion/FusionAll.h&amp;gt;&lt;BR /&gt;#include &amp;lt;CAM/CAMAll.h&amp;gt;&lt;/DIV&gt;&lt;DIV&gt;#include &amp;lt;stdio.h&amp;gt;&lt;BR /&gt;#include &amp;lt;io.h&amp;gt;&lt;BR /&gt;#include &amp;lt;iostream&amp;gt;&lt;BR /&gt;#include &amp;lt;iomanip&amp;gt;&lt;BR /&gt;#include &amp;lt;fstream&amp;gt;&lt;BR /&gt;#include &amp;lt;string.h&amp;gt;&lt;BR /&gt;#include &amp;lt;conio.h&amp;gt;&lt;BR /&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;BR /&gt;#include &amp;lt;time.h&amp;gt;&lt;BR /&gt;#include &amp;lt;conio.h&amp;gt;&lt;BR /&gt;#include &amp;lt;assert.h&amp;gt;&lt;BR /&gt;#include &amp;lt;math.h&amp;gt;&lt;BR /&gt;#include &amp;lt;memory.h&amp;gt;&lt;BR /&gt;#include &amp;lt;errno.h&amp;gt;&lt;/DIV&gt;&lt;DIV&gt;//#include &amp;lt;iostream&amp;gt;&lt;BR /&gt;#include &amp;lt;complex&amp;gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;using namespace adsk::core;&lt;BR /&gt;using namespace adsk::fusion;&lt;BR /&gt;using namespace adsk::cam;&lt;/DIV&gt;&lt;DIV&gt;using namespace std;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;Ptr&amp;lt;Application&amp;gt; app;&lt;BR /&gt;Ptr&amp;lt;UserInterface&amp;gt; ui;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;extern "C" XI_EXPORT bool run(const char* context)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;app = Application::get();&lt;BR /&gt;&amp;nbsp;if (!app)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;return false;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;ui = app-&amp;gt;userInterface();&lt;BR /&gt;&amp;nbsp;if (!ui)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;return false;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;ui-&amp;gt;messageBox("Hello script");&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;/* create a file */&lt;BR /&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;/* Test Writing to a file */ &amp;nbsp;&lt;BR /&gt;&amp;nbsp;ofstream outflm;&lt;BR /&gt;&amp;nbsp;outflm.open("outflm.txt");&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;double a = 10.0;&lt;BR /&gt;&amp;nbsp;char aStr[16]; // string which will contain the number&lt;BR /&gt;&amp;nbsp;sprintf_s ( aStr, "%f", a ); // %d makes the result be a decimal integer&lt;BR /&gt;&amp;nbsp;string SaStr;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SaStr += "Test aStr";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SaStr += " ";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SaStr += aStr;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ui-&amp;gt;messageBox(SaStr);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; outflm &amp;lt;&amp;lt; SaStr;&lt;BR /&gt;&amp;nbsp; outflm.close();&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp; char str[100]; &amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp; ifstream inflm;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; inflm.open("inflm.txt");&lt;BR /&gt;&amp;nbsp;&amp;nbsp; inflm.getline(str, 100, '#');&lt;BR /&gt;&amp;nbsp;&amp;nbsp; ui-&amp;gt;messageBox("str", str);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp; string x = "fred";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int d = 3;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; char dStr[16]; // string which will contain the number&lt;BR /&gt;&amp;nbsp;&amp;nbsp; sprintf_s ( dStr, "%d", d ); // %d makes the result be a decimal integer&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; ui-&amp;gt;messageBox("Test messageBox");&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; string msg;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; msg = "Test 2";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; msg += " ";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; msg += x;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; msg += " ";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; msg += dStr;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ui-&amp;gt;messageBox(msg);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;return true;&lt;BR /&gt;}&lt;/DIV&gt;&lt;DIV&gt;#ifdef XI_WIN&lt;/DIV&gt;&lt;DIV&gt;#include &amp;lt;windows.h&amp;gt;&lt;/DIV&gt;&lt;DIV&gt;BOOL APIENTRY DllMain(HMODULE hmodule, DWORD reason, LPVOID reserved)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;switch (reason)&lt;BR /&gt;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;case DLL_PROCESS_ATTACH:&lt;BR /&gt;&amp;nbsp;case DLL_THREAD_ATTACH:&lt;BR /&gt;&amp;nbsp;case DLL_THREAD_DETACH:&lt;BR /&gt;&amp;nbsp;case DLL_PROCESS_DETACH:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;break;&lt;BR /&gt;&amp;nbsp;}&lt;BR /&gt;&amp;nbsp;return TRUE;&lt;BR /&gt;}&lt;/DIV&gt;&lt;DIV&gt;#endif // XI_WIN&lt;/DIV&gt;</description>
      <pubDate>Sat, 01 Sep 2018 14:55:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/in-c-open-a-file-and-read-write-integer-double-string-data-then/m-p/8239618#M15549</guid>
      <dc:creator>tperam</dc:creator>
      <dc:date>2018-09-01T14:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: In C++  Open a File and Read Write Integer Double String  Data then Close</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/in-c-open-a-file-and-read-write-integer-double-string-data-then/m-p/8240615#M15550</link>
      <description>&lt;P&gt;Hi Brian Ekins,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; The reason I would like to do&amp;nbsp; file input output in Fusion 360 is to have the capability of having the data for hundreds or more&amp;nbsp; of sketches in a file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to import the common C++ Library &lt;SPAN&gt;file input output &lt;/SPAN&gt;capability&amp;nbsp; into Fusion 360?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Sun, 02 Sep 2018 19:57:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/in-c-open-a-file-and-read-write-integer-double-string-data-then/m-p/8240615#M15550</guid>
      <dc:creator>tperam</dc:creator>
      <dc:date>2018-09-02T19:57:13Z</dc:date>
    </item>
    <item>
      <title>Re: In C++  Open a File and Read Write Integer Double String  Data then Close</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/in-c-open-a-file-and-read-write-integer-double-string-data-then/m-p/8240997#M15551</link>
      <description>&lt;P&gt;I tried your code and it worked for me.&amp;nbsp;May I know what problem you are seeing with your code. The best way to create C++ Script/Add-in is to&amp;nbsp;start&amp;nbsp;with default C++ project. Please look at the following&amp;nbsp;link&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-9701BBA7-EC0E-4016-A9C8-964AA4838954" target="_blank"&gt;http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-9701BBA7-EC0E-4016-A9C8-964AA4838954&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will set VS project settings correctly and you can modify it later for your work. You can use any C++ library for your script.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Sep 2018 05:24:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/in-c-open-a-file-and-read-write-integer-double-string-data-then/m-p/8240997#M15551</guid>
      <dc:creator>goyals</dc:creator>
      <dc:date>2018-09-03T05:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: In C++  Open a File and Read Write Integer Double String  Data then Close</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/in-c-open-a-file-and-read-write-integer-double-string-data-then/m-p/8242022#M15552</link>
      <description>&lt;P&gt;Hi Goyals,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; I Tried the code again today.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I followed the steps in the link you sent.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It Compiles and Runs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But does not read the data from the input file and does not write the data into the output file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Input File(inflm.txt) Data is:&lt;/P&gt;&lt;P&gt;abcd1234&lt;BR /&gt;efgh5678&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The messageBox did not display the above line.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After running, nothing got written into the Output file (outflm.txt).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Thurai&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Sep 2018 16:03:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/in-c-open-a-file-and-read-write-integer-double-string-data-then/m-p/8242022#M15552</guid>
      <dc:creator>tperam</dc:creator>
      <dc:date>2018-09-03T16:03:58Z</dc:date>
    </item>
    <item>
      <title>Re: In C++  Open a File and Read Write Integer Double String  Data then Close</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/in-c-open-a-file-and-read-write-integer-double-string-data-then/m-p/8242133#M15553</link>
      <description>&lt;P&gt;I am hoping that after compiling the code, you are running the script from "Scripts and Add-ins" dialog. Rather than giving just the file name, please try to pass full path like 'D://Outflm.txt'. My guess is that script is not able to locate these text files on your machine.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Sep 2018 17:48:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/in-c-open-a-file-and-read-write-integer-double-string-data-then/m-p/8242133#M15553</guid>
      <dc:creator>goyals</dc:creator>
      <dc:date>2018-09-03T17:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: In C++  Open a File and Read Write Integer Double String  Data then Close</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/in-c-open-a-file-and-read-write-integer-double-string-data-then/m-p/8242183#M15554</link>
      <description>&lt;P&gt;Hi Goyals,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; I Added the full path as you suggested.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then it worked Okay.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Great and Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The new code is as below and I called it TestFile3.cpp&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;BR /&gt;#include &amp;lt;Core/CoreAll.h&amp;gt;&lt;BR /&gt;#include &amp;lt;Fusion/FusionAll.h&amp;gt;&lt;BR /&gt;#include &amp;lt;CAM/CAMAll.h&amp;gt;&lt;/DIV&gt;&lt;DIV&gt;using namespace adsk::core;&lt;BR /&gt;using namespace adsk::fusion;&lt;BR /&gt;using namespace adsk::cam;&lt;/DIV&gt;&lt;DIV&gt;#include &amp;lt;iostream&amp;gt;&lt;BR /&gt;#include &amp;lt;fstream&amp;gt;&lt;BR /&gt;#include &amp;lt;string&amp;gt;&lt;/DIV&gt;&lt;DIV&gt;#include &amp;lt;stdio.h&amp;gt;&lt;BR /&gt;#include &amp;lt;io.h&amp;gt;&lt;BR /&gt;#include &amp;lt;conio.h&amp;gt;&lt;BR /&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;BR /&gt;#include &amp;lt;time.h&amp;gt;&lt;BR /&gt;#include &amp;lt;conio.h&amp;gt;&lt;BR /&gt;#include &amp;lt;assert.h&amp;gt;&lt;BR /&gt;#include &amp;lt;math.h&amp;gt;&lt;BR /&gt;#include &amp;lt;memory.h&amp;gt;&lt;BR /&gt;#include &amp;lt;errno.h&amp;gt;&lt;/DIV&gt;&lt;DIV&gt;using namespace std;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Ptr&amp;lt;Application&amp;gt; app;&lt;BR /&gt;Ptr&amp;lt;UserInterface&amp;gt; ui;&lt;/DIV&gt;&lt;DIV&gt;extern "C" XI_EXPORT bool run(const char* context)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;app = Application::get();&lt;BR /&gt;&amp;nbsp;if (!app)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;return false;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;ui = app-&amp;gt;userInterface();&lt;BR /&gt;&amp;nbsp;if (!ui)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;return false;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;ui-&amp;gt;messageBox("Hello script");&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;// Read File&lt;BR /&gt;&amp;nbsp; string line;&lt;BR /&gt;&amp;nbsp; ifstream myfile ("C://Users//tpera//AppData//Roaming//Autodesk//Autodesk Fusion 360//API//Scripts//TestFile3//infile.txt");&lt;BR /&gt;&amp;nbsp; if (myfile.is_open())&lt;BR /&gt;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;ui-&amp;gt;messageBox(" Opened infile.txt");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while ( getline (myfile,line) )&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout &amp;lt;&amp;lt; line &amp;lt;&amp;lt; '\n';&lt;BR /&gt;&amp;nbsp;&amp;nbsp; line +="\n";&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp; ui-&amp;gt;messageBox(line);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;myfile.close();&lt;BR /&gt;&amp;nbsp; }&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; else&lt;BR /&gt;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; ui-&amp;gt;messageBox(" Unable to Open infile.txt");&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;// writing on a text file&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string x = "fred";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int d = 3;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; //string dStr;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; //std::string dAsString = std::to_string(d);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; char dStr[16]; // string which will contain the number&lt;BR /&gt;&amp;nbsp;&amp;nbsp; sprintf_s ( dStr, "%d", d ); // %d makes the result be a decimal integer&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; string msg;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; msg = "Test Write File";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; msg += " ";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; msg += x;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; msg += " ";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; msg += dStr;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ui-&amp;gt;messageBox(msg);&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp; ofstream myfile2 ("C://Users//tpera//AppData//Roaming//Autodesk//Autodesk Fusion 360//API//Scripts//TestFile3//outfile.txt");&lt;BR /&gt;&amp;nbsp; if (myfile2.is_open())&lt;BR /&gt;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //myfile2 &amp;lt;&amp;lt; "This is a line.\n";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //myfile2 &amp;lt;&amp;lt; "This is another line.\n";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; myfile2 &amp;lt;&amp;lt; msg;&lt;BR /&gt;&amp;nbsp;//myfile2.put('A');&lt;BR /&gt;&amp;nbsp;//myfile2.write(msg);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ui-&amp;gt;messageBox(" Opened outfile.txt");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; myfile2.close();&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; else&lt;BR /&gt;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;ui-&amp;gt;messageBox("Unable to open outfile.txt");&lt;BR /&gt;&amp;nbsp; }&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;return true;&lt;BR /&gt;}&lt;/DIV&gt;&lt;DIV&gt;#ifdef XI_WIN&lt;/DIV&gt;&lt;DIV&gt;#include &amp;lt;windows.h&amp;gt;&lt;/DIV&gt;&lt;DIV&gt;BOOL APIENTRY DllMain(HMODULE hmodule, DWORD reason, LPVOID reserved)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;switch (reason)&lt;BR /&gt;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;case DLL_PROCESS_ATTACH:&lt;BR /&gt;&amp;nbsp;case DLL_THREAD_ATTACH:&lt;BR /&gt;&amp;nbsp;case DLL_THREAD_DETACH:&lt;BR /&gt;&amp;nbsp;case DLL_PROCESS_DETACH:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;break;&lt;BR /&gt;&amp;nbsp;}&lt;BR /&gt;&amp;nbsp;return TRUE;&lt;BR /&gt;}&lt;/DIV&gt;&lt;DIV&gt;#endif // XI_WIN&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;infile.txt:&lt;/DIV&gt;&lt;DIV&gt;abcd1234&lt;BR /&gt;efgh5678&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;outfile.txt:&lt;/DIV&gt;&lt;DIV&gt;Test Write File fred 3&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Mon, 03 Sep 2018 18:21:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/in-c-open-a-file-and-read-write-integer-double-string-data-then/m-p/8242183#M15554</guid>
      <dc:creator>tperam</dc:creator>
      <dc:date>2018-09-03T18:21:02Z</dc:date>
    </item>
  </channel>
</rss>

