Compare colors

Compare colors

TONELLAL
Collaborator Collaborator
291 Views
1 Reply
Message 1 of 2

Compare colors

TONELLAL
Collaborator
Collaborator

Hello,

I need to override part color with default renderstyle color. So I get the default render style color (only the Ambient color), create a color based on RGB values, and compare with reference colors to use a Select case. But I cannot differentiate 2 colors created with CreateColors. Where is the problem ?

 

Dim oDoc As PartDocument
Dim couleur As Color, colRed As Color, colGreen As Color

Dim rr As Byte, gg As Byte, bb As Byte


Set oDoc = ThisApplication.ActiveDocument
oDoc.RenderStyles.Item("Par défaut").GetAmbientColor rr, gg, bb

'Create the color

Set couleur = ThisApplication.TransientObjects.CreateColor(rr, gg, bb)

 

'Create reference colors

Set colRed= ThisApplication.TransientObjects.CreateColor(255, 0, 0)
Set colGreen = ThisApplication.TransientObjects.CreateColor(0, 255, 0)

 

'Compare

select case couleur  'ALL THE CASES ARE TRUE !

case colRed

  ...

case colGreen

  ...

end select

0 Likes
292 Views
1 Reply
Reply (1)
Message 2 of 2

philippe.leefsma
Alumni
Alumni

Hi There,

 

You cannot use an object as a Select/Case paramater, only Integer/String/Bool are supported I believe.

 

You would need to create your own color comparison method by checking each property to see if they are equal, Color.Red, Green, Blue, Opacity.

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes