Color of a selected face

Color of a selected face

george1985
Collaborator Collaborator
936 Views
7 Replies
Message 1 of 8

Color of a selected face

george1985
Collaborator
Collaborator

Hello,

Is it possible to change the default color of a selected face via API?
For example, each time when I select any face in Inventor, I would like to be of a dark magenta color:

george1985_0-1715993217812.png

 

This functionality can be achieved via UI in "Color Schemes".
Sadly "Color Schemes" only exist in newer Inventor versions:

george1985_1-1715993368170.png

 



So I was hopping to change this color property via API?
I see there is Application.ColorScheme object, but its properties have only get, no set capability (at least on Inventor 2018)

https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-F5AA49A4-98A5-4851-9BA6-75BA72225123das

Is there some other way to change the color of the selected face via API?

I would be grateful for any kind of help.

0 Likes
Accepted solutions (1)
937 Views
7 Replies
Replies (7)
Message 2 of 8

Andrii_Humeniuk
Advisor
Advisor

Hi @george1985 . Face appearance and Inventor color scheme settings are two different things. If you only need to be able to change the appearance of the face, then you need this iLogic code:

Dim sNameAsset As String = "Magenta"
Dim oInvApp As Inventor.Application = ThisApplication
Dim oPDoc As PartDocument = TryCast(oInvApp.ActiveDocument, PartDocument)
If oPDoc Is Nothing Then Exit Sub
Dim oAsset, oInvAsset As Inventor.Asset
Try : oAsset = oPDoc.Assets(sNameAsset)
Catch
	For Each oAssetLib As AssetLibrary In oInvApp.AssetLibraries
		For Each oAppr As Asset In oAssetLib.AppearanceAssets
			If oAppr.DisplayName = sNameAsset Then oInvAsset = oAppr : Exit For
		Next
		If oInvAsset IsNot Nothing Then Exit For
	Next
	If oInvAsset Is Nothing Then Exit Sub
	Try : oAsset = oInvAsset.CopyTo(oPDoc) : Catch : End Try
End Try
If oAsset Is Nothing Then Exit Sub
Do
	Dim oFace As Inventor.Face = Nothing
	oFace = oInvApp.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Selection Face...")
	If oFace Is Nothing Then Exit Sub
	Try : oFace.Appearance = oAsset
	Catch : Logger.Info("Failed to change appearance!") : End Try
Loop

Also, I couldn't find a appearance called "Dark magenta" in my library. Make sure that you have it and write its full name in line 1.

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

Message 3 of 8

george1985
Collaborator
Collaborator

Thank you @Andrii_Humeniuk for the useful code

I assume the upper code, requires from user to run it, each time he wants to have the selected face color changed?

What I was thinking of: changing the Inventor color scheme variable at the beginning of my Inventor session - by running a code. And then once it is change, it will last until  close that Inventor session.
In this case, it would be the color of the selected face.

0 Likes
Message 4 of 8

_dscholtes_
Advocate
Advocate
Accepted solution

Did you find this thread? It's an old one, but it seems to adress (and solve) the same issue, although I'm not sure it's such specific as selecting a face.

https://forums.autodesk.com/t5/inventor-forum/changing-colors-for-highlighting-part-in-assembly/td-p... 

 

Message 5 of 8

george1985
Collaborator
Collaborator

Hi @_dscholtes_ 
Thank you very much for this very useful tool!

Do you know which color I need to change - in order to modify the color of a selected face?
"Primary Select" or "Secondary Select"?

george1985_0-1716503452511.png

 

0 Likes
Message 6 of 8

_dscholtes_
Advocate
Advocate

I haven't used the tool, but the entries in the list you've show look like the entries in the color scheme editor (I use v2023), so I'll base my answer on that.

For selecting a component, body, feature (etc) in the main model window, you need to adjust the 'highlight' entry.

For  selecting entitities during e.g. the constrain command, you need to adjust the 'primary', secondairy' and 'tertiary' entries.

 Just play around and find out 🙂

Message 7 of 8

george1985
Collaborator
Collaborator

Thank you @_dscholtes_ ,
I am afraid to change anything, in order to not corrupt my Inventor registry 😄
(I already made a backup .reg file)

But it seems that the same Color Scheme Editor functionalities you have on your Inventor 2023 - are also editing the Registry?

0 Likes
Message 8 of 8

_dscholtes_
Advocate
Advocate

@george1985That could be, I have absolutely no idea.