TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Crank on September 20, 2007, 04:28:57 PM

Title: How to select in attipedit with lisp
Post by: Crank on September 20, 2007, 04:28:57 PM
I'm trying to walk trough all attribs after a block has been inserted with lisp and then start the command ATTIPEDIT on every attribute. This is something I've tried:
Code: [Select]
(setq att (entlast))
(if (assoc 66 (entget att))(progn
         (setq att (entnext (entlast)))
(while (setq att (entnext att))
(if (= (cdr (assoc 0 (entget att))) "ATTRIB")
(vl-cmdf ".attipedit" (nentselp (cdr (assoc 11 (entget att)))))
)
)
))
The problem with this is that you need a point real close to the text. The coords of DXF-code 10 or 11 are not working because the text isn't on those insertion points.

So the big question is: How can I find a point that's exact on the text of the attribute, or is there another way to use ATTIPEDIT when you only have the ename of the block to go from?
Title: Re: How to select in attipedit with lisp
Post by: LE on September 20, 2007, 04:43:10 PM
ATTIPEDIT ?

is that a new command in A2008?
Title: Re: How to select in attipedit with lisp
Post by: Crank on September 20, 2007, 04:53:28 PM
Yes, it's a command to edit an atrribute in place.
Title: Re: How to select in attipedit with lisp
Post by: T.Willey on September 20, 2007, 05:00:08 PM
I don't have '08, so this is a guess/idea.  Couldn't you just pass the ename of the attribute to the comamnd?

Edit:  You may need to watch out for the error of nesting a command to deep.
Title: Re: How to select in attipedit with lisp
Post by: Crank on September 20, 2007, 05:57:00 PM
Negative. This doesn't work: (command "attipedit" (entnext (entlast))) , but this works: (command "attipedit" (nentsel)) or (command "attipedit" (nentselp))

The coords found with (nentselp) can also be used.
Title: Re: How to select in attipedit with lisp
Post by: T.Willey on September 20, 2007, 06:19:02 PM
Try this it, worked with -attedit, so it might work with the new command.  Pass the command a list of the attribute's ename followed by the block's ename.

Edit:  This may not work, as shown with this little bit of code from the command line.
Quote
Command: (progn
(_> (setq blkent (car (entsel)))
(_> (setq attent (car (nentsel)))
(_> (command "-attedit" "" "" "" "" (list attent blkent))
(_> )

Select object:
Select object: -attedit
Edit attributes one at a time? [Yes/No] <Y>:
Enter block name specification <*>:
Enter attribute tag specification <*>:
Enter attribute value specification <*>: Select Attributes:
Command: nil

but if done from the command line it works, as shown here
Quote
Command: -attedit

Edit attributes one at a time? [Yes/No] <Y>:

Enter block name specification <*>:

Enter attribute tag specification <*>:

Enter attribute value specification <*>:
Select Attributes: (list attent blkent)
(<Entity name: 7efcdf98> <Entity name: 7efcdf90>)
1 found
Select Attributes: *Cancel*

Now I don't know what to say.....  :ugly:
Title: Re: How to select in attipedit with lisp
Post by: CADchup on September 21, 2007, 03:45:37 AM
The coordinate of gc10 needs to be trans'd to the current UCS:

Code: [Select]
(setq att (entlast))
(if (assoc 66 (entget att))
  (while (setq att (entnext att))
    (if (= (cdr (assoc 0 (entget att))) "ATTRIB")
      (vl-cmdf ".attipedit"
               (nentselp
                 (trans (cdr (assoc 10 (entget att)))
                        (cdr (assoc -1 (entget att)))
                        1
                        )
                 )
               )
      )
    )
  )

Next thing is: This depends on the current zoom factor and the size of PICKBOX. You might have to zoom to the block or even the attribute before running the code.


Markus
Title: Re: How to select in attipedit with lisp
Post by: Crank on September 21, 2007, 01:42:44 PM
Thanks Markus.
That works with normal blocks. The problem seems to be that my blocks are annotative.  :-(

I have some ideas how to pick a point that's exact on the text, but it will take some time before I find the right answer.
Title: Re: How to select in attipedit with lisp
Post by: ASMI on September 21, 2007, 03:33:53 PM
I havn't 2008 and ATTPEDIT. But what for you select attributes with NENTSELP function? Maybe:

Code: [Select]
(setq att(entlast))
(if (assoc 66 (entget att))
  (while (setq att (entnext att))
    (if (= (cdr (assoc 0 (entget att))) "ATTRIB")
      (vl-cmdf ".attipedit" att)
      )
    )
  )