Newbie question

Discussion in 'AutoCAD' started by Craig West, Jun 25, 2004.

  1. Craig West

    Craig West Guest

    Hi everyone,

    This seems like a simple thing to try and do, but I can't figure it and have
    gone through help so many times to try and find an answer.

    I am trying to get the colour of a specific entity, I use the following
    command to get the entities information,

    (setq
    entl (entget (ssget ":s"))

    what I can't figure out is how to extract the information for colour, I know
    it is associated with '62' within that list, but don't know how to just
    isolate that piece of information.

    Thanks in advance for any help.
     
    Craig West, Jun 25, 2004
    #1
  2. Craig West

    bruno Guest

    Craig West a écrit :

    (cdr (assoc 62 (entget (car (entsel)))))

    acad developper help for more info

    bye
     
    bruno, Jun 25, 2004
    #2
  3. Craig West

    Jon Guest

    And if the color is bylayer, there will be no 62 in the object, so a fuller
    solution would be:

    (setq entl (entget (ssget ":s"))
    colorcode (assoc 62 entl)
    )
    (if colorcode
    (setq colorcode (cdr colorcode) colortype "Forced")
    (setq entitylayer (cdr (assoc 8 entl))
    colorcode (cdr (assoc 62 (tblsearch "layer" entitylayer)))
    colortype "ByLayer"
    )
    )
    (princ (strcat "\nColor is " (itoa colorcode) " and is " colortype))

    Jon Rasmussen
     
    Jon, Jun 25, 2004
    #3
  4. Craig West

    Joe Burke Guest

    Craig,

    Entget returns a DXF code 62 association list if the object in question is not color
    BYLAYER. Otherwise, the 62 code is absent. So that's something you need to check, if
    you use that method.

    I think using the ActiveX method is easier.

    Command: (setq ename (car (entsel "\nSelect object: ")))
    Select object: <Entity name: 7effa660>
    Command: (setq vobj (vlax-ename->vla-object ename))
    #<VLA-OBJECT IAcadLine 03b2d5e4>
    Command: (setq color (vlax-get vobj 'Color))
    256 ;color bylayer

    No need to mess with DXF codes. And this method always returns something.

    BTW, a question for the group. I don't have 2005 yet. Using 2004. Does 2005 still
    support the Color property? Or is the TrueColor property the only way to do it under
    2005?

    Joe Burke
     
    Joe Burke, Jun 25, 2004
    #4
  5. Joe,

    Color is still supported, but I'd advise working on moving your code to
    TrueColor.

    --
    R. Robert Bell


    Craig,

    Entget returns a DXF code 62 association list if the object in question is
    not color
    BYLAYER. Otherwise, the 62 code is absent. So that's something you need to
    check, if
    you use that method.

    I think using the ActiveX method is easier.

    Command: (setq ename (car (entsel "\nSelect object: ")))
    Select object: <Entity name: 7effa660>
    Command: (setq vobj (vlax-ename->vla-object ename))
    #<VLA-OBJECT IAcadLine 03b2d5e4>
    Command: (setq color (vlax-get vobj 'Color))
    256 ;color bylayer

    No need to mess with DXF codes. And this method always returns something.

    BTW, a question for the group. I don't have 2005 yet. Using 2004. Does 2005
    still
    support the Color property? Or is the TrueColor property the only way to do
    it under
    2005?

    Joe Burke
     
    R. Robert Bell, Jun 25, 2004
    #5
  6. Craig West

    Joe Burke Guest

    Thanks, Robert. I'll get around to it sometime soon.

    I guess it is a bit of dilemma though. My code should work under any version from
    2000 forward. I guess I'll have to add version checking.

    I'm sure all this was covered here in the NG. I missed it since I just recently
    upgraded to 2004. My clients are still using 2002. It doesn't make sense for me to
    get too far ahead of them, regardless of my opinion.

    Joe Burke
     
    Joe Burke, Jun 25, 2004
    #6
  7. If you need to maintain backwards compatibility, don't fix it until it's
    broke! ;^)

    --
    R. Robert Bell


    Thanks, Robert. I'll get around to it sometime soon.

    I guess it is a bit of dilemma though. My code should work under any version
    from
    2000 forward. I guess I'll have to add version checking.

    I'm sure all this was covered here in the NG. I missed it since I just
    recently
    upgraded to 2004. My clients are still using 2002. It doesn't make sense for
    me to
    get too far ahead of them, regardless of my opinion.

    Joe Burke
     
    R. Robert Bell, Jun 25, 2004
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.