How to buy
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © 2025 Autodesk Inc. All rights reserved
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
Edit: this doesn't work woops
There's a transparency option when creating a color:
Dim oColor As Color oColor = ThisApplication.TransientObjects.CreateColor(255, 255, 255, 0) '--- '------- '---------- Dim oCamera As Camera oCamera.SaveAsBitmap(sResultPathImage & "\" & sPartNumber & ".png", 2800, 2800, oColor)
This won't export with a transparent background though because it's a 24x bitmap. only 32x bitmaps have a transparency layer.
If you use the function:
then there is an option according to the help files.
But this will not give you a picture file but just an IPictureDisp object. You can convert those objects to Bitmap objects check this post:
Maybe then it's possible to save the picture to a file. But I'm afraid this will be too much for an iLogic rule. I would suggest that you create an addin for this. You can find a tutorial for this on my blog.
http://www.hjalte.nl/60-creating-an-inventor-addin
And in the follow-up post a converter Bitmap <-> IPictureDisp is used for creating buttons.
http://www.hjalte.nl/61-adding-icons-to-your-buttons
Maybe it will help you but I guess it won't be easy and in the end I'm not sure it will work.
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Blog: hjalte.nl - github.com
This might be helpful to you:-
'Get the active view. Dim oView = ThisApplication.ActiveView 'Create a new NameValueMap Object Dim oOptions As NameValueMap oOptions = ThisApplication.TransientObjects.CreateNameValueMap '.TransientObjects.CreateNameValueMap oOptions.Value("TransparentBackground") = True 'save screenshot Call oView.SaveAsBitmapWithOptions(CurrentFile, 0, 0, oOptions)
How to buy
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © 2025 Autodesk Inc. All rights reserved
Type a product name