Message 1 of 6
Export .PNG Settings....can you toggle them w/ iLogic?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Gang...
I have some iLogic that is exporting a .png, but appears we can't toggle the two additional settings for Showing the Active Components (turn off) and the Transparent Background (Off). Is it possible?
Here's my code;
'--------------------------------------------------------- ' Export Current View to Desktop\<AssemblyName>\template.png ' Resolution: 8000 x 8000 ' Inventor 2023 — minimal API usage for compatibility '--------------------------------------------------------- ' Fully qualify Inventor types to avoid ambiguity with WinForms Dim invApp As Inventor.Application = ThisApplication Dim oDoc As Inventor.Document = invApp.ActiveDocument ' Ensure assembly (.iam) If oDoc.DocumentType <> Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then System.Windows.Forms.MessageBox.Show("This rule only works in an Assembly (.iam).", "Error") Return End If ' Active view Dim oView As Inventor.View = invApp.ActiveView ' -------------------------------------------------------- ' Build Desktop\<AssemblyName>\template.png ' -------------------------------------------------------- ' Get assembly base name (no extension) Dim baseName As String = System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName) ' Sanitize name for folder creation (remove invalid path characters) Dim invalidChars() As Char = System.IO.Path.GetInvalidFileNameChars() For Each ch As Char In invalidChars baseName = baseName.Replace(ch.ToString(), "_") Next ' Resolve Desktop path (respects OneDrive Desktop if redirected) 'Dim desktopPath As String = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory) Dim desktopPath As String = "\\umklfs15\doctrak$\Web\Wheels\stock-item" ' Create target folder: Desktop\<AssemblyName> Dim targetFolder As String = System.IO.Path.Combine(desktopPath, baseName) If Not System.IO.Directory.Exists(targetFolder) Then System.IO.Directory.CreateDirectory(targetFolder) End If ' Final output file Dim outFile As String = System.IO.Path.Combine(targetFolder, "template.png") ' -------------------------------------------------------- ' Export as PNG at requested resolution ' -------------------------------------------------------- Dim outWidth As Integer = 8000 Dim outHeight As Integer = 8000 Try oView.SaveAsBitmap(outFile, outWidth, outHeight) System.Windows.Forms.MessageBox.Show("PNG export complete:" & vbCrLf & outFile, "Done") Catch ex As Exception ' Fallback if the GPU/driver rejects 8000 px (common on some systems) Dim fallbackW As Integer = 6000 Dim fallbackH As Integer = 6000 Try oView.SaveAsBitmap(outFile, fallbackW, fallbackH) System.Windows.Forms.MessageBox.Show( _ "8000×8000 failed on this system. Exported " & fallbackW & "×" & fallbackH & " instead:" & vbCrLf & outFile, _ "Export Complete (Fallback)") Catch ex2 As Exception System.Windows.Forms.MessageBox.Show( _ "Export failed. Error:" & vbCrLf & ex2.Message, _ "Export Error") End Try End Try
Steve Hilvers
Inventor Certified User / Vault Professional Influencer
Inventor Certified User / Vault Professional Influencer