I want a lisp routine that selects a block with attributes and ATTSYNC's all the blocks in the drawing with the same name.
Thanks,
Larry
Hi,
>> I want a lisp routine
Are that the correct words? This forum (for LISP, Customization, ...) is to support people when they have a problem while for example writing their lisp-code.
It's nothing like "I want ... send it to me" (and when I interpret your words a little bit more) .... "for free".
Sorry, - alfred -
(defun c:AtAll (/ blks a) (vl-load-com) (while (setq a (tblnext "BLOCK" (null a))) (if (= (cdr (Assoc 70 a)) 2) (vl-cmdf "_.AttSync" "Name" (cdr (assoc 2 a))) ) ) (princ) )
HTH
Thanks. i was looking for a routine that would ATTSYNC just the blocks with the same name as selected, not all the blocks in a drawing. I was able to revise your routine to do just that. Thanks again for pointing me in the right direction.
Larry
Is there an advantage to using
(vl-cmdf "_.AttSync" "Name" (cdr (assoc 2 a)))
and not
(command "_.Attsync" ....)
Or is it just to be consistent with VL?
@Shneuph wrote:Is there an advantage to using
(vl-cmdf "_.AttSync" "Name" (cdr (assoc 2 a)))
and not
(command "_.Attsync" ....)
Or is it just to be consistent with VL?
I normally use vl-cmdf everytime i'm using an argument to evaluate inside a command call, just in case the argument fails the program continues (not that it matters on this cae as variable a would have a definite value) think of it as an alternative error trapping.
Before the call to a native command, "vl-cmdf" evaluates the argument first, compared to "command" which runs the native command first vefore evaluating the variables
It is best explained on Autocad Help Dialog
The differences between command and vl-cmdf are easier to see if you enter the following calls at the AutoCAD Command prompt, rather than the VLISP Console prompt:
Command: (command "line" (getpoint "point?") '(0 0) "")
line Specify first point: point?
Specify next point or [Undo]:
Command: nil
Using command, the LINE command executes first; then the getpoint function is called.
Command: (VL-CMDF "line" (getpoint "point?") '(0 0) "")
point?line Specify first point:
Specify next point or [Undo]:
Command: T
HTH
@bdsmls wrote:Thanks. i was looking for a routine that would ATTSYNC just the blocks with the same name as selected, not all the blocks in a drawing. I was able to revise your routine to do just that. Thanks again for pointing me in the right direction.
Larry
Good for you Larry
One thing though, wont an ordinary call to Attsync accomplish the same thing? (selecting the block that is)
Makes me wonder why the need for lisp code really. i guess you want to select multiple blocks then.
Anyhoo.
Gald i could help
I expected people would wonder why i just didn't use ATTSYNC. I write commands to make it easier for the guys in the office to accomplish certain tasks. sad to say, most would not remember ATTSYNC to update blocks so it's usually easier to put together a task in a lisp routine and add it to our list of custom routines.
Larry
Understandable, when you're editing blocks often it's time saver to be able to run a custom command and just pick a block without having to go through all the ATTSYNC prompts anyway.
Hi from France
If you want to synchronize all attributes blocks with an unique command, you can use
ATTSYNC N (from Name) and type * for all blocks
Bye Hyppolight
Yoan AUBRY