- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Can anybody help?
I am trying to set the colour of a part, via a VBA macro, using RGB Values.
Can someone try the following VBA macro on a Inventor part (ipt) document and let me know if you are getting the same error as me?
Public Function SetPartColour()
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
Dim color As ColorAssetValue
Set color = oDoc.ActiveAppearance.Item("generic_diffuse")
color.Value = ThisApplication.TransientObjects.CreateColor(Red, Green, Blue)
End Function
I get an error on the line highlighted in RED
Does anybody know how I can fix the error?
Many thanks in advance!!!!
Darren
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
What version of Inventor are you using?
-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570
Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am currently using 2021 (And testing 2022).
Are there different macros to change the colour depending on what version of inventor you are using?
Many thanks in advance!!
Kind Regards
Darren
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
Here is how I do it :
Dim oAppearence As Asset oAppearence = oDoc.Assets.Add(kAssetTypeAppearance, "Generic", "Appearances") Dim oColor As ColorAssetValue oColor = oAppearence.Item("generic_diffuse") oColor.Value = ThisApplication.TransientObjects.CreateColor(0,145,255) oExtrude1.Appearance = oAppearence
oExstrude1 is set before hand.
Regards,
FINET L.
If this post solved your question, please kindly mark it as "Solution"
If this post helped out in any way to solve your question, please drop a "Like"- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @isocam
In case it's of interest, attached is a 2019 file that creates a new appearance in the part and allows you to use sliders in a form to change the color dynamically.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com