Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Reply
Message 1 of 13
bdsmls
2826 Views, 12 Replies

ATTSYNC

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

12 REPLIES 12
Message 2 of 13
Alfred.NESWADBA
in reply to: bdsmls

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 -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 13
bdsmls
in reply to: bdsmls

just asking. sorry you feel that way. i should have said, i'm looking for..., not i want...

Message 4 of 13
pbejse
in reply to: bdsmls

(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

 

Message 5 of 13
bdsmls
in reply to: bdsmls

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

Message 6 of 13
Shneuph
in reply to: pbejse

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?

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
Message 7 of 13
pbejse
in reply to: Shneuph


@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

Message 8 of 13
pbejse
in reply to: bdsmls


@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

 

Message 9 of 13
bdsmls
in reply to: bdsmls

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

Message 10 of 13
Shneuph
in reply to: bdsmls

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.

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
Message 11 of 13
Anonymous
in reply to: Shneuph

(if (not Acet-Getvar) (vla-load AcetUtil.fas))
(acet-attsync "BLOCK NAME")

 

This code works for me.

Message 12 of 13
ivor.bach
in reply to: pbejse

I do love this lisp.

Message 13 of 13
Y.AUBRY
in reply to: bdsmls

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

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost