<?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: Context for publication- Inventor Presentation in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/context-for-publication-inventor-presentation/m-p/11311302#M140478</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Publications are basically fully featured Scene objects, both of which are children of the Presentation document.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After much digging, I was not able to determine what the context variable should be. (There is a lot of goodies hidden in the document attributes, but none worked...)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I was able to find a suitable workaround I believe to access all the publications without using SelectSet. This operates on two principles: The model browser scene nodes return PublicationObject type and no Scenes can have the same names (Inventor throws an error if you try to name them the same). Therefore, I am able to get a list of all publication objects and also determine the active publication.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note this code is iLogic and can be run using the new 2023 ribbon buttons.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Dim doc As PresentationDocument = ThisApplication.ActiveDocument
Dim pubs As New List(Of Publication) 'Essentially PresentationDocument.Publications

Dim topnode = doc.BrowserPanes.Item("Model").TopNode

For Each node As BrowserNode In topnode.BrowserNodes 'These are all the scene nodes
	If node.NativeObject IsNot Nothing AndAlso TypeOf node.NativeObject Is Publication Then
		pubs.Add(node.NativeObject)
	End If
Next

Dim activePub = pubs.First(Function(p) p.DisplayName = doc.ActiveScene.Name) 'Essentially PresentationDocument.ActivePublication&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 21 Jul 2022 12:30:40 GMT</pubDate>
    <dc:creator>g.georgiades</dc:creator>
    <dc:date>2022-07-21T12:30:40Z</dc:date>
    <item>
      <title>Context for publication- Inventor Presentation</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/context-for-publication-inventor-presentation/m-p/11310660#M140453</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;In PresentationDocument class, ActivePublication property requires ("Context") as argument. I would like to know how publication and presentation document is related and what is the required "context" as argument.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 06:39:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/context-for-publication-inventor-presentation/m-p/11310660#M140453</guid>
      <dc:creator>mjkoushik</dc:creator>
      <dc:date>2022-07-21T06:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: Context for publication- Inventor Presentation</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/context-for-publication-inventor-presentation/m-p/11311302#M140478</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Publications are basically fully featured Scene objects, both of which are children of the Presentation document.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After much digging, I was not able to determine what the context variable should be. (There is a lot of goodies hidden in the document attributes, but none worked...)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I was able to find a suitable workaround I believe to access all the publications without using SelectSet. This operates on two principles: The model browser scene nodes return PublicationObject type and no Scenes can have the same names (Inventor throws an error if you try to name them the same). Therefore, I am able to get a list of all publication objects and also determine the active publication.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note this code is iLogic and can be run using the new 2023 ribbon buttons.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Dim doc As PresentationDocument = ThisApplication.ActiveDocument
Dim pubs As New List(Of Publication) 'Essentially PresentationDocument.Publications

Dim topnode = doc.BrowserPanes.Item("Model").TopNode

For Each node As BrowserNode In topnode.BrowserNodes 'These are all the scene nodes
	If node.NativeObject IsNot Nothing AndAlso TypeOf node.NativeObject Is Publication Then
		pubs.Add(node.NativeObject)
	End If
Next

Dim activePub = pubs.First(Function(p) p.DisplayName = doc.ActiveScene.Name) 'Essentially PresentationDocument.ActivePublication&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 12:30:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/context-for-publication-inventor-presentation/m-p/11311302#M140478</guid>
      <dc:creator>g.georgiades</dc:creator>
      <dc:date>2022-07-21T12:30:40Z</dc:date>
    </item>
  </channel>
</rss>

