TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started 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:
(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?
-
ATTIPEDIT ?
is that a new command in A2008?
-
Yes, it's a command to edit an atrribute in place.
-
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.
-
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.
-
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.
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
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:
-
The coordinate of gc10 needs to be trans'd to the current UCS:
(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
-
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.
-
I havn't 2008 and ATTPEDIT. But what for you select attributes with NENTSELP function? Maybe:
(setq att(entlast))
(if (assoc 66 (entget att))
(while (setq att (entnext att))
(if (= (cdr (assoc 0 (entget att))) "ATTRIB")
(vl-cmdf ".attipedit" att)
)
)
)