<?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: Macro functionning for assembly or part in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/macro-functionning-for-assembly-or-part/m-p/10017930#M120208</link>
    <description>&lt;P&gt;The &lt;A href="http://help.autodesk.com/view/INVNTOR/2019/ENU/?guid=GUID-22DC2E3B-4463-4B01-B028-89F5CA7863E7" target="_blank" rel="noopener"&gt;DocumentsEnumerator Object&lt;/A&gt; can't be set to a single document from an open part file.&amp;nbsp; You could use the Application.Documents.VisibleDocuments, but you would then have to remove those you don't want if more than 1 document is open.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alternatively, if you use an &lt;A href="http://help.autodesk.com/view/INVNTOR/2019/ENU/?guid=GUID-6C4C98CB-8909-48EF-B73E-F663424D5B41" target="_blank" rel="noopener"&gt;ObjectCollection Object&lt;/A&gt; , then you could fill it with AllReferencedDocuments from assembly files or with the "odoc" by itself if it is a part.&lt;/P&gt;</description>
    <pubDate>Thu, 21 Jan 2021 00:06:45 GMT</pubDate>
    <dc:creator>J-Camper</dc:creator>
    <dc:date>2021-01-21T00:06:45Z</dc:date>
    <item>
      <title>Macro functionning for assembly or part</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/macro-functionning-for-assembly-or-part/m-p/10016362#M120169</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm trying to create a macro functionning for all parts if the active document is an assembly, or on the part if it is a part. Something like this :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim oRefDocs As DocumentsEnumerator&lt;BR /&gt;Dim oRefDoc As Document&lt;BR /&gt;Dim odoc As Document&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Set odoc = ThisApplication.ActiveDocument&lt;/P&gt;&lt;P&gt;If odoc.DocumentType = kAssemblyDocumentObject Then Set oRefDocs = odoc.AllReferencedDocuments&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;If odoc.DocumentType = kPartDocumentObject Then&amp;nbsp;Set oRefDocs = odoc&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;For each oRefDoc in oRefDocs&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;...&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;next&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;The red line does not function, and I'm stuck... any idea ?&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2021 15:19:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/macro-functionning-for-assembly-or-part/m-p/10016362#M120169</guid>
      <dc:creator>TONELLAL</dc:creator>
      <dc:date>2021-01-20T15:19:05Z</dc:date>
    </item>
    <item>
      <title>Re: Macro functionning for assembly or part</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/macro-functionning-for-assembly-or-part/m-p/10016520#M120175</link>
      <description>&lt;P&gt;What are you attempting to use that document variable for later in your macro?&amp;nbsp; You may need to define it as its true document type (PartDocument or AssemblyDocument) before it will allow certain actions/access related to it.&lt;/P&gt;&lt;P&gt;Here is one approach (of many):&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Dim oDocType As DocumentTypeEnum
Set oDocType = ThisApplication.ActiveDocumentType
If oDocType = kPartDocumentObject Then
	Dim oPDoc As PartDocument
	Set oPDoc = ThisApplication.ActiveDocument
	GoTo PartStart '(place in code dealing with PartDocument stuff)
ElseIf oDocType = kAssemblyDocumentObject Then
	Dim oADoc As AssemblyDocument
	Set oADoc = ThisApplication.ActiveDocument
	GoTo AsmStart '(place in code dealing with AssemblyDocument stuff)
End If&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this solved your problem, or answered your question, please click &lt;SPAN style="background-color: green; color: white;"&gt;&lt;STRONG&gt;ACCEPT SOLUTION&lt;/STRONG&gt;&lt;/SPAN&gt;.&lt;BR /&gt;Or, if this helped you, please click 'LIKE' &lt;SPAN&gt;&lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@7401B55A0A518861312A0F851CD29320/emoticons/1f44d.png" alt=":thumbs_up:" title=":thumbs_up:" /&gt;&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;If you have time, please... Vote For &lt;A href="https://forums.autodesk.com/t5/forums/recentpostspage/post-type/message/interaction-style/idea/user-id/7812054/" target="_blank"&gt;My IDEAS &lt;SPAN&gt;&lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@B166FEBB95D67CFA84899D32D8E17FC1/emoticons/1f4a1.png" alt=":light_bulb:" title=":light_bulb:" /&gt;&lt;/SPAN&gt;&lt;/A&gt;or you can Explore &lt;A href="https://knowledge.autodesk.com/profile/LTSUSR7HXMSAE/articles" target="_blank"&gt;My CONTRIBUTIONS &lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2021/ENU/" target="_blank"&gt;Inventor 2021 Help &lt;/A&gt;| &lt;A href="https://forums.autodesk.com/t5/inventor-forum/bd-p/78/" target="_blank"&gt;Inventor Forum &lt;/A&gt;| &lt;A href="https://forums.autodesk.com/t5/inventor-customization/bd-p/120/" target="_blank"&gt;Inventor Customization Forum &lt;/A&gt;| &lt;A href="https://forums.autodesk.com/t5/inventor-ideas/idb-p/v1232/" target="_blank"&gt;Inventor Ideas Forum &lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2021 16:05:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/macro-functionning-for-assembly-or-part/m-p/10016520#M120175</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2021-01-20T16:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: Macro functionning for assembly or part</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/macro-functionning-for-assembly-or-part/m-p/10017631#M120205</link>
      <description>&lt;P&gt;I agree with your approach. To be more specific, I currently have an iLogic rule that works for iam. This rule is a treatment for all components of the iam. I'm trying to adapt it so that it works the same way for one part. The current code is of the type :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;oRefDocs = ThisDoc.Document.AllReferencedDocuments
For Each oRefDoc In oRefDocs
...
Next oRefDoc&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;What I'm trying to do is to make oRefDocs contain AllreferencedDocuments if the file is an iam, or contain the file itself if it is a part.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2021 21:41:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/macro-functionning-for-assembly-or-part/m-p/10017631#M120205</guid>
      <dc:creator>TONELLAL</dc:creator>
      <dc:date>2021-01-20T21:41:36Z</dc:date>
    </item>
    <item>
      <title>Re: Macro functionning for assembly or part</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/macro-functionning-for-assembly-or-part/m-p/10017930#M120208</link>
      <description>&lt;P&gt;The &lt;A href="http://help.autodesk.com/view/INVNTOR/2019/ENU/?guid=GUID-22DC2E3B-4463-4B01-B028-89F5CA7863E7" target="_blank" rel="noopener"&gt;DocumentsEnumerator Object&lt;/A&gt; can't be set to a single document from an open part file.&amp;nbsp; You could use the Application.Documents.VisibleDocuments, but you would then have to remove those you don't want if more than 1 document is open.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alternatively, if you use an &lt;A href="http://help.autodesk.com/view/INVNTOR/2019/ENU/?guid=GUID-6C4C98CB-8909-48EF-B73E-F663424D5B41" target="_blank" rel="noopener"&gt;ObjectCollection Object&lt;/A&gt; , then you could fill it with AllReferencedDocuments from assembly files or with the "odoc" by itself if it is a part.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jan 2021 00:06:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/macro-functionning-for-assembly-or-part/m-p/10017930#M120208</guid>
      <dc:creator>J-Camper</dc:creator>
      <dc:date>2021-01-21T00:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: Macro functionning for assembly or part</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/macro-functionning-for-assembly-or-part/m-p/10018936#M120218</link>
      <description>&lt;P&gt;&lt;EM&gt;"The&amp;nbsp;&lt;A href="http://help.autodesk.com/view/INVNTOR/2019/ENU/?guid=GUID-22DC2E3B-4463-4B01-B028-89F5CA7863E7" target="_blank" rel="noopener nofollow noopener noreferrer"&gt;DocumentsEnumerator Object&lt;/A&gt;&amp;nbsp;can't be set to a single document from an open part file."&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Yes, that's the problem...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"&lt;EM&gt;Alternatively, if you use an&amp;nbsp;&lt;/EM&gt;&lt;/SPAN&gt;&lt;EM&gt;&lt;A href="http://help.autodesk.com/view/INVNTOR/2019/ENU/?guid=GUID-6C4C98CB-8909-48EF-B73E-F663424D5B41" target="_blank" rel="noopener nofollow noopener noreferrer"&gt;ObjectCollection Object&lt;/A&gt;&amp;nbsp;"&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;That's the workaround I use. I thought there was a better solution. The DocumentsEnumeratorObject contains Documents, ActiveDocument is a document, so I don't understand why I can't fill a DocumentsEnumeratorObject with a Document...&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jan 2021 10:55:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/macro-functionning-for-assembly-or-part/m-p/10018936#M120218</guid>
      <dc:creator>TONELLAL</dc:creator>
      <dc:date>2021-01-21T10:55:41Z</dc:date>
    </item>
    <item>
      <title>Re: Macro functionning for assembly or part</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/macro-functionning-for-assembly-or-part/m-p/10019444#M120229</link>
      <description>&lt;P&gt;The DocumentsEnumerator Object can't be filled because it has no method for Add/Remove.&amp;nbsp; The only properties it has are: Count, Item, &amp;amp; Type.&amp;nbsp; You have to set it to another DocumentsEnumerator Object, like AllReferencedDocuments, in order for it to be "filled".&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jan 2021 13:26:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/macro-functionning-for-assembly-or-part/m-p/10019444#M120229</guid>
      <dc:creator>J-Camper</dc:creator>
      <dc:date>2021-01-21T13:26:54Z</dc:date>
    </item>
  </channel>
</rss>

