<?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: Code suddenly not working anymore in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/code-suddenly-not-working-anymore/m-p/8621793#M78405</link>
    <description>&lt;P&gt;Tip:&lt;/P&gt;
&lt;P&gt;Put a few Messageboxes to take a look till where the code runs.&lt;/P&gt;
&lt;P&gt;Please let me know at what line the code crashes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;</description>
    <pubDate>Tue, 26 Feb 2019 12:51:24 GMT</pubDate>
    <dc:creator>bradeneuropeArthur</dc:creator>
    <dc:date>2019-02-26T12:51:24Z</dc:date>
    <item>
      <title>Code suddenly not working anymore</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/code-suddenly-not-working-anymore/m-p/8621629#M78402</link>
      <description>&lt;P&gt;trying to solve&lt;/P&gt;</description>
      <pubDate>Tue, 26 Feb 2019 11:37:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/code-suddenly-not-working-anymore/m-p/8621629#M78402</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-02-26T11:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: Code suddenly not working anymore</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/code-suddenly-not-working-anymore/m-p/8621729#M78403</link>
      <description>&lt;P&gt;Well, It might be coincidence, but I renewed our Autodesk licenses this morning, and I had to change my Product Collection into a Design Suite that we still had. But I only need Inventor, so...&lt;/P&gt;
&lt;P&gt;A few months back&amp;nbsp;@Anonymous&amp;nbsp;had this code snippet for me, which worked beautifully, but now I get these errors:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyone could have a look what might be the problem? I use this rule daily, so it is kind of important to me.&amp;nbsp;&amp;nbsp;Many Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="error1.JPG" style="width: 563px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/607555iA366621E48F861B2/image-size/large?v=v2&amp;amp;px=999" role="button" title="error1.JPG" alt="error1.JPG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="error2.JPG" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/607556i11731D689749AF17/image-size/large?v=v2&amp;amp;px=999" role="button" title="error2.JPG" alt="error2.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Imports System.IO
GetInput :

Six_Digit = InputBox("Enter 6 Digit number", "iLogic", 000000)

If Six_Digit = "" Then
	Return
Else If Len(Six_Digit) &amp;lt;&amp;gt; "6" Then
MessageBox.Show("Input must be 6 digits", "ilogic")
GoTo GetInput

End If


Dim oDoc As Document
Dim sFilename As String

'hard code path
oLibrary_Folder = "U:\Johan\PTN_Part_Library\"


Dim oFilenames() As String
oFilenames = System.IO.Directory.GetFiles(oLibrary_Folder, _
"*.*", SearchOption.AllDirectories)

For Each oFilename As String In oFilenames
	If oFilename.Contains(Six_Digit) Then
		Dim oOptions As Inventor.NameValueMap
		oOptions = ThisApplication.TransientObjects.CreateNameValueMap
		oDoc = ThisApplication.Documents.OpenWithOptions(oFilename, oOptions, False)
		sFilename = oFilename
		Exit For
	End If
Next

If sFilename = "" Then
	MessageBox.Show("No matching libary file found.", "iLogic")
	Return
End If

iCounter = 0

'path from current file
oActiveAssemblyfolder = ThisDoc.Path &amp;amp; "\"

'path from current project file ( *.ipj)
oProjectfolder = _
ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath &amp;amp; "\"

Dim oProject_Filenames() As String
oProject_Filenames = System.IO.Directory.GetFiles(oProjectfolder, _
"*.*", SearchOption.AllDirectories)

'count existing project files					  
For Each oFilename As String In oProject_Filenames
	If oFilename.Contains(Six_Digit) Then
		iCounter = iCounter + 1
	End If
Next

'increment counter
iCounter = iCounter + 1


'find the postion of the last backslash in the path
FNamePos = InStrRev(sFilename, "\", - 1)
'get the file name with the file extension
oName = Right(sFilename, Len(sFilename) - FNamePos)
'get the file name (without extension)
ShortName = Left(oName, Len(oName) - 4)
'get extension
oExt = Right(oName, 4)


If iCounter &amp;lt; 10 Then
	iCounter = "00" + CStr(iCounter)
ElseIf iCounter &amp;lt; 100 Then
	iCounter = "0" + CStr(iCounter)
Else
	iCounter = CStr(iCounter)
End If

oNewName = ShortName &amp;amp; "_" &amp;amp; iCounter

oPathandName = oActiveAssemblyfolder &amp;amp; oNewName &amp;amp; oExt

'save new document
oDoc.SaveAs(oPathandName, True)
oDoc.Close

'[ Place Component
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

' Create Matrix
Dim oMatrix As Matrix
oMatrix = ThisApplication.TransientGeometry.CreateMatrix
Call oMatrix.SetTranslation(ThisApplication.TransientGeometry.CreateVector(50, 50, 50), True)


'insert new occurence
Dim oOcc As ComponentOccurrence
oOcc = oAsmCompDef.Occurrences.Add( _
oPathandName, oMatrix)

oOcc.Grounded = False
ThisDoc.Document.SelectSet.Select(oOcc)

']

'MessageBox.Show("New file created: " &amp;amp; vbLf &amp;amp; oPathandName, "iLogic")

&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Feb 2019 12:21:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/code-suddenly-not-working-anymore/m-p/8621729#M78403</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-02-26T12:21:55Z</dc:date>
    </item>
    <item>
      <title>Re: Code suddenly not working anymore</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/code-suddenly-not-working-anymore/m-p/8621786#M78404</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the harcode path may be a problem&lt;/P&gt;
&lt;P&gt;use the server name or IP address instea like "Serverxyz" or 10.0.0.x&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;</description>
      <pubDate>Tue, 26 Feb 2019 12:47:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/code-suddenly-not-working-anymore/m-p/8621786#M78404</guid>
      <dc:creator>bradeneuropeArthur</dc:creator>
      <dc:date>2019-02-26T12:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: Code suddenly not working anymore</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/code-suddenly-not-working-anymore/m-p/8621793#M78405</link>
      <description>&lt;P&gt;Tip:&lt;/P&gt;
&lt;P&gt;Put a few Messageboxes to take a look till where the code runs.&lt;/P&gt;
&lt;P&gt;Please let me know at what line the code crashes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;</description>
      <pubDate>Tue, 26 Feb 2019 12:51:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/code-suddenly-not-working-anymore/m-p/8621793#M78405</guid>
      <dc:creator>bradeneuropeArthur</dc:creator>
      <dc:date>2019-02-26T12:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: Code suddenly not working anymore</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/code-suddenly-not-working-anymore/m-p/8621821#M78406</link>
      <description>&lt;P&gt;Well it is very wierd. After a rebuild all, it seems to work again... will try the messages boxes next time the issue pops up. Many Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 26 Feb 2019 13:05:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/code-suddenly-not-working-anymore/m-p/8621821#M78406</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-02-26T13:05:04Z</dc:date>
    </item>
    <item>
      <title>Re: Code suddenly not working anymore</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/code-suddenly-not-working-anymore/m-p/8621943#M78407</link>
      <description>&lt;P&gt;Good to hear that is working again.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Feb 2019 13:49:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/code-suddenly-not-working-anymore/m-p/8621943#M78407</guid>
      <dc:creator>bradeneuropeArthur</dc:creator>
      <dc:date>2019-02-26T13:49:34Z</dc:date>
    </item>
  </channel>
</rss>

