Attribute rotation angle

Discussion in 'AutoCAD' started by Matt W, Oct 18, 2004.

  1. Matt W

    Matt W Guest

    I'm looking for a little guidance here...

    How do you obtain the rotation angle of an attdef within a block?
    I know how to get the block rotation angle, but not the attribute itself.

    Thanks in advance!
     
    Matt W, Oct 18, 2004
    #1
  2. You have to step through the block definition
    with (entnext) until you reach the desired entity.
    Once you have the ename it is just like operating
    on any other entity.
     
    Jason Piercey, Oct 18, 2004
    #2
  3. Matt W

    Matt W Guest

    Thanks.
    The whole "entnext" concept is new to me. I've never had to use it before.
    Am I at least on the right track with my code?? Here's what I've got so far.

    Code:
    (defun DXF (code lst)
    (cdr (assoc code lst))
    )
    
    (defun c:att ( / objEnt ent2 entList att1 att)
    (if (setq objEnt (entsel "Select block... "))
    (progn
    (setq ent2 (entget (setq entList (car objEnt))))
    (if (DXF 66 ent2)
    (progn
    (princ "\nBlock has attributes")
    ; This is where I'm getting confused/stumped, etc...  How do
    I incorporate 'entnext' here?
    )
    )
    )
    (alert "Nothing selected!")
    )
    (princ)
    )
    
    --
    I support two teams: the Red Sox and whoever beats the Yankees.


    "Jason Piercey" <Jason AT atreng DOT com> wrote in message
    | You have to step through the block definition
    | with (entnext) until you reach the desired entity.
    | Once you have the ename it is just like operating
    | on any other entity.
    |
    | --
    | Autodesk Discussion Group Facilitator
    |
    |
    |
    | | > I'm looking for a little guidance here...
    | >
    | > How do you obtain the rotation angle of an attdef within a block?
    | > I know how to get the block rotation angle, but not the attribute
    itself.
    | >
    | > Thanks in advance!
    | >
    | > --
    | > I support two teams: the Red Sox and whoever beats the Yankees.
    | >
    | >
    | >
    |
    |
     
    Matt W, Oct 18, 2004
    #3
  4. Here is a quick sample..

    (setq ename (tblobjname "block" "test"))
    <Entity name: 7edca6c0>

    (entget ename)
    ((-1 . <Entity name: 7edca6c0>) (0 . "BLOCK") (330 . <Entity name:
    7edca698>)

    <snip>

    (setq ename (entnext ename))
    <Entity name: 7edca6a0>

    (entget ename)
    ((-1 . <Entity name: 7edca6a0>) (0 . "LWPOLYLINE") (330 . <Entity name:

    <snip>

    (setq ename (entnext ename))
    <Entity name: 7edca6a8>

    (entget ename)
    ((-1 . <Entity name: 7edca6a8>) (0 . "ATTDEF") (330 . <Entity name:
    7edca698>)

    <snip>

    etc...


    Here is one of my toolbox functions that I use to
    access subentity enames.


    ; Jason Piercey . June 2nd, 2003
    ; get list of sub entity names
    ; [ename] - entity name or vla-object - block, insert or polyline
    ; [filter] - string, re: wcmatch()
    ; return: list of enames or nil
    ; revised: July 10th, 2003 - accepts ename or vla-object
    (defun nEnts (ename filter / data ent rtn)
    (or (= 'ename (type ename))
    (setq ename (vlax-vla-object->ename ename)) )
    (setq filter (strcase filter))
    (while (and ename (setq ename (entnext ename)))
    (setq data (entget ename))
    (setq ent (cdr (assoc 0 data)))
    (if (wcmatch ent filter)
    (setq rtn (cons ename rtn)) )
    (if (= "SEQEND" ent) (setq ename nil))
    )
    (reverse rtn)
    )


    Examples:

    (nEnts (tblobjname "block" "test") "*")
    (<Entity name: 7edca6a0> <Entity name: 7edca6a8> <Entity name: 7edca6b0>
    <Entity name: 7edca6b8>)


    (nEnts (tblobjname "block" "test") "attdef")
    (<Entity name: 7edca6a8> <Entity name: 7edca6b0> <Entity name: 7edca6b8>)


    (nEnts (tblobjname "block" "test") "lwpolyline")
    (<Entity name: 7edca6a0>)
     
    Jason Piercey, Oct 18, 2004
    #4
  5. Matt W

    Matt W Guest

    Thanks, Jason.
    This helps a lot!

    --
    I support two teams: the Red Sox and whoever beats the Yankees.


    "Jason Piercey" <Jason AT atreng DOT com> wrote in message
    | Here is a quick sample..
    |
    | (setq ename (tblobjname "block" "test"))
    | <Entity name: 7edca6c0>
    |
    | (entget ename)
    | ((-1 . <Entity name: 7edca6c0>) (0 . "BLOCK") (330 . <Entity name:
    | 7edca698>)
    |
    | <snip>
    |
    | (setq ename (entnext ename))
    | <Entity name: 7edca6a0>
    |
    | (entget ename)
    | ((-1 . <Entity name: 7edca6a0>) (0 . "LWPOLYLINE") (330 . <Entity name:
    |
    | <snip>
    |
    | (setq ename (entnext ename))
    | <Entity name: 7edca6a8>
    |
    | (entget ename)
    | ((-1 . <Entity name: 7edca6a8>) (0 . "ATTDEF") (330 . <Entity name:
    | 7edca698>)
    |
    | <snip>
    |
    | etc...
    |
    |
    | Here is one of my toolbox functions that I use to
    | access subentity enames.
    |
    |
    | ; Jason Piercey . June 2nd, 2003
    | ; get list of sub entity names
    | ; [ename] - entity name or vla-object - block, insert or polyline
    | ; [filter] - string, re: wcmatch()
    | ; return: list of enames or nil
    | ; revised: July 10th, 2003 - accepts ename or vla-object
    | (defun nEnts (ename filter / data ent rtn)
    | (or (= 'ename (type ename))
    | (setq ename (vlax-vla-object->ename ename)) )
    | (setq filter (strcase filter))
    | (while (and ename (setq ename (entnext ename)))
    | (setq data (entget ename))
    | (setq ent (cdr (assoc 0 data)))
    | (if (wcmatch ent filter)
    | (setq rtn (cons ename rtn)) )
    | (if (= "SEQEND" ent) (setq ename nil))
    | )
    | (reverse rtn)
    | )
    |
    |
    | Examples:
    |
    | (nEnts (tblobjname "block" "test") "*")
    | (<Entity name: 7edca6a0> <Entity name: 7edca6a8> <Entity name: 7edca6b0>
    | <Entity name: 7edca6b8>)
    |
    |
    | (nEnts (tblobjname "block" "test") "attdef")
    | (<Entity name: 7edca6a8> <Entity name: 7edca6b0> <Entity name: 7edca6b8>)
    |
    |
    | (nEnts (tblobjname "block" "test") "lwpolyline")
    | (<Entity name: 7edca6a0>)
    |
    | --
    | Autodesk Discussion Group Facilitator
    |
    |
    |
    | | > Thanks.
    | > The whole "entnext" concept is new to me. I've never had to use it
    | before.
    | > Am I at least on the right track with my code?? Here's what I've got so
    | far.
    | >
    | >
    Code:
    | > (defun DXF (code lst)
    | >    (cdr (assoc code lst))
    | > )
    | >
    | > (defun c:att ( / objEnt ent2 entList att1 att)
    | >    (if (setq objEnt (entsel "Select block... "))
    | >       (progn
    | >          (setq ent2 (entget (setq entList (car objEnt))))
    | >          (if (DXF 66 ent2)
    | >             (progn
    | >                (princ "\nBlock has attributes")
    | >                ; This is where I'm getting confused/stumped, etc...  How
    | do
    | > I incorporate 'entnext' here?
    | >             )
    | >          )
    | >       )
    | >       (alert "Nothing selected!")
    | >    )
    | >    (princ)
    | > )
    | > 
    | >
    | > --
    | > I support two teams: the Red Sox and whoever beats the Yankees.
    |
    |
     
    Matt W, Oct 18, 2004
    #5
  6. You're welcome.
     
    Jason Piercey, Oct 18, 2004
    #6
  7. Matt W

    Jeff Mishler Guest

    As an alternative to (entnext) you could use ActiveX methods to get the
    attributes.

    ;function to return a 2 element list of attributes for a block
    ;the first element contains the editable attributes and the second
    ;contains the constant attributes. If either one is empty, nil is
    ;returned for that element
    (defun GETATTS (blk / )
    (if (eq (type blk) 'ENAME)
    (setq blk (vlax-ename->vla-object blk))
    )
    (if (vla-get-hasattributes blk)
    (setq vAtts (vlax-invoke blk "getattributes")
    cAtts (vlax-invoke blk "getconstantattributes")
    )
    )
    (list vAtts cAtts)
    )
     
    Jeff Mishler, Oct 18, 2004
    #7
  8. I should probably update my toolbox function
    to use activeX, just haven't gotten around to it.
     
    Jason Piercey, Oct 18, 2004
    #8
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.