.NET

Reply
Active Contributor
davidgarner
Posts: 26
Registered: ‎04-14-2005
Message 1 of 8 (123 Views)

FromColor

123 Views, 7 Replies
09-08-2005 02:45 PM
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?
Distinguished Contributor
Mikko
Posts: 212
Registered: ‎10-03-2003
Message 2 of 8 (123 Views)

Re: FromColor

09-09-2005 04:27 AM in reply to: davidgarner
I use the FromRgb:

Dim color As Autodesk.AutoCAD.Colors.Color
color = Autodesk.AutoCAD.Colors.Color.FromRgb(255, 255, 255)
Active Contributor
davidgarner
Posts: 26
Registered: ‎04-14-2005
Message 3 of 8 (123 Views)

Re: FromColor

09-09-2005 09:11 AM 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 )
Distinguished Contributor
Mikko
Posts: 212
Registered: ‎10-03-2003
Message 4 of 8 (123 Views)

Re: FromColor

09-09-2005 10:01 AM in reply to: davidgarner
I'd use numeric numbers.

Autodesk.AutoCAD.Colors.Color.FromRgb(255, 255, 0)
Active Contributor
davidgarner
Posts: 26
Registered: ‎04-14-2005
Message 5 of 8 (123 Views)

Re: FromColor

09-09-2005 10:23 AM 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?
Distinguished Contributor
Mikko
Posts: 212
Registered: ‎10-03-2003
Message 6 of 8 (123 Views)

Re: FromColor

09-09-2005 11:41 AM 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)
*Tony Tanzillo
Message 7 of 8 (123 Views)

Re: FromColor

09-09-2005 02:02 PM 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?
*Albert Szilvasy
Message 8 of 8 (123 Views)

Re: FromColor

09-11-2005 11:13 AM 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?
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.