• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • .NET

    Reply
    Active Contributor
    Posts: 26
    Registered: ‎04-14-2005

    FromColor

    94 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?
    Please use plain text.
    Distinguished Contributor
    Posts: 195
    Registered: ‎10-03-2003

    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)
    Please use plain text.
    Active Contributor
    Posts: 26
    Registered: ‎04-14-2005

    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 )
    Please use plain text.
    Distinguished Contributor
    Posts: 195
    Registered: ‎10-03-2003

    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)
    Please use plain text.
    Active Contributor
    Posts: 26
    Registered: ‎04-14-2005

    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?
    Please use plain text.
    Distinguished Contributor
    Posts: 195
    Registered: ‎10-03-2003

    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)
    Please use plain text.
    *Tony Tanzillo

    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?
    Please use plain text.
    *Albert Szilvasy

    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?
    Please use plain text.