<?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: inventor 2016 - 2018 issues in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2016-2018-issues/m-p/7848607#M91376</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To come back on my problem ( = not able to delete the imported assembly in an assembly)&amp;nbsp;&lt;/P&gt;&lt;P&gt;The assembly that I want to import is triggered "After Open Document" by the rule "AutoMakeAllFreeAndPromote"&lt;/P&gt;&lt;P&gt;When I adapt the first script "AutomakeAllFreeAndPromote" by adding a messagebox after editoOcc. and deleting the last commando "MakeAllFreeAndPromote", then I am inside the subassembly after importing this assembly. When I then call the commando manually "MakeAllFreeAndPromote" IT WORKS!!!&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I run this commando automatically during my first script (see step 3) - it doesn't work! Then I'm able to promote the parts to my top level, but not able to delete the empty subassembly.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I also tried to insert the commando at the last line :&amp;nbsp;&lt;SPAN&gt; "oSubAssyOcc.Delete" - but then I get an error.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;it seems that I'm not able to select this empty subassembly and delete it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;Who can help me to delete this?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 13 Mar 2018 09:12:25 GMT</pubDate>
    <dc:creator>m.maertens6DTZT</dc:creator>
    <dc:date>2018-03-13T09:12:25Z</dc:date>
    <item>
      <title>inventor 2016 - 2018 issues</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2016-2018-issues/m-p/7841285#M91373</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I'm here again with an issue during updating my inventor to 2018&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We're using a module in the VBA that allows us to automaticly 'makeAllFreeAndPromote" an assembly when you drag and drop this.&lt;/P&gt;&lt;P&gt;In 2016 this works perfect, in 2018 not.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Let me explain what I want to do:&lt;/P&gt;&lt;P&gt;1. drag and drop an assembly from our library in my project (on toplevel)&lt;/P&gt;&lt;P&gt;2. explode this imported assembly into the separate parts and delete the imported assembly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In 2018 this happens:&lt;/P&gt;&lt;P&gt;1. Drag and drop the assembly works fine&lt;/P&gt;&lt;P&gt;2. explode the assembly into separate parts works fine&lt;/P&gt;&lt;P&gt;3. Delete the imported assembly doesn't works anymore.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me out how I can fix this.&lt;/P&gt;&lt;P&gt;Because, when I save my project - it also saves the empty assembly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See screenshot below.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="assembly issue.jpg" style="width: 229px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/473188i6CF6EBB74D7F3AD8/image-size/large?v=v2&amp;amp;px=999" role="button" title="assembly issue.jpg" alt="assembly issue.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here is the code:&lt;BR /&gt;Module 1 = auto make all free and promote&lt;/P&gt;&lt;PRE&gt;Sub AutoMakeAllFreePromote()
'step 1 Check if the correct Workspace is set
    Call GetFileLocation
    Dim oWorkspace As String
    oWorkspace = ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath
    If oWorkspace &amp;lt;&amp;gt; sDefaultRootProject Then
            Debug.Print "Rule AutoMakeAllFreePromote has been cancelled because non-default workspace has been chosen"
            Debug.Print "This is normal if you are editing beCAD"
            Exit Sub
    End If
   
'step 2 Determine the level we are one
    Dim oMainAssembly As AssemblyDocument
    Set oMainAssembly = ThisApplication.ActiveDocument

    Dim oAssembly As AssemblyDocument
    Set oAssembly = ThisApplication.ActiveEditDocument

    Dim oOcc As ComponentOccurrence
          
'step 3 select the part that has been placed &amp;amp; edit it
    If oMainAssembly.FullDocumentName = oAssembly.FullDocumentName Then
    'we are on the main assembly
        Set oOcc = oAssembly.ComponentDefinition.Occurrences.Item(oAssembly.ComponentDefinition.Occurrences.Count)
    Else
    'we are in a subassembly
        MsgBox "Move this assembly to the Main assembly &amp;amp; press 'MakeAllFreeAndPromote'. Next time place directly at top level", vbOKOnly, "Error"
        Exit Sub
        'the below doesn't work properly, to be investigated
        'Set oOcc = oMainAssembly.ComponentDefinition.Occurrences.ItemByName(oMainAssembly.ComponentDefinition.ActiveOccurrence.Name).SubOccurrences.Item(oAssembly.ComponentDefinition.Occurrences.Count)
    End If
       
    
    oOcc.Edit
    
'step 3 Call MakeAllFreeAndPromote
    MakeAlleFreeAndPromote
   
    
End Sub&lt;/PRE&gt;&lt;P&gt;Module 2 = make all free and promote&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Public Sub MakeAlleFreeAndPromote()

' Create a transaction. -&amp;gt; for 1 undo command
Dim oTransMgr As TransactionManager
Set oTransMgr = ThisApplication.TransactionManager
Dim oTrans As Transaction
Set oTrans = oTransMgr.StartTransaction(ThisApplication.ActiveDocument, "MakeAlleFreeAndPromote")
  

' check if an iwall is selected
        Dim oDoc As AssemblyDocument
        Set oDoc = ThisApplication.ActiveDocument

        Dim oOcc As ComponentOccurrence
        On Error Resume Next
        Set oOcc = oDoc.SelectSet.Item(1)
        If Err Then
            GoTo TraverseNormally
        End If
        
        If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then
            If oOcc.ActiveLevelOfDetailRepresentation = "Wall" Then
               oOcc.Edit
            End If
        End If

'declare everything needed
TraverseNormally:
        Dim oDef As AssemblyComponentDefinition
        Set oDef = oDoc.ComponentDefinition
        
        Dim oAssDoc As AssemblyDocument
        Set oAssDoc = ThisApplication.ActiveEditObject
        Dim oActDef As AssemblyComponentDefinition
        Set oActDef = oAssDoc.ComponentDefinition
        
        Dim oPattern As OccurrencePattern
        Dim oPatternElement As OccurrencePatternElement
        Dim oOccurence As ComponentOccurrence
        Dim oComponent As ComponentOccurrence





        'Traverse all the patterns in the assembly:
        For Each oPattern In oAssDoc.ComponentDefinition.OccurrencePatterns
            'Traverse all elements in the pattern to make them independent:
            For Each oPatternElement In oPattern.OccurrencePatternElements
              '  On Error Resume Next
                oPatternElement.Independent = True
                If Err Then
                    Err.Clear
                    End If
            Next oPatternElement
        Next oPattern
        
        'Delete all patterns in the assembly
        For Each oPattern In oAssDoc.ComponentDefinition.OccurrencePatterns
            oPattern.Delete
        Next oPattern
        
        'delete all suppressed
        For Each oComponent In oAssDoc.ComponentDefinition.Occurrences
                If oComponent.Suppressed = True Then
                    oComponent.Delete
                End If
        Next oComponent
        
        'Unground all components
        For Each oOccurence In oAssDoc.ComponentDefinition.Occurrences
            If oOccurence.Grounded = True Then
                oOccurence.Grounded = False
            End If
        Next oOccurence
        
        'Delete all iComposites
        For Each oIcomp In oAssDoc.ComponentDefinition.iMateResults
         '   On Error Resume Next
            oIcomp.Delete
            If Err Then
            Err.Clear
            End If
        Next oIcomp
        
        'Delete all imates
        For Each oImate In oAssDoc.ComponentDefinition.iMateDefinitions
          '  On Error Resume Next
            oImate.Delete
            If Err Then
            Err.Clear
            End If
        Next oImate
        
        'Delete all constraints
        For Each oConstraint In oAssDoc.ComponentDefinition.Constraints
           ' On Error Resume Next
            oConstraint.Delete
            If Err Then
            Err.Clear
            End If
        Next oConstraint
            
        'Promote all frames

            ' Get the top level occurrence of an assembly
             Dim oSubAssyOcc As ComponentOccurrence
             
             
            ' On Error Resume Next
                     Set oSubAssyOcc = oDef.Occurrences.ItemByName(oDef.ActiveOccurrence.Name)
                      'If Err Then
                       '   MsgBox "A subassembly must be active if you want to promote it. No Subassembly will be touched"
                           
                   ' Else
                        Dim i As Integer
                        For i = 1 To oActDef.Occurrences.Count
                           
                        ' Get the 2nd level occurrence under the assembly occurrence
                        Dim oSubOcc As ComponentOccurrenceProxy
                        Set oSubOcc = oSubAssyOcc.SubOccurrences.Item(1)
                        
                        Dim oPane As BrowserPane
                        Set oPane = oDoc.BrowserPanes.Item("AmBrowserArrangement") '2017 11 05 - multilangue change
                        
                        ' Get the browser nodes corresponding to the two occurrences
                        Dim oTargetNode As BrowserNode
                        Set oTargetNode = oPane.GetBrowserNodeFromObject(oSubAssyOcc)
                        
                        
                        Dim oSourceNode As BrowserNode
                        Set oSourceNode = oPane.GetBrowserNodeFromObject(oSubOcc)
                        
                        
                        ' Reorder the nodes to promote the sub-occurrence to the top level
                        Call oPane.Reorder(oTargetNode, True, oSourceNode)
                        
                        Next
                        
                        ' activate one level up
                             Dim oCtrlDef As ControlDefinition
                            Set oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item("AppReturnTopCmd")
                            oCtrlDef.Execute
                                
                        ' Delete the original Subassembly
                            oSubAssyOcc.Delete
                            oSubAssyOcc.Delete
                      'End If
             On Error GoTo 0

    
' End the transaction.
    oTrans.End
End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 14:48:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2016-2018-issues/m-p/7841285#M91373</guid>
      <dc:creator>m.maertens6DTZT</dc:creator>
      <dc:date>2018-03-09T14:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: inventor 2016 - 2018 issues</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2016-2018-issues/m-p/7848257#M91374</link>
      <description>&lt;P&gt;Hello &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5625653"&gt;@m.maertens6DTZT&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please provide Assembly with imported assembly to reproduce ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please make sure that files are non confidential.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks and regards,&lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2018 06:41:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2016-2018-issues/m-p/7848257#M91374</guid>
      <dc:creator>chandra.shekar.g</dc:creator>
      <dc:date>2018-03-13T06:41:03Z</dc:date>
    </item>
    <item>
      <title>Re: inventor 2016 - 2018 issues</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2016-2018-issues/m-p/7848284#M91375</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See enclosed the requested files.&lt;/P&gt;&lt;P&gt;Thanks for your help.&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>Tue, 13 Mar 2018 06:57:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2016-2018-issues/m-p/7848284#M91375</guid>
      <dc:creator>m.maertens6DTZT</dc:creator>
      <dc:date>2018-03-13T06:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: inventor 2016 - 2018 issues</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2016-2018-issues/m-p/7848607#M91376</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To come back on my problem ( = not able to delete the imported assembly in an assembly)&amp;nbsp;&lt;/P&gt;&lt;P&gt;The assembly that I want to import is triggered "After Open Document" by the rule "AutoMakeAllFreeAndPromote"&lt;/P&gt;&lt;P&gt;When I adapt the first script "AutomakeAllFreeAndPromote" by adding a messagebox after editoOcc. and deleting the last commando "MakeAllFreeAndPromote", then I am inside the subassembly after importing this assembly. When I then call the commando manually "MakeAllFreeAndPromote" IT WORKS!!!&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I run this commando automatically during my first script (see step 3) - it doesn't work! Then I'm able to promote the parts to my top level, but not able to delete the empty subassembly.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I also tried to insert the commando at the last line :&amp;nbsp;&lt;SPAN&gt; "oSubAssyOcc.Delete" - but then I get an error.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;it seems that I'm not able to select this empty subassembly and delete it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;Who can help me to delete this?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2018 09:12:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2016-2018-issues/m-p/7848607#M91376</guid>
      <dc:creator>m.maertens6DTZT</dc:creator>
      <dc:date>2018-03-13T09:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: inventor 2016 - 2018 issues</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2016-2018-issues/m-p/7848693#M91377</link>
      <description>&lt;P&gt;Hello &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5625653"&gt;@m.maertens6DTZT&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After promoting, try the following VBA code to delete referenced components.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Sub DeleteDerivedAssembly()
    Dim oDoc As AssemblyDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oDef As AssemblyComponentDefinition
    Set oDef = oDoc.ComponentDefinition
    
    Dim occ As ComponentOccurrence
    For Each occ In oDef.Occurrences
        If occ.DefinitionDocumentType = kPartDocumentObject Then
            Dim oPartDef As PartComponentDefinition
            Set oPartDef = occ.Definition
            
            Dim oDerivedAssembly As DerivedAssemblyComponent
            For Each oDerivedAssembly In oPartDef.ReferenceComponents.DerivedAssemblyComponents
                Call oDerivedAssembly.Delete
            Next
        End If
        
    Next
End Sub&lt;/PRE&gt;
&lt;P&gt;Please feel free to contact if there is any queries.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If solves problem, click on "Accept as solution" / give a "Kudo".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks and regards,&lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2018 09:49:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2016-2018-issues/m-p/7848693#M91377</guid>
      <dc:creator>chandra.shekar.g</dc:creator>
      <dc:date>2018-03-13T09:49:19Z</dc:date>
    </item>
    <item>
      <title>Re: inventor 2016 - 2018 issues</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2016-2018-issues/m-p/7848778#M91378</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the code, but when I place that after promoting, then I notice that my parts are modified. This code does something with my parts.&lt;BR /&gt;No, what I actually want to do is&lt;BR /&gt;1. Import an assembly from my &lt;U&gt;library&lt;/U&gt;. (for example a bolt-nut connection)&lt;BR /&gt;2. After importing, the assembly must explode so I have the parts separately on top level (must be separately for my BOM)&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. Delete the imported subassembly because it's empty&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want, I can also make a movie to show you my actions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just don't understand why this worked perfectly in 2016 and not in 2018.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2018 10:21:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2016-2018-issues/m-p/7848778#M91378</guid>
      <dc:creator>m.maertens6DTZT</dc:creator>
      <dc:date>2018-03-13T10:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: inventor 2016 - 2018 issues</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2016-2018-issues/m-p/7848789#M91379</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5625653"&gt;@m.maertens6DTZT&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Video is better to demonstrate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks and regards,&lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2018 10:24:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2016-2018-issues/m-p/7848789#M91379</guid>
      <dc:creator>chandra.shekar.g</dc:creator>
      <dc:date>2018-03-13T10:24:48Z</dc:date>
    </item>
    <item>
      <title>Re: inventor 2016 - 2018 issues</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2016-2018-issues/m-p/7848992#M91380</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've made 3 video's:&lt;/P&gt;&lt;P&gt;1. Demonstration how this works in 2016&lt;/P&gt;&lt;P&gt;2. Demonstration how this behave in 2018 with the same code.&lt;/P&gt;&lt;P&gt;3. Demo when I disable the 2nd script 'MakeAllFreeAndPromote' but do this manually. See picture below how I disable this.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="disable makeallfree.jpg" style="width: 263px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/474534i2068F7F547608106/image-dimensions/263x92?v=v2" width="263" height="92" role="button" title="disable makeallfree.jpg" alt="disable makeallfree.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;SO there is a difference of doing this automatically or manually. (And it's the same code)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply&lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2018 11:36:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2016-2018-issues/m-p/7848992#M91380</guid>
      <dc:creator>m.maertens6DTZT</dc:creator>
      <dc:date>2018-03-13T11:36:22Z</dc:date>
    </item>
    <item>
      <title>Re: inventor 2016 - 2018 issues</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2016-2018-issues/m-p/7851610#M91381</link>
      <description>&lt;P&gt;Hello &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5625653"&gt;@m.maertens6DTZT&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for videos,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead of using command "AppReturnTopCmd", Call oSubAssyOcc.ExitEdit(kExitToParent) Inventor API is used to return back to parent level. Same changes are implemented in the below code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Public Sub MakeAlleFreeAndPromote()

' Create a transaction. -&amp;gt; for 1 undo command
Dim oTransMgr As TransactionManager
Set oTransMgr = ThisApplication.TransactionManager
Dim oTrans As Transaction
Set oTrans = oTransMgr.StartTransaction(ThisApplication.ActiveDocument, "MakeAlleFreeAndPromote")
  

' check if an iwall is selected
        Dim oDoc As AssemblyDocument
        Set oDoc = ThisApplication.ActiveDocument

        Dim oOcc As ComponentOccurrence
        On Error Resume Next
        Set oOcc = oDoc.SelectSet.Item(1)
        If Err Then
            GoTo TraverseNormally
        End If
        
        If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then
            If oOcc.ActiveLevelOfDetailRepresentation = "Wall" Then
               oOcc.Edit
            End If
        End If

'declare everything needed
TraverseNormally:
        Dim oDef As AssemblyComponentDefinition
        Set oDef = oDoc.ComponentDefinition
        
        Dim oAssDoc As AssemblyDocument
        Set oAssDoc = ThisApplication.ActiveEditObject
        Dim oActDef As AssemblyComponentDefinition
        Set oActDef = oAssDoc.ComponentDefinition
        
        Dim oPattern As OccurrencePattern
        Dim oPatternElement As OccurrencePatternElement
        Dim oOccurence As ComponentOccurrence
        Dim oComponent As ComponentOccurrence





        'Traverse all the patterns in the assembly:
        For Each oPattern In oAssDoc.ComponentDefinition.OccurrencePatterns
            'Traverse all elements in the pattern to make them independent:
            For Each oPatternElement In oPattern.OccurrencePatternElements
              '  On Error Resume Next
                oPatternElement.Independent = True
                If Err Then
                    Err.Clear
                    End If
            Next oPatternElement
        Next oPattern
        
        'Delete all patterns in the assembly
        For Each oPattern In oAssDoc.ComponentDefinition.OccurrencePatterns
            oPattern.Delete
        Next oPattern
        
        'delete all suppressed
        For Each oComponent In oAssDoc.ComponentDefinition.Occurrences
                If oComponent.Suppressed = True Then
                    oComponent.Delete
                End If
        Next oComponent
        
        'Unground all components
        For Each oOccurence In oAssDoc.ComponentDefinition.Occurrences
            If oOccurence.Grounded = True Then
                oOccurence.Grounded = False
            End If
        Next oOccurence
        
        'Delete all iComposites
        For Each oIcomp In oAssDoc.ComponentDefinition.iMateResults
         '   On Error Resume Next
            oIcomp.Delete
            If Err Then
            Err.Clear
            End If
        Next oIcomp
        
        'Delete all imates
        For Each oImate In oAssDoc.ComponentDefinition.iMateDefinitions
          '  On Error Resume Next
            oImate.Delete
            If Err Then
            Err.Clear
            End If
        Next oImate
        
        'Delete all constraints
        For Each oConstraint In oAssDoc.ComponentDefinition.Constraints
           ' On Error Resume Next
            oConstraint.Delete
            If Err Then
            Err.Clear
            End If
        Next oConstraint
            
        'Promote all frames

            ' Get the top level occurrence of an assembly
             Dim oSubAssyOcc As ComponentOccurrence
             
             
            ' On Error Resume Next
                     Set oSubAssyOcc = oDef.Occurrences.ItemByName(oDef.ActiveOccurrence.Name)
                      'If Err Then
                       '   MsgBox "A subassembly must be active if you want to promote it. No Subassembly will be touched"
                           
                   ' Else
                        Dim i As Integer
                        For i = 1 To oActDef.Occurrences.Count
                           
                        ' Get the 2nd level occurrence under the assembly occurrence
                        Dim oSubOcc As ComponentOccurrenceProxy
                        Set oSubOcc = oSubAssyOcc.SubOccurrences.Item(1)
                        
                        Dim oPane As BrowserPane
                        Set oPane = oDoc.BrowserPanes.Item("AmBrowserArrangement") '2017 11 05 - multilangue change
                        
                        ' Get the browser nodes corresponding to the two occurrences
                        Dim oTargetNode As BrowserNode
                        Set oTargetNode = oPane.GetBrowserNodeFromObject(oSubAssyOcc)
                        
                        
                        Dim oSourceNode As BrowserNode
                        Set oSourceNode = oPane.GetBrowserNodeFromObject(oSubOcc)
                        
                        
                        ' Reorder the nodes to promote the sub-occurrence to the top level
                        Call oPane.Reorder(oTargetNode, True, oSourceNode)
                        
                        Next
                        &lt;FONT color="#ff0000"&gt;Call oSubAssyOcc.ExitEdit(kExitToParent)&lt;/FONT&gt;
                        ' activate one level up
                             &lt;FONT color="#008000"&gt;'Dim oCtrlDef As ControlDefinition
                             'Set oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item("AppReturnTopCmd")
                             'oCtrlDef.Execute
&lt;/FONT&gt;                                
                        ' Delete the original Subassembly
                            oSubAssyOcc.Delete
                            oSubAssyOcc.Delete
                      'End If
             On Error GoTo 0

    
' End the transaction.
    oTrans.End
End Sub&lt;/PRE&gt;
&lt;P&gt;Please feel free to contact if there is any queries.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If solves problem, click on "Accept as solution" / give a "Kudo".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks and regards,&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 05:30:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2016-2018-issues/m-p/7851610#M91381</guid>
      <dc:creator>chandra.shekar.g</dc:creator>
      <dc:date>2018-03-14T05:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: inventor 2016 - 2018 issues</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2016-2018-issues/m-p/7851739#M91382</link>
      <description>&lt;P&gt;Hello &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;&lt;DIV class="username_area"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Wow,&lt;/P&gt;&lt;P&gt;This really works again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I can finalize the upgrade to inventor 2018.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Maarten&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 07:11:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2016-2018-issues/m-p/7851739#M91382</guid>
      <dc:creator>m.maertens6DTZT</dc:creator>
      <dc:date>2018-03-14T07:11:06Z</dc:date>
    </item>
    <item>
      <title>Re: inventor 2016 - 2018 issues</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2016-2018-issues/m-p/7851750#M91383</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5625653"&gt;@m.maertens6DTZT&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's great news!!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My solution leads to finalize the upgrade to Inventor 2018.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks and regards,&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 07:15:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2016-2018-issues/m-p/7851750#M91383</guid>
      <dc:creator>chandra.shekar.g</dc:creator>
      <dc:date>2018-03-14T07:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: inventor 2016 - 2018 issues</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2016-2018-issues/m-p/10322746#M91384</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm here again.&lt;BR /&gt;Inventor 2022 crashes when I drag and drop a subassembly that includes the rule of "autoMakeAllFreeAndPromote".&lt;BR /&gt;Again, when I disable&amp;nbsp; in the rule the line "Call MakeAllFreeAndPromote" - but I do it manually, it works fine.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 May 2021 06:48:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2016-2018-issues/m-p/10322746#M91384</guid>
      <dc:creator>m.maertens6DTZT</dc:creator>
      <dc:date>2021-05-19T06:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: inventor 2016 - 2018 issues</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2016-2018-issues/m-p/10328279#M91385</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5625653"&gt;@m.maertens6DTZT&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please provide non confidential video demonstrate the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks and regards,&lt;/P&gt;</description>
      <pubDate>Fri, 21 May 2021 03:59:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2016-2018-issues/m-p/10328279#M91385</guid>
      <dc:creator>chandra.shekar.g</dc:creator>
      <dc:date>2021-05-21T03:59:17Z</dc:date>
    </item>
  </channel>
</rss>

