.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Reply
Message 1 of 8
davidgarner
455 Views, 7 Replies

FromColor

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?
7 REPLIES 7
Message 2 of 8
Mikko
in reply to: davidgarner

I use the FromRgb:

Dim color As Autodesk.AutoCAD.Colors.Color
color = Autodesk.AutoCAD.Colors.Color.FromRgb(255, 255, 255)
Message 3 of 8
davidgarner
in reply to: davidgarner

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 )
Message 4 of 8
Mikko
in reply to: davidgarner

I'd use numeric numbers.

Autodesk.AutoCAD.Colors.Color.FromRgb(255, 255, 0)
Message 5 of 8
davidgarner
in reply to: davidgarner

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?
Message 6 of 8
Mikko
in reply to: davidgarner

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)
Message 7 of 8
Anonymous
in reply to: davidgarner

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?
Message 8 of 8
Anonymous
in reply to: davidgarner

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?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost