<?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 Betreff: Write to Notepad keeps growing every time the rule is run in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-to-notepad-keeps-growing-every-time-the-rule-is-run/m-p/9771209#M116363</link>
    <description>&lt;P&gt;Thankyou so much&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4427777"&gt;@chandra.shekar.g&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That has saved me so much time.&amp;nbsp; I was originally sending each line to an excel file but&lt;/P&gt;&lt;P&gt;it is so much faster sending it to a txt file.&amp;nbsp; I was just stuck on that duplicate name issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Much appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 27 Sep 2020 22:23:45 GMT</pubDate>
    <dc:creator>forbillian</dc:creator>
    <dc:date>2020-09-27T22:23:45Z</dc:date>
    <item>
      <title>Write to Notepad keeps growing every time the rule is run</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-to-notepad-keeps-growing-every-time-the-rule-is-run/m-p/8592073#M94348</link>
      <description>&lt;P&gt;As a part of my rule, I need to write data into a text file. I noticed that, it keeps growing instead of creating a new text file.&lt;/P&gt;
&lt;P&gt;Could someone help, please!&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;PRE&gt;Public Class forBomStructure
	Shared oTextSave As String = "C:\Users\Public\Documents\iLogicBuffer.txt"
			
	Sub Main()
'	create_txt(oWritex)
		Dim oDoc As Document = ThisApplication.ActiveDocument
		Dim oModelDoc As Document
		Dim oStr As String = ""
		Dim iL_Name as String = "0023A Full File Names of Occurrences"
			oWrite_Sub(oWrite, "FILE REFERENCE TREE RAN FROM: " &amp;amp; oDoc.FullFileName)			
			oWrite_Sub(oWrite, "RULE: " &amp;amp; iL_Name)	
			oWrite_Sub(oWrite, "-----------------------------")
'			Process.Start ("Notepad.exe", oTextSave)
'			Exit Sub
		
			For Each oModelDoc In oDoc.AllReferencedDocuments
''				RecurReferencing(oModelDoc, oStr, 0)
'				MessageBox.Show("oModelDoc.Name: " &amp;amp; oModelDoc.FullFileName, "Title")
'				oFFN_Document = oModelDoc.FullFileName
'				oWrite_Sub(oWrite, oFFN_Document)
			Next
			
		Process.Start ("Notepad.exe", oTextSave)
	
	End Sub
	
	Sub oWrite_Sub(oWrite As System.IO.StreamWriter, oStr_to_Write As String)

		oWrite = System.IO.File.AppendText(oTextSave)
		oWrite.WriteLine(oStr_to_Write)	
		oWrite.Flush()
		oWrite.Close

	If My_Expression Then
		'---------------
		End If
	End Sub
		
		
End Class
&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Feb 2019 08:38:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-to-notepad-keeps-growing-every-time-the-rule-is-run/m-p/8592073#M94348</guid>
      <dc:creator>RoyWickrama_RWEI</dc:creator>
      <dc:date>2019-02-13T08:38:53Z</dc:date>
    </item>
    <item>
      <title>Betreff: Write to Notepad keeps growing every time the rule is run</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-to-notepad-keeps-growing-every-time-the-rule-is-run/m-p/8592105#M94349</link>
      <description>&lt;P&gt;If you need everytime a new file than you can delete the old one before writing to it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Dim FileDelete As String

FileDelete = "C:\testDelete.txt"

 If System.IO.File.Exists( FileDelete ) = True Then
   System.IO.File.Delete( FileDelete )
   MsgBox("File Deleted")
End If&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Feb 2019 08:54:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-to-notepad-keeps-growing-every-time-the-rule-is-run/m-p/8592105#M94349</guid>
      <dc:creator>GeorgK</dc:creator>
      <dc:date>2019-02-13T08:54:28Z</dc:date>
    </item>
    <item>
      <title>Betreff: Write to Notepad keeps growing every time the rule is run</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-to-notepad-keeps-growing-every-time-the-rule-is-run/m-p/8592336#M94351</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/2129088"&gt;@RoyWickrama_RWEI&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/241746"&gt;@GeorgK&lt;/a&gt;&amp;nbsp; is right. If text file is already exists, delete before creating&amp;nbsp;this line&amp;nbsp;(create_txt(oWritex)).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks and regards,&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 10:56:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-to-notepad-keeps-growing-every-time-the-rule-is-run/m-p/8592336#M94351</guid>
      <dc:creator>chandra.shekar.g</dc:creator>
      <dc:date>2019-02-13T10:56:51Z</dc:date>
    </item>
    <item>
      <title>Betreff: Write to Notepad keeps growing every time the rule is run</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-to-notepad-keeps-growing-every-time-the-rule-is-run/m-p/8594853#M94405</link>
      <description>&lt;P&gt;Great help. It works.&lt;/P&gt;
&lt;P&gt;Thanks. I added the following in my code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;	&lt;SPAN&gt;Sub&lt;/SPAN&gt; &lt;SPAN&gt;oDelete_ex_Notepad&lt;/SPAN&gt;(&lt;SPAN&gt;oTextSave&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt;)   'To delete &lt;SPAN&gt;oTextSave&lt;/SPAN&gt; if existing.
		&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;FileDelete&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt;
		&lt;SPAN&gt;FileDelete&lt;/SPAN&gt; = &lt;SPAN&gt;"C:\testDelete.txt"&lt;/SPAN&gt;
	 	&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;System&lt;/SPAN&gt;.&lt;SPAN&gt;IO&lt;/SPAN&gt;.&lt;SPAN&gt;File&lt;/SPAN&gt;.&lt;SPAN&gt;Exists&lt;/SPAN&gt;(&lt;SPAN&gt;oTextSave&lt;/SPAN&gt;) = &lt;SPAN&gt;True&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt;
	   	&lt;SPAN&gt;System&lt;/SPAN&gt;.&lt;SPAN&gt;IO&lt;/SPAN&gt;.&lt;SPAN&gt;File&lt;/SPAN&gt;.&lt;SPAN&gt;Delete&lt;/SPAN&gt;(&lt;SPAN&gt;oTextSave&lt;/SPAN&gt;)
	   	&lt;SPAN&gt;MsgBox&lt;/SPAN&gt;(&lt;SPAN&gt;"File Deleted"&lt;/SPAN&gt;)
		&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;
	&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Feb 2019 05:20:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-to-notepad-keeps-growing-every-time-the-rule-is-run/m-p/8594853#M94405</guid>
      <dc:creator>RoyWickrama_RWEI</dc:creator>
      <dc:date>2019-02-14T05:20:06Z</dc:date>
    </item>
    <item>
      <title>Betreff: Write to Notepad keeps growing every time the rule is run</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-to-notepad-keeps-growing-every-time-the-rule-is-run/m-p/9763052#M116235</link>
      <description>&lt;P&gt;Hi Chandra,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a text file which gets all part names in an assembly written, however I am struggling to&lt;/P&gt;&lt;P&gt;work out how to combine both write &amp;amp; read of my text file lines and only add the next part name if it doesn't already exist in previous lines.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a basic example where I can check if the name exists - but I am unsure how to then activate the append function with it (you'll see it commented out below) so I can then add the name if its unique:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;oFile&lt;/SPAN&gt; = &lt;SPAN&gt;"C:\Temp\Names.txt"&lt;/SPAN&gt;
&lt;SPAN&gt;oRead&lt;/SPAN&gt; = &lt;SPAN&gt;System&lt;/SPAN&gt;.&lt;SPAN&gt;IO&lt;/SPAN&gt;.&lt;SPAN&gt;File&lt;/SPAN&gt;.&lt;SPAN&gt;OpenText&lt;/SPAN&gt;(&lt;SPAN&gt;oFile&lt;/SPAN&gt;)
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;sLine&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt; = &lt;SPAN&gt;""&lt;/SPAN&gt;

&lt;SPAN&gt;Do&lt;/SPAN&gt;
	&lt;SPAN&gt;sLine2&lt;/SPAN&gt; = &lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN&gt;FileName&lt;/SPAN&gt;(&lt;SPAN&gt;False&lt;/SPAN&gt;)
    &lt;SPAN&gt;sLine&lt;/SPAN&gt; = &lt;SPAN&gt;oRead&lt;/SPAN&gt;.&lt;SPAN&gt;ReadLine&lt;/SPAN&gt;()
    &lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;Not&lt;/SPAN&gt; &lt;SPAN&gt;sLine&lt;/SPAN&gt; &lt;SPAN&gt;Is&lt;/SPAN&gt; &lt;SPAN&gt;Nothing&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt;
       &lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;sLine&lt;/SPAN&gt; &amp;lt;&amp;gt; &lt;SPAN&gt;sLine2&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt;
		   
&lt;SPAN&gt;'		   oAppend = IO.File.AppendText("C:\TEMP2\Test_File.txt")&lt;/SPAN&gt;
&lt;SPAN&gt;'		   oAppend.WriteLine(ThisDoc.FileName(False))&lt;/SPAN&gt;
&lt;SPAN&gt;'           oAppend.Flush()&lt;/SPAN&gt;
&lt;SPAN&gt;'		   oAppend.Close()&lt;/SPAN&gt;

		   &lt;SPAN&gt;MsgBox&lt;/SPAN&gt;(&lt;SPAN&gt;sLine2&lt;/SPAN&gt;)
	   &lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;
    &lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;
&lt;SPAN&gt;Loop&lt;/SPAN&gt; &lt;SPAN&gt;Until&lt;/SPAN&gt; &lt;SPAN&gt;sLine&lt;/SPAN&gt; &lt;SPAN&gt;Is&lt;/SPAN&gt; &lt;SPAN&gt;Nothing&lt;/SPAN&gt;
&lt;SPAN&gt;oRead&lt;/SPAN&gt;.&lt;SPAN&gt;Close&lt;/SPAN&gt;()
&lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN&gt;Launch&lt;/SPAN&gt;(&lt;SPAN&gt;oFile&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Any help would be appreciated. Thanks&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4427777"&gt;@chandra.shekar.g&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 09:14:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-to-notepad-keeps-growing-every-time-the-rule-is-run/m-p/9763052#M116235</guid>
      <dc:creator>forbillian</dc:creator>
      <dc:date>2020-09-23T09:14:40Z</dc:date>
    </item>
    <item>
      <title>Betreff: Write to Notepad keeps growing every time the rule is run</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-to-notepad-keeps-growing-every-time-the-rule-is-run/m-p/9765494#M116285</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1693791"&gt;@forbillian&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try below iLogic code to write part name if does not exists.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Dim name As String = ThisDoc.FileName(False)
Dim Path As String = "C:\temp\Testing.txt"
Dim file As System.IO.StreamReader = New System.IO.StreamReader(path)
Dim found As Boolean = False 

For Each Line As String In System.IO.File.ReadAllLines(path) 
    If Line.Contains(name) = True Then
		found = True 
        Exit For
    End If
Next
file.Close()

If found = False Then
	oAppend = System.IO.File.AppendText(path)
	oAppend.WriteLine(ThisDoc.FileName(False))
	oAppend.Flush()
	oAppend.Close()
End If&lt;/LI-CODE&gt;
&lt;P&gt;Thanks and regards,&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 10:17:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-to-notepad-keeps-growing-every-time-the-rule-is-run/m-p/9765494#M116285</guid>
      <dc:creator>chandra.shekar.g</dc:creator>
      <dc:date>2020-09-24T10:17:54Z</dc:date>
    </item>
    <item>
      <title>Betreff: Write to Notepad keeps growing every time the rule is run</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-to-notepad-keeps-growing-every-time-the-rule-is-run/m-p/9771209#M116363</link>
      <description>&lt;P&gt;Thankyou so much&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4427777"&gt;@chandra.shekar.g&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That has saved me so much time.&amp;nbsp; I was originally sending each line to an excel file but&lt;/P&gt;&lt;P&gt;it is so much faster sending it to a txt file.&amp;nbsp; I was just stuck on that duplicate name issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Much appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Sep 2020 22:23:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-to-notepad-keeps-growing-every-time-the-rule-is-run/m-p/9771209#M116363</guid>
      <dc:creator>forbillian</dc:creator>
      <dc:date>2020-09-27T22:23:45Z</dc:date>
    </item>
    <item>
      <title>Re: Write to Notepad keeps growing every time the rule is run</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-to-notepad-keeps-growing-every-time-the-rule-is-run/m-p/9773994#M116423</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/2129088"&gt;@RoyWickrama_RWEI&lt;/a&gt;&amp;nbsp;(&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/241746"&gt;@GeorgK&lt;/a&gt;&amp;nbsp;) Instead of&lt;/P&gt;&lt;LI-CODE lang="general"&gt;System.IO.File.AppendText(oTextSave)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try&lt;/P&gt;&lt;LI-CODE lang="general"&gt;System.IO.File.CreateText(oTextSave)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;According to &lt;A title="link to microsoft help page" href="https://docs.microsoft.com/en-us/dotnet/api/system.io.file.createtext?view=netcore-3.1" target="_blank" rel="noopener"&gt;this&lt;/A&gt; microsoft API article, :&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Creates or opens a file for writing UTF-8 encoded text. If the file already exists, its contents are overwritten.&lt;/LI-CODE&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>Tue, 29 Sep 2020 09:38:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-to-notepad-keeps-growing-every-time-the-rule-is-run/m-p/9773994#M116423</guid>
      <dc:creator>_dscholtes_</dc:creator>
      <dc:date>2020-09-29T09:38:06Z</dc:date>
    </item>
  </channel>
</rss>

