cancel
Showing results for 
Search instead for 
Did you mean: 

Color Handling in NX: White is not member of Color

Creator
Creator

I ran this code directly in NX without any problem, however, when I put this code to Visual Studio, it returns errors "White is not member of Color" - any suggestion to fix this problem is appreciated.

 

 

2017-05-30_11-53-59.png

 

3 REPLIES

Re: Color Handling in NX: White is not member of Color

Siemens Phenom Siemens Phenom
Siemens Phenom

What namespace did you import to get the Color class? You probably need to add it as a reference in your VS project properties.

 

Re: Color Handling in NX: White is not member of Color

Siemens Phenom Siemens Phenom
Siemens Phenom
Do you have both 'Imports Snap' and 'Imports System.Drawing' in your program.

If I only have System.Drawing, then I can use this line:

Dim bckgrndColor As Color = Color.White

But if I have Snap also, then I have to fully qualify which Color I mean:

Dim bckgrndColor As System.Drawing.Color = Drawing.Color.White

because Snap.Color does not have a member named White.

Re: Color Handling in NX: White is not member of Color

Siemens Phenom Siemens Phenom
Siemens Phenom

You say the code works in the Journal Editor, but not in Visual Studio.

 

This is because code that's built/run in the Journal Editor automatically gets a reference to System.Drawing, so "Color" is understood to mean System.Drawing.Color.

 

In Visual Studio, you have to add the reference to System.Drawing yourself.

山田
yamada