Document (part or sub-assembly) highlight color is different from default blue c

RoyWickrama_RWEI
Advisor
Advisor

Document (part or sub-assembly) highlight color is different from default blue c

RoyWickrama_RWEI
Advisor
Advisor

I have part of my rule that I select documents from within the assembly.

The rule is fine (i.e., the selected document gets highlighted at the time of selecting). But the color is different from default blue.

Could someone help to fix this issue! Thanks.

 

Public Class RWEI_0023A
Sub main()
Dim iL_NO As String = "0025A"
Dim iL_Name As String = "Highlighted Multiple Selections"
Dim iL_FFN As String = "Rule " & iL_NO & ": " & iL_Name
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument

	Dim oLFN_Pos As Long
	Dim oFFN As String	'Full file name (with extension)
	Dim oLFN As String	'Local file name (with extension)

Dim oSelectionOptions As New ArrayList
Dim oComp As String  = "Component"
Dim oPart As String = "Part"
Dim oCancell As String = "Cancel"
oSelectionOptions.Add(oComp)
oSelectionOptions.Add(oPart)
oSelectionOptions.Add(oCancell)

Dim oSelectedSet As Inventor.HighlightSet
oSelectedSet = oDoc.CreateHighlightSet
oSelectedSet.Clear

Dim oEntities As ObjectCollection
oEntities = ThisApplication.TransientObjects.CreateObjectCollection

Dim oOccurrence As ComponentOccurrence
oSelection = InputListBox("SELECT", oSelectionOptions, oSelectionOptions(0), Title := iL_NO & ": COMPONENT SELECTION", ListName := iL_NO & ": Selection List")
If oSelection = oCancell Then Exit Sub

While True
	If oSelection = oComp Then
		oEntity = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, iL_NO & ": Select Component:")
	Else If oSelection = oPart Then
		oEntity = ThisApplication.CommandManager.Pick(kAssemblyLeafOccurrenceFilter, iL_NO & ": Select Part:")
	End If
	If IsNothing(oEntity) Then Exit While
	oSelectedSet.AddItem(oEntity)
	oEntities.Add(oEntity) 
End While
oSelectedSet.Clear

i = 1
For Each oEntity In oEntities
'	oDoc_Entity = oEntity.Definition.Document
'	oFFN = oDoc_Entity.FullFileName
'	oLFN_Return = oName_Doc_Local(oFFN, oLFN_Pos, oLFN)
'	MessageBox.Show("Name - Occurrence: " & oEntity.Name _
'	& vbLf & "Name - LFN: " & oLFN_Return _
'	& vbLf & "Name - FFN: " & oDoc_Entity.FullFileName, iL_FFN)
''	i += 1
Next 

End Sub

Function oName_Doc_Local(oFFN As String, oLFN_Pos As Double, oLFN As String)
		oLFN_Pos = InStrRev(oFFN, "\", -1)		
		oLFN = Mid(oFFN, oLFN_Pos + 1, Len(oFFN) - oLFN_Pos)
		Return oLFN
End Function

End Class

Not Blue.png 

0 Likes
Reply
Accepted solutions (1)
869 Views
13 Replies
Replies (13)

bradeneuropeArthur
Mentor
Mentor

Hi,

 

Maybe I don't understand, but I don't see any code that changes the color!!

 

Regards,

Autodesk Software: Inventor Professional 2018 | Vault Professional 2018 | Autocad Mechanical 2018
Programming Skills: Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Dimension Component! | Partlist Export! | Derive I-properties! | Vault Prompts Via API! | Vault Handbook/Manual!
Drawing Toggle Sheets! | Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

0 Likes

bradeneuropeArthur
Mentor
Mentor

I understand now...

I will see.....

 

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

RoyWickrama_RWEI
Advisor
Advisor

Thanks for taking time to take a look at this.

0 Likes

bradeneuropeArthur
Mentor
Mentor

I am still struggling with the color too.

Think that it also could be a api bug.

But I am not sure.

A tried to change the color to ie red but also not working.

 

🤔🤔🤔

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

0 Likes

chandra.shekar.g
Autodesk Support
Autodesk Support

@RoyWickrama_RWEI ,

 

Hoping that below settings in Application options may be helpful.

Selection_color.png

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



RoyWickrama_RWEI
Advisor
Advisor

Thanks for the reply. It opened me some where I totally neglected.

But, it not not yielding the results I expect. But, good to explore. Thanks.

0 Likes

bradeneuropeArthur
Mentor
Mentor

Hi,

 

Still think there is an API bug here.

I tried to change the color by .SetColor(255,0,0), but this is not working.

So to my opinion maybe a bug!!!!

Maybe Autodesk can confirm this?

 

Regards,

Autodesk Software: Inventor Professional 2018 | Vault Professional 2018 | Autocad Mechanical 2018
Programming Skills: Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Dimension Component! | Partlist Export! | Derive I-properties! | Vault Prompts Via API! | Vault Handbook/Manual!
Drawing Toggle Sheets! | Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

RoyWickrama_RWEI
Advisor
Advisor

Thanks for the reply.

You are right.

For now, it is OK because it is highlighted any way (@ a weird color).

 

I have a humble request. In my other post, I need to have the bom structure including the items made referenced from within assembly. Do you think, could you shed some light on this! Thanks.

 

https://forums.autodesk.com/t5/inventor-customization/bom-structure-assigned-assy-level-not-captured...

 

 

 

0 Likes

bradeneuropeArthur
Mentor
Mentor

I have tried this with no result...

oSelectedSet = oDoc.CreateHighlightSet
Dim r As Byte = 250
Dim g As Byte = 0
Dim b As Byte = 0
oSelectedSet.Color.SetColor (r,g,b)

MsgBox (oSelectedSet.Color.Red & "-" & oSelectedSet.Color.Green & "-" & oSelectedSet.Color.Blue)

Result is always 240 0 0

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

0 Likes

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@RoyWickrama_RWEI ,

 

Try below code to change the color of highlighted sets. @bradeneuropeArthur is provided valuable hint to change the color of selection.

Public Class RWEI_0023A
Sub main()
	Dim iL_NO As String = "0025A"
	Dim iL_Name As String = "Highlighted Multiple Selections"
	Dim iL_FFN As String = "Rule " & iL_NO & ": " & iL_Name
	Dim oDoc As AssemblyDocument
	oDoc = ThisApplication.ActiveDocument

	Dim oLFN_Pos As Long
	Dim oFFN As String	'Full file name (with extension)
	Dim oLFN As String	'Local file name (with extension)

	Dim oSelectionOptions As New ArrayList
	Dim oComp As String  = "Component"
	Dim oPart As String = "Part"
	Dim oCancell As String = "Cancel"
	oSelectionOptions.Add(oComp)
	oSelectionOptions.Add(oPart)
	oSelectionOptions.Add(oCancell)


	Dim oSelectedSet As Inventor.HighlightSet
	oSelectedSet = oDoc.CreateHighlightSet
	oSelectedSet.Clear
	
	Dim r As Byte = 0
	Dim g As Byte = 0
	Dim b As Byte = 250
 	Dim oColor As Color
    oColor = ThisApplication.TransientObjects.CreateColor(r,g,b)
	
	oSelectedSet.Color = oColor 
	
	Dim oEntities As ObjectCollection
	oEntities = ThisApplication.TransientObjects.CreateObjectCollection

	Dim oOccurrence As ComponentOccurrence
	oSelection = InputListBox("SELECT", oSelectionOptions, oSelectionOptions(0), Title := iL_NO & ": COMPONENT SELECTION", ListName := iL_NO & ": Selection List")
	If oSelection = oCancell Then Exit Sub

	While True
		If oSelection = oComp Then
			oEntity = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, iL_NO & ": Select Component:")
		Else If oSelection = oPart Then
			oEntity = ThisApplication.CommandManager.Pick(kAssemblyLeafOccurrenceFilter, iL_NO & ": Select Part:")
		End If
		If IsNothing(oEntity) Then Exit While
		oSelectedSet.AddItem(oEntity)
		oEntities.Add(oEntity) 
	End While
	oSelectedSet.Clear

	i = 1
	For Each oEntity In oEntities
	'	oDoc_Entity = oEntity.Definition.Document
	'	oFFN = oDoc_Entity.FullFileName
	'	oLFN_Return = oName_Doc_Local(oFFN, oLFN_Pos, oLFN)
	'	MessageBox.Show("Name - Occurrence: " & oEntity.Name _
	'	& vbLf & "Name - LFN: " & oLFN_Return _
	'	& vbLf & "Name - FFN: " & oDoc_Entity.FullFileName, iL_FFN)
	''	i += 1
	Next 

End Sub

Function oName_Doc_Local(oFFN As String, oLFN_Pos As Double, oLFN As String)
		oLFN_Pos = InStrRev(oFFN, "\", -1)		
		oLFN = Mid(oFFN, oLFN_Pos + 1, Len(oFFN) - oLFN_Pos)
		Return oLFN
End Function

End Class

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



RoyWickrama_RWEI
Advisor
Advisor

Thanks a lot Chandra.Shekar.

It is doing well. 

At this moment, I thank @bradeneurope|Arthur as well - was so much helpful.

0 Likes

bradeneuropeArthur
Mentor
Mentor

@chandra.shekar.g 

 

That did the trick:

	Dim r As Byte = 0
	Dim g As Byte = 0
	Dim b As Byte = 250
 	Dim oColor As Color
    oColor = ThisApplication.TransientObjects.CreateColor(r,g,b)
	
	oSelectedSet.Color = oColor 

Well done Smiley Wink

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

chandra.shekar.g
Autodesk Support
Autodesk Support

@bradeneuropeArthur 


@bradeneuropeArthur wrote:

@chandra.shekar.g 

 

That did the trick:

	Dim r As Byte = 0
	Dim g As Byte = 0
	Dim b As Byte = 250
 	Dim oColor As Color
    oColor = ThisApplication.TransientObjects.CreateColor(r,g,b)
	
	oSelectedSet.Color = oColor 

Well done Smiley Wink


Yes, this is what needed to assign color to selectset.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network