Batch Export Images with transparent background
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello! I am currently using an iLogic rule I found from some years back on this forum to batch export a large group of images. It would be ideal if these images could already have a transparent background when I export them, so I don't have to run another photoshop script to accomplish this. I know that some compression formats of .bmp support an alpha channel, but I'm not sure what all can be accomplished in Inventor, or if there's a rule to export as PNG which would make it much easier potentially. Any feedback would be greatly appreciated!
Imports System.Windows.Forms
Imports System.IO
Sub Main
sResultPathImage = SelFolder(ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath) 'oDefaultPathImage)
sResultPathBatch = SelFolder(ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath) 'oDefaultPathBatch)
'Dim oHolderList As String
If sResultPathBatch <> "" Then
Dim oFiles = Directory.GetFiles(sResultPathBatch, "*.IAM")
For Each FileName As String In oFiles
On Error Resume Next
oDoc = ThisApplication.Documents.Open(FileName, True)
Dim sPartNumber As String = oDoc.PropertySets("Design Tracking Properties")("Part Number").Value
oCamera = InventorVb.Application.ActiveView.Camera
oCamera.Fit
oCamera.Apply
oCamera.SaveAsBitmap(sResultPathImage & "\" & sPartNumber & ".bmp",2800,2000)
oDoc.Close()
oHolderList = oHolderList & sPartNumber & vbLf
Next
End If
MessageBox.Show(oHolderList)
End Sub
Private Function SelFolder(sPath As String) As String
On Error Resume Next
If sPath = "" Then sPath = ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath
Dim FBrowserDialog As New FolderBrowserDialog
FBrowserDialog.SelectedPath = sPath
Dim result As DialogResult = FBrowserDialog.ShowDialog()
SelFolder = ""
If ( result = DialogResult.OK ) Then 'And ( FBrowserDialog.SelectedPath <> sPath ) Then
SelFolder = FBrowserDialog.SelectedPath
End If
End Function