<?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: VB.net error on ported VBA code in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/vb-net-error-on-ported-vba-code/m-p/6484118#M65913</link>
    <description>Well this was an easy fix after a bit more searching.&lt;BR /&gt;&lt;BR /&gt;Just replace the loop at the end with the following code, which I found in a thread of mine asking for help while creating this script.&lt;BR /&gt;&lt;BR /&gt;oPart.Replace(NewFilePath, True)</description>
    <pubDate>Mon, 08 Aug 2016 14:25:29 GMT</pubDate>
    <dc:creator>pball</dc:creator>
    <dc:date>2016-08-08T14:25:29Z</dc:date>
    <item>
      <title>VB.net error on ported VBA code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/vb-net-error-on-ported-vba-code/m-p/6480745#M65886</link>
      <description>&lt;P&gt;I have a VBA script that would save and replace all occurrences of a selected component. I've since ported that to my VB.net addin and now I'm having issues. When I use the script from my VB.net addin I get an illegal error when the script replaces parts with ilogic triggers in them. The exact same VBA does not cause this error. The error does not cause the operation to fail but it causes extra clicks and would probably scare the average person.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a different way to find and replace that might not cause this or a way to prevent ilogic triggers from running when replacing components.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error Message:&lt;/P&gt;&lt;P&gt;"&lt;SPAN&gt;Illegal&lt;/SPAN&gt; attempt to create identified &lt;SPAN&gt;child&lt;/SPAN&gt; &lt;SPAN&gt;transaction&lt;/SPAN&gt; inside an unidentified &lt;SPAN&gt;transaction&lt;/SPAN&gt;"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Imports Inventor

Module Save_Replace_All
    Public Sub SaveReplaceAll()
        'Checks if open document is assembly
        If (ThisApplication.ActiveDocument.DocumentType &amp;lt;&amp;gt; DocumentTypeEnum.kAssemblyDocumentObject) Then
            MsgBox("This is NOT an assembly document!", vbExclamation)
            Exit Sub
        End If

        Dim oPart As ComponentOccurrence
        Dim oPartDoc As Document
        Dim NewFilePath As String

        oPart = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select the part to save and replace all.")
        If (oPart Is Nothing) Then Exit Sub
        oPartDoc = oPart.Definition.Document

        Dim oFileDlg As Inventor.FileDialog = Nothing
        Call ThisApplication.CreateFileDialog(oFileDlg)

        'check file type and set dialog filter
        If oPartDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
            oFileDlg.Filter = "Autodesk Inventor Part Files (*.ipt)|*.ipt"
        ElseIf oPartDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
            oFileDlg.Filter = "Autodesk Inventor Assembly Files (*.iam)|*.iam"
        End If

        oFileDlg.InitialDirectory = ThisApplication.FileLocations.Workspace
        oFileDlg.FileName = Filename(oPartDoc.FullFileName)
        oFileDlg.CancelError = True

        Call oFileDlg.ShowSave()

        If oFileDlg.FileName &amp;lt;&amp;gt; "" Then
            NewFilePath = oFileDlg.FileName
        Else
            Exit Sub
        End If

        ThisApplication.SilentOperation = True
        Call oPartDoc.SaveAs(NewFilePath, True)
        ThisApplication.SilentOperation = False
&lt;BR /&gt;'ERROR OCCURS BELOW
        Dim fd As DocumentDescriptor
        For Each fd In ThisApplication.ActiveEditDocument.ReferencedDocumentDescriptors
            If (fd.FullDocumentName = oPartDoc.FullFileName) Then
                fd.ReferencedFileDescriptor.ReplaceReference(NewFilePath)
            End If
        Next

        'Update browser names
        'UBN()

    End Sub
End Module&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2016 15:34:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/vb-net-error-on-ported-vba-code/m-p/6480745#M65886</guid>
      <dc:creator>pball</dc:creator>
      <dc:date>2016-08-05T15:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: VB.net error on ported VBA code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/vb-net-error-on-ported-vba-code/m-p/6481322#M65889</link>
      <description>take a look at this&lt;BR /&gt;&lt;A href="http://forums.autodesk.com/t5/inventor-customization/thisapplication-in-vb-net/m-p/3778198#M42278" target="_blank"&gt;http://forums.autodesk.com/t5/inventor-customization/thisapplication-in-vb-net/m-p/3778198#M42278&lt;/A&gt;</description>
      <pubDate>Fri, 05 Aug 2016 19:45:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/vb-net-error-on-ported-vba-code/m-p/6481322#M65889</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-08-05T19:45:27Z</dc:date>
    </item>
    <item>
      <title>Re: VB.net error on ported VBA code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/vb-net-error-on-ported-vba-code/m-p/6483766#M65909</link>
      <description>I'm using ThisApplication all over my addin so I don't see how that is the issue.</description>
      <pubDate>Mon, 08 Aug 2016 12:28:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/vb-net-error-on-ported-vba-code/m-p/6483766#M65909</guid>
      <dc:creator>pball</dc:creator>
      <dc:date>2016-08-08T12:28:22Z</dc:date>
    </item>
    <item>
      <title>Re: VB.net error on ported VBA code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/vb-net-error-on-ported-vba-code/m-p/6484118#M65913</link>
      <description>Well this was an easy fix after a bit more searching.&lt;BR /&gt;&lt;BR /&gt;Just replace the loop at the end with the following code, which I found in a thread of mine asking for help while creating this script.&lt;BR /&gt;&lt;BR /&gt;oPart.Replace(NewFilePath, True)</description>
      <pubDate>Mon, 08 Aug 2016 14:25:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/vb-net-error-on-ported-vba-code/m-p/6484118#M65913</guid>
      <dc:creator>pball</dc:creator>
      <dc:date>2016-08-08T14:25:29Z</dc:date>
    </item>
  </channel>
</rss>

