FromColor

FromColor

Anonymous
Not applicable
1,112 Views
7 Replies
Message 1 of 8

FromColor

Anonymous
Not applicable
I'm executing the following statement (or trying to at least):

Autodesk.AutoCAD.Colors.Color acadColor =
Autodesk.AutoCAD.Colors.Color.FromColor( System.Drawing.Color.Yellow );

This throws an exception with the message "eInvalidInput"

Any ideas why this command is throwing an expection?
0 Likes
1,113 Views
7 Replies
Replies (7)
Message 2 of 8

Mikko
Advocate
Advocate
I use the FromRgb:

Dim color As Autodesk.AutoCAD.Colors.Color
color = Autodesk.AutoCAD.Colors.Color.FromRgb(255, 255, 255)
0 Likes
Message 3 of 8

Anonymous
Not applicable
Thanks Mikko

Yes, the FromRgb method works fine.

But, what is wrong with the Autodesk.AutoCAD.Colors.Color.FromColor( System.Drawing.Color) method.

My code is passes a System.Drawing.Color enumeration and I don't want to have to convert it to RGB.

it makes for really ugly code

Autodesk.AutoCAC.Colors.Color.FromRgb( System.Drawing.Color.Yellow.R, System.Drawing.Color.Yellow.G, System.Drawing.Color.Yellow.B )
0 Likes
Message 4 of 8

Mikko
Advocate
Advocate
I'd use numeric numbers.

Autodesk.AutoCAD.Colors.Color.FromRgb(255, 255, 0)
0 Likes
Message 5 of 8

Anonymous
Not applicable
Pehaps I havn't made myself clear.

I'm trying to find out why the FromColor method throws an exception when passed a System.Drawing.Color enumerated value.

My code recieves as a parameter a System.Drawing.Color (not three RGB values). While I can use the System.Drawing.Color.R and .B and .G properties and the FromRgb method, it is much clearer code to use the variable that is passed.

So, once again I'll ask, what am I doing wrong that is causing the FromColor method to throw an exception?
0 Likes
Message 6 of 8

Mikko
Advocate
Advocate
Hmm, I get that same error using FromColor. FromColorIndex works. I have no idea how to use FromColor. Might look at that at another time.

Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 2)
0 Likes
Message 7 of 8

Anonymous
Not applicable
Because its broken.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

wrote in message news:4951971@discussion.autodesk.com...
Pehaps I havn't made myself clear.

I'm trying to find out why the FromColor method throws an exception when passed a System.Drawing.Color enumerated value.

My code recieves as a parameter a System.Drawing.Color (not three RGB values). While I can use the System.Drawing.Color.R and .B and .G properties and the FromRgb method, it is much clearer code to use the variable that is passed.

So, once again I'll ask, what am I doing wrong that is causing the FromColor method to throw an exception?
0 Likes
Message 8 of 8

Anonymous
Not applicable
Indeed this is a bug. I'll make sure that it gets fixed.

Albert
"Tony Tanzillo" wrote in message
news:4952333@discussion.autodesk.com...
Because its broken.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

wrote in message news:4951971@discussion.autodesk.com...
Pehaps I havn't made myself clear.

I'm trying to find out why the FromColor method throws an exception when
passed a System.Drawing.Color enumerated value.

My code recieves as a parameter a System.Drawing.Color (not three RGB
values). While I can use the System.Drawing.Color.R and .B and .G
properties and the FromRgb method, it is much clearer code to use the
variable that is passed.

So, once again I'll ask, what am I doing wrong that is causing the FromColor
method to throw an exception?
0 Likes