Dear all,
I want to save my thumbnails with a different background then my original setting of my inventor file.
Theirfore I first want to change the background then save the file and then set the setting back to the original inventor setting.
I've already have tried to write a little in Visual Studio, see attachment, but I keep getting an error.
It would be great if anyone could help me.
Public Sub BackgroundSwapper(ByVal InventorApplication As Inventor.Application)
Dim oDoc As Inventor.Document = InventorApplication.ActiveEditDocument
Dim StandardFile As String = ("C:\TEMP\InventorBackGroundSettings.txt")
Dim CurrentColorScheme As String
On Error Resume Next
CurrentColorScheme = InventorApplication.ActiveColorScheme.Name
Dim DefaultSetting As String
If System.IO.File.Exists(StandardFile) Then
DefaultSetting = com_BackgroundAssm.Text
Else
DefaultSetting = com_BackgroundAssm.Text
End If
If CurrentColorScheme = "Presentation" Then
InventorApplication.ColorSchemes(DefaultSetting).Activate()
InventorApplication.ColorSchemes.BackgroundType = 52737 '= color gradient.
Else
InventorApplication.ColorSchemes("Presentation").Activate()
InventorApplication.ColorSchemes.BackgroundType = 52737 '= one color.
End If
oDoc.Save()
End Sub
Solved! Go to Solution.
Solved by Dev_rim. Go to Solution.
Hi there,
As far as I know ActiveEditDocument, is using for reaching the assembly documents on the edit mode. So first thing you should use ActiveDocument instead of ActiveEditDocument.
I can not understand why you are using 2 If statements with the same result on true and false.
In the end the final code you need I think :
Public Sub BackgroundSwapper(ByVal InventorApplication As Inventor.Application)
Dim oDoc As Inventor.Document = InventorApplication.ActiveDocument
Dim StandardFile As String = ("C:\TEMP\InventorBackGroundSettings.txt")
Dim CurrentColorScheme As String
On Error Resume Next
CurrentColorScheme = InventorApplication.ActiveColorScheme.Name
Dim DefaultSetting As String = com_BackgroundAssm.Text
InventorApplication.ColorSchemes("Presentation").Activate()
InventorApplication.ColorSchemes.BackgroundType = 52737 '= one color.
oDoc.Save()
InventorApplication.ColorSchemes(CurrentColorScheme).Activate()
End Sub
Hi,
Thanks for your reply. It still has the same error as before.
I think your right about the double statement. So I will implement that.
Oh I just check the image you send.
You have to call the function with Application object.
You are calling it right now like this
But you have to put some Application object inside of the parenthesis.
like:
BackgroundSwapper(Invapp)
or the variable that contains the Inventor.Application object.
Thats your issue
for myself, I use this little code
In application option: one color set to white
and I use background file
If ThisApplication.ColorSchemes.BackgroundType = kOneColorBackgroundType Then ThisApplication.ColorSchemes.BackgroundType = kImageBackgroundType Else If ThisApplication.ColorSchemes.BackgroundType = kImageBackgroundType Then ThisApplication.ColorSchemes.BackgroundType = kOneColorBackgroundType End If
Can't find what you're looking for? Ask the community or share your knowledge.