<?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: Open each document for view and close inside assembly. in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/open-each-document-for-view-and-close-inside-assembly/m-p/12114882#M155462</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11943979"&gt;@K.TRYFONIDIS&lt;/a&gt;&amp;nbsp;.&amp;nbsp;Try this code:&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Sub main()
	Dim oAsmDoc As AssemblyDocument = ThisDoc.FactoryDocument
	Dim oDocs As Documents = ThisApplication.Documents
	Dim oRefDocs As DocumentsEnumerator = oAsmDoc.AllReferencedDocuments
	If oRefDocs.Count = 0 Then Exit Sub
	For Each oRefDoc As Document In oRefDocs
		Dim oDoc As Document = oDocs.Open(oRefDoc.FullDocumentName, True)
		System.Threading.Thread.Sleep(5000)
		If oDoc.IsModifiable Then oDoc.Save()
		oDoc.Close()
	Next
End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 20 Jul 2023 13:32:52 GMT</pubDate>
    <dc:creator>Andrii_Humeniuk</dc:creator>
    <dc:date>2023-07-20T13:32:52Z</dc:date>
    <item>
      <title>Open each document for view and close inside assembly.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/open-each-document-for-view-and-close-inside-assembly/m-p/12114852#M155460</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to make an external rule that will run only in an assembly document and will open each of the documents inside of it (.iam and .ipt ) view them for 3 sec then save and close, after move to next one.&lt;BR /&gt;&lt;BR /&gt;i am trying to use a code like this one but i don't get it to run.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;referencedDocs&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;DocumentsEnumerator&lt;/SPAN&gt; = &lt;SPAN&gt;asmDoc&lt;/SPAN&gt;.&lt;SPAN&gt;AllReferencedDocuments&lt;/SPAN&gt;
    &lt;SPAN&gt;For&lt;/SPAN&gt; &lt;SPAN&gt;Each&lt;/SPAN&gt; &lt;SPAN&gt;doc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Document&lt;/SPAN&gt; &lt;SPAN&gt;In&lt;/SPAN&gt; &lt;SPAN&gt;referencedDocs&lt;/SPAN&gt;
        &lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;doc&lt;/SPAN&gt;.&lt;SPAN&gt;DocumentType&lt;/SPAN&gt; = &lt;SPAN&gt;kPartDocumentObject&lt;/SPAN&gt; &lt;SPAN&gt;Or&lt;/SPAN&gt; &lt;SPAN&gt;doc&lt;/SPAN&gt;.&lt;SPAN&gt;DocumentType&lt;/SPAN&gt; = &lt;SPAN&gt;kAssemblyDocumentObject&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt;
            &lt;SPAN&gt;OpenAndViewDocument&lt;/SPAN&gt;(&lt;SPAN&gt;doc&lt;/SPAN&gt;)
            &lt;SPAN&gt;Thread&lt;/SPAN&gt;.&lt;SPAN&gt;Sleep&lt;/SPAN&gt;(5000) &lt;SPAN&gt;' View each document for 5 seconds&lt;/SPAN&gt;
            &lt;SPAN&gt;CloseDocument&lt;/SPAN&gt;(&lt;SPAN&gt;doc&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2023 13:22:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/open-each-document-for-view-and-close-inside-assembly/m-p/12114852#M155460</guid>
      <dc:creator>K.TRYFONIDIS</dc:creator>
      <dc:date>2023-07-20T13:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: Open each document for view and close inside assembly.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/open-each-document-for-view-and-close-inside-assembly/m-p/12114882#M155462</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11943979"&gt;@K.TRYFONIDIS&lt;/a&gt;&amp;nbsp;.&amp;nbsp;Try this code:&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Sub main()
	Dim oAsmDoc As AssemblyDocument = ThisDoc.FactoryDocument
	Dim oDocs As Documents = ThisApplication.Documents
	Dim oRefDocs As DocumentsEnumerator = oAsmDoc.AllReferencedDocuments
	If oRefDocs.Count = 0 Then Exit Sub
	For Each oRefDoc As Document In oRefDocs
		Dim oDoc As Document = oDocs.Open(oRefDoc.FullDocumentName, True)
		System.Threading.Thread.Sleep(5000)
		If oDoc.IsModifiable Then oDoc.Save()
		oDoc.Close()
	Next
End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2023 13:32:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/open-each-document-for-view-and-close-inside-assembly/m-p/12114882#M155462</guid>
      <dc:creator>Andrii_Humeniuk</dc:creator>
      <dc:date>2023-07-20T13:32:52Z</dc:date>
    </item>
    <item>
      <title>Re: Open each document for view and close inside assembly.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/open-each-document-for-view-and-close-inside-assembly/m-p/12114927#M155464</link>
      <description>&lt;P&gt;it works pretty good, only problem is that i want to rotate the parts for those 5 sec, and when i run the code its like frozen.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2023 13:49:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/open-each-document-for-view-and-close-inside-assembly/m-p/12114927#M155464</guid>
      <dc:creator>K.TRYFONIDIS</dc:creator>
      <dc:date>2023-07-20T13:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: Open each document for view and close inside assembly.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/open-each-document-for-view-and-close-inside-assembly/m-p/12114935#M155466</link>
      <description>&lt;P&gt;You cannot use the program while running the code, but you can for example add a 360 degree rotation around the Y axis to the code.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2023 13:51:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/open-each-document-for-view-and-close-inside-assembly/m-p/12114935#M155466</guid>
      <dc:creator>Andrii_Humeniuk</dc:creator>
      <dc:date>2023-07-20T13:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: Open each document for view and close inside assembly.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/open-each-document-for-view-and-close-inside-assembly/m-p/12114955#M155468</link>
      <description>&lt;P&gt;did a slight change to your code.&lt;BR /&gt;&lt;BR /&gt;it works perfect.&lt;BR /&gt;&lt;BR /&gt;this code is being combined with a trigger ilogic to save custom thumbnails of the part ( you can rotate with spacemouse if you have one )&lt;BR /&gt;&lt;BR /&gt;Open documents code.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Imports System.Threading

Sub Main()
Dim oAsmDoc As AssemblyDocument = ThisDoc.FactoryDocument
Dim oDocs As Documents = ThisApplication.Documents
Dim oRefDocs As DocumentsEnumerator = oAsmDoc.AllReferencedDocuments
If oRefDocs.Count = 0 Then Exit Sub

For Each oRefDoc As Document In oRefDocs
Dim oDoc As Document = oDocs.Open(oRefDoc.FullDocumentName, True)
Dim startTime As DateTime = DateTime.Now
Do While DateTime.Now.Subtract(startTime).TotalSeconds &amp;lt; 5
' Allow interaction with the model for 5 seconds
ThisApplication.UserInterfaceManager.DoEvents()
Loop

If oDoc.IsModifiable Then oDoc.Save()
oDoc.Close()
Next

Interaction.MsgBox("Success! All referenced documents have been opened, viewed, saved, and closed.", MsgBoxStyle.Information, "iLogic Rule")
End Sub&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Code to trigger before save.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Imports System.Drawing
Imports System.Drawing.Imaging
' Rule to run only for IPT and IAM files
Sub MAIN	
    Dim m_Doc As Inventor.Document
    m_Doc = ThisDoc.Document
    
    If m_Doc.DocumentType &amp;lt;&amp;gt; kAssemblyDocumentObject _
        And m_Doc.DocumentType &amp;lt;&amp;gt; kPartDocumentObject Then 
        MessageBox.Show("File is not a model.", "iLogic")
        Return 'exit rule
    End If

    ' Get current color scheme name
    Dim oColorSchemeName As String
    oColorSchemeName = ThisApplication.ActiveColorScheme.Name

    ' Get current color scheme background type
    Dim oBackGroundType As BackgroundTypeEnum
    oBackGroundType = ThisApplication.ColorSchemes.BackgroundType

    ' Change to Deep Blue (Presentation)
    ThisApplication.ColorSchemes.Item("Presentation").Activate

    ' Set to use one color background type
    ThisApplication.ColorSchemes.BackgroundType = BackgroundTypeEnum.kOneColorBackgroundType

    ' Save the active view as an image directly
    Dim m_Camera As Inventor.Camera = ThisApplication.ActiveView.Camera
    Dim m_TO As Inventor.TransientObjects = ThisApplication.TransientObjects
    Dim m_CV As Inventor.View = ThisApplication.ActiveView

    Dim m_PrevMode As Integer = m_CV.DisplayMode
    Dim m_Disp3D As Boolean = ThisApplication.DisplayOptions.Show3DIndicator

    m_CV.DisplayMode = Inventor.DisplayModeEnum.kShadedWithEdgesRendering
    ThisApplication.DisplayOptions.Show3DIndicator = False

    m_CV.Update

    ' Set the image path and name
    Dim oPath As String = "folder to save\IMAGES\"
    Dim oFileName As String = System.IO.Path.GetFileNameWithoutExtension(m_Doc.FullFileName) ' Get the file name without extension
    Dim oFile As String = oPath &amp;amp; oFileName &amp;amp; ".png"

    ' Save the image
    m_Camera.SaveAsBitmap(oFile, 800, 600, m_TO.CreateColor(255, 255, 255))

    m_CV.DisplayMode = m_PrevMode
    ThisApplication.DisplayOptions.Show3DIndicator = m_Disp3D
    m_CV.Update

    ' Change back to the original color scheme using the name
    ThisApplication.ColorSchemes.Item(oColorSchemeName).Activate

    ' Change back to the original background type
    ThisApplication.ColorSchemes.BackgroundType = oBackGroundType

End Sub&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2023 13:58:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/open-each-document-for-view-and-close-inside-assembly/m-p/12114955#M155468</guid>
      <dc:creator>K.TRYFONIDIS</dc:creator>
      <dc:date>2023-07-20T13:58:54Z</dc:date>
    </item>
  </channel>
</rss>

