<?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: Editing component in sub assembly  error with VBA in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/editing-component-in-sub-assembly-error-with-vba/m-p/8620849#M94922</link>
    <description>&lt;P&gt;Hi&amp;nbsp;JaneFan,&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;That is exactly what I'm expecting! &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you. I appreciate your help.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Feb 2019 02:42:23 GMT</pubDate>
    <dc:creator>Olsndot</dc:creator>
    <dc:date>2019-02-26T02:42:23Z</dc:date>
    <item>
      <title>Editing component in sub assembly  error with VBA</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/editing-component-in-sub-assembly-error-with-vba/m-p/8613474#M94768</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have trouble with elementary code in VBA.&lt;BR /&gt;That code is to edit component as shown in the below.&lt;BR /&gt;It works in top assembly,but doesn't work in editing sub assembly from within top assembly.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What exactly needs changed to allow this to work?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Sub EDIT_COMPONENT()

Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveEditDocument

Dim oAsmCompDef As ComponentDefinition
Set oAsmCompDef = oAsmDoc.ComponentDefinition

Dim oOcc As ComponentOccurrence
Set oOcc = oAsmCompDef.Occurrences.Item(1)
oOcc.EDIT
End Sub&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 07:10:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/editing-component-in-sub-assembly-error-with-vba/m-p/8613474#M94768</guid>
      <dc:creator>Olsndot</dc:creator>
      <dc:date>2019-02-22T07:10:05Z</dc:date>
    </item>
    <item>
      <title>Re: Editing component in sub assembly  error with VBA</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/editing-component-in-sub-assembly-error-with-vba/m-p/8613703#M94784</link>
      <description>&lt;P&gt;Hey &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7076281"&gt;@Olsndot&lt;/a&gt; ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Editing a sub occurrence in API can be coded like this. Code need be adjusted as your need.&lt;/P&gt;
&lt;P&gt;Sub EDIT_COMPONENT()&lt;/P&gt;
&lt;P&gt;Dim oAsmDoc As AssemblyDocument&lt;BR /&gt;Set oAsmDoc = ThisApplication.ActiveDocument&lt;/P&gt;
&lt;P&gt;Dim oAsmCompDef As ComponentDefinition&lt;BR /&gt;Set oAsmCompDef = oAsmDoc.ComponentDefinition&lt;/P&gt;
&lt;P&gt;Dim oOcc As ComponentOccurrence&lt;BR /&gt;Set oOcc = oAsmCompDef.Occurrences.Item(1).SubOccurrences(1)&lt;/P&gt;
&lt;P&gt;oOcc.Edit&lt;BR /&gt;End Sub&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 09:19:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/editing-component-in-sub-assembly-error-with-vba/m-p/8613703#M94784</guid>
      <dc:creator>JaneFan</dc:creator>
      <dc:date>2019-02-22T09:19:34Z</dc:date>
    </item>
    <item>
      <title>Re: Editing component in sub assembly  error with VBA</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/editing-component-in-sub-assembly-error-with-vba/m-p/8617877#M94877</link>
      <description>&lt;P&gt;Hi,@JaneFan&lt;BR /&gt;Thank you for reply,but that is different than what I was expecting.&lt;BR /&gt;I'm sorry I didn't explain it enough and pardon my broken English.. &lt;BR /&gt;I want to edit component in sub assembly while editing sub assembly as shown in the figure.&lt;BR /&gt;Problem I faced is getting error at the&lt;/P&gt;
&lt;PRE&gt;oOcc.Edit&lt;/PRE&gt;
&lt;P&gt;Is it possible to resolve the the problem and edit component in sub assembly while editing?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 01:07:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/editing-component-in-sub-assembly-error-with-vba/m-p/8617877#M94877</guid>
      <dc:creator>Olsndot</dc:creator>
      <dc:date>2019-02-25T01:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: Editing component in sub assembly  error with VBA</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/editing-component-in-sub-assembly-error-with-vba/m-p/8618512#M94899</link>
      <description>&lt;P&gt;Hey &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7076281"&gt;@Olsndot&lt;/a&gt; ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is updated code if you are getting document from ActiveEditDocument. Thanks for Rocky's suggestion. &lt;BR /&gt;Here is the updated code:&lt;/P&gt;
&lt;P&gt;Sub EditUpdate()&lt;/P&gt;
&lt;P&gt;Dim oAsmDoc As AssemblyDocument&lt;BR /&gt;Set oAsmDoc = ThisApplication.ActiveEditDocument&lt;/P&gt;
&lt;P&gt;Dim oEditOccu As ComponentOccurrence&lt;BR /&gt;Dim oTopDoc As AssemblyDocument&lt;BR /&gt;If Not (oAsmDoc Is ThisApplication.ActiveDocument) Then&lt;BR /&gt;Set oTopDoc = ThisApplication.ActiveDocument&lt;BR /&gt;Set oEditOccu = oTopDoc.ComponentDefinition.ActiveOccurrence&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;Dim oOcc As ComponentOccurrence&lt;BR /&gt;Set oOcc = oEditOccu.SubOccurrences(1)&lt;/P&gt;
&lt;P&gt;oOcc.edit&lt;BR /&gt;End Sub&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 09:50:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/editing-component-in-sub-assembly-error-with-vba/m-p/8618512#M94899</guid>
      <dc:creator>JaneFan</dc:creator>
      <dc:date>2019-02-25T09:50:00Z</dc:date>
    </item>
    <item>
      <title>Re: Editing component in sub assembly  error with VBA</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/editing-component-in-sub-assembly-error-with-vba/m-p/8620849#M94922</link>
      <description>&lt;P&gt;Hi&amp;nbsp;JaneFan,&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;That is exactly what I'm expecting! &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you. I appreciate your help.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Feb 2019 02:42:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/editing-component-in-sub-assembly-error-with-vba/m-p/8620849#M94922</guid>
      <dc:creator>Olsndot</dc:creator>
      <dc:date>2019-02-26T02:42:23Z</dc:date>
    </item>
    <item>
      <title>Re: Editing component in sub assembly  error with VBA</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/editing-component-in-sub-assembly-error-with-vba/m-p/9366090#M106792</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;SPAN&gt;Jane Fan,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How to run VBA user parameter of the part component in assembly. Can you hepl me.&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;I have the code from VBA excel to run into inventor, but not working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sub RunIAM()&lt;/P&gt;&lt;P&gt;Dim oWkbk As Workbook&lt;BR /&gt;Set oWkbk = ThisWorkbook&lt;/P&gt;&lt;P&gt;Dim oSheet As Worksheet&lt;BR /&gt;Set oSheet = oWkbk.ActiveSheet&lt;/P&gt;&lt;P&gt;Dim oInv As Inventor.Application&lt;BR /&gt;Set oInv = GetObject(, "Inventor.Application")&lt;/P&gt;&lt;P&gt;Dim oDoc As Document&lt;BR /&gt;Set oDoc = oInv.ActiveDocument&lt;/P&gt;&lt;P&gt;Dim oDocAssy As AssemblyDocument&lt;BR /&gt;Set oDocAssy = oInv.ActiveDocument&lt;/P&gt;&lt;P&gt;' Define sheet name where information resides&lt;BR /&gt;Dim sSheetName As String&lt;BR /&gt;sSheetName = "Output Parameter"&lt;/P&gt;&lt;P&gt;' Set range where parameter names reside in sheet&lt;BR /&gt;Dim sParamRange As String&lt;BR /&gt;sParamRange = "A2:A81"&lt;/P&gt;&lt;P&gt;Dim oCompDef As ComponentDefinition&lt;BR /&gt;' Get component definition&lt;BR /&gt;Set oCompDef = oDoc.ComponentDefinition&lt;/P&gt;&lt;P&gt;Dim oAsmCompDef As AssemblyComponentDefinition&lt;BR /&gt;Set oAsmCompDef = oDocAssy.ComponentDefinition&lt;/P&gt;&lt;P&gt;Dim oOcc As ComponentOccurrence&lt;BR /&gt;Set oOcc = oAsmCompDef.Occurrences.Item(1)&lt;/P&gt;&lt;P&gt;'define parameters&lt;BR /&gt;Dim oUserParams As UserParameters&lt;BR /&gt;Set oUserParams = oCompDef.Parameters.UserParameters&lt;BR /&gt;Dim param As Parameter&lt;BR /&gt;&lt;BR /&gt;Dim oCell As Range&lt;BR /&gt;' Loop through each parameter listed in sheet&lt;BR /&gt;For Each oCell In oSheet.Range(sParamRange)&lt;BR /&gt;' Parse through parameters and check to see if parameter name matches current parameter from Excel&lt;BR /&gt;For Each oParam In oUserParams&lt;BR /&gt;' If names match, copy value and units from Excel into parameter expression&lt;BR /&gt;If oCell.Value = oParam.Name Then&lt;BR /&gt;oParam.Expression = oCell.Offset(0, 1).Value &amp;amp; oCell.Offset(0, 2).Value&lt;BR /&gt;End If&lt;BR /&gt;Next oParam&lt;BR /&gt;Next oCell&lt;/P&gt;&lt;P&gt;'Suppress feature&lt;BR /&gt;If Range("K6").Value = "L" Then&lt;BR /&gt;Dim oHole4 As Inventor.PartFeature&lt;BR /&gt;Set oHole4 = oAsmCompDef.Occurrences.Item(1).Features("Hole4")&lt;BR /&gt;oHole4.Suppressed = True&lt;BR /&gt;Dim oHole5 As Inventor.PartFeature&lt;BR /&gt;Set oHole5 = oDocPart.ComponentDefinition.Features("Hole5")&lt;BR /&gt;oHole5.Suppressed = False&lt;BR /&gt;ElseIf Range("K6").Value = "R" Then&lt;BR /&gt;Set oHole4 = oAsmCompDef.Occurrences.Item(1).Features("Hole4")&lt;BR /&gt;oHole4.Suppressed = False&lt;BR /&gt;Set oHole5 = oDocPart.ComponentDefinition.Features("Hole5")&lt;BR /&gt;oHole5.Suppressed = True&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;If Range("K8").Value = "DE" Then&lt;BR /&gt;Dim oMirror1 As Inventor.PartFeature&lt;BR /&gt;Set oMirror1 = oDocPart.ComponentDefinition.Features("Mirror1")&lt;BR /&gt;oMirror1.Suppressed = True&lt;BR /&gt;Dim oHole3 As Inventor.PartFeature&lt;BR /&gt;Set oHole3 = oDocPart.ComponentDefinition.Features("Hole3")&lt;BR /&gt;oHole3.Suppressed = False&lt;BR /&gt;ElseIf Range("K8").Value = "NDE" Then&lt;BR /&gt;Set oMirror1 = oDocPart.ComponentDefinition.Features("Mirror1")&lt;BR /&gt;oMirror1.Suppressed = False&lt;BR /&gt;Set oHole3 = oDocPart.ComponentDefinition.Features("Hole3")&lt;BR /&gt;oHole3.Suppressed = True&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;If Range("K4").Value = "D1328" Then&lt;BR /&gt;Dim oHole6 As Inventor.PartFeature&lt;BR /&gt;Set oHole6 = oDocPart.ComponentDefinition.Features("Hole6")&lt;BR /&gt;oHole6.Suppressed = True&lt;BR /&gt;Dim oExtrude3 As Inventor.PartFeature&lt;BR /&gt;Set oExtrude3 = oDocPart.ComponentDefinition.Features("Extrusion3")&lt;BR /&gt;oExtrude3.Suppressed = True&lt;BR /&gt;Else&lt;BR /&gt;Set oHole6 = oDocPart.ComponentDefinition.Features("Hole6")&lt;BR /&gt;oHole6.Suppressed = False&lt;BR /&gt;Set oExtrude3 = oDocPart.ComponentDefinition.Features("Extrusion3")&lt;BR /&gt;oExtrude3.Suppressed = False&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;Set oExcel = Nothing&lt;/P&gt;&lt;P&gt;' Update part/assembly&lt;BR /&gt;oDoc.Update&lt;BR /&gt;ActiveWorkbook.Save&lt;/P&gt;&lt;P&gt;End Sub&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 08:39:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/editing-component-in-sub-assembly-error-with-vba/m-p/9366090#M106792</guid>
      <dc:creator>tonythm</dc:creator>
      <dc:date>2020-03-09T08:39:37Z</dc:date>
    </item>
  </channel>
</rss>

