Jump to content

Recommended Posts

Posted

I am new to the forum and have no experience with writing lisp routines. I have a routine that annotates a block using the block name as the label. What I would like to be able to do is modify this routine to annotate one of the block's attributes. The tag for the attribute is currently called "KEY" ,but I'm assuming this could be modified so that any attribute could be labeled.

 

If someone could help me with this I would be grateful.

 

(defun c:1 ()

 

(command "undo" "end" "undo" "begin")

 

(setvar "luprec" 0)

 

 

 

(setq ss (ssget

(list

'(0 . "INSERT")

)))

 

 

(setq bnum (sslength ss))

(setq ent (ssname ss 0))

 

(setq name (entget ent))

(setq bname (cdr (assoc 2 name)))

 

 

(setvar "orthomode" 0)

 

 

 

(setq a (rtos bnum ))

 

 

(setq b (strcat bname "(" a ")"))

 

 

(command "leader" pause pause "" b "")

 

(setvar "orthomode" 0)

 

 

(setvar "luprec" 2)

 

)

Posted

Could you explain in more detail I’m not really understanding what you want to accomplish.

Did you write the posted code?

 

Here is a break down on what the posted code does.

 

[font=Times New Roman][font=Times New Roman](defun c:1x ( / ss bnum ent bname a b );_need to locolize variables[/font]
[font=Times New Roman]; (command "undo" "end" "undo" "begin");_this is wrong it shound be[/font]
[font=Times New Roman]  (command "undo""begin");_this marks the beginning of a group to be undon if the undo command is involked[/font]
[font=Times New Roman](setvar "luprec" 0);_sets # of zeros after desimal point (this is not needed)[/font]
[font=Times New Roman];_prompts user to select a block[/font]
[font=Times New Roman](setq ss (ssget[/font]
[font=Times New Roman](list[/font]
[font=Times New Roman]'(0 . "INSERT")[/font]
[font=Times New Roman])))[/font]
[font=Times New Roman](setq bnum (sslength ss));_# of selected blocks in drawing[/font]
[font=Times New Roman](setq ent (ssname ss 0));_gets first item in the selection set[/font]
[font=Times New Roman](setq name (entget ent));_# gets block entity info[/font]
[font=Times New Roman](setq bname (cdr (assoc 2 name)));_gets block name[/font]
[font=Times New Roman](setvar "orthomode" 0);_turns ortho mode off[/font]
[font=Times New Roman](setq a (rtos bnum ));_# of selected blocks in the drawing[/font]
[font=Times New Roman](setq b (strcat bname "(" a ")"));_puts the block name and the # of occurences of that block together[/font]
[font=Times New Roman](command "leader" pause pause "" b "") ;_makse the leader with block anme and number of occurenced of that block in the drawing[/font]
[font=Times New Roman](setvar "orthomode" 0);_turns ortho mode off[/font]
[font=Times New Roman](setvar "luprec" 2);_sets # of zeros after desimal point (this is not needed)[/font]
[font=Times New Roman]  (command "undo" "end");_this marks the end of a group to be undon if the undo command is involked[/font]
[font=Times New Roman]  (princ)[/font]
[font=Times New Roman]);_defun[/font]
[/font]

Posted

John,

 

Thank you so much for your reply. It really helped me see what the different lines do. In response to your questions...

 

1) No I did not write the routine. A friend provided it to me. He got it from someone who got it from someone else. So I'm not surprised that there are irrelevant elements in this routine.

 

2) What I would like to be able to do is to modify this routine so that a leader is generated. The text of that leader would be the value of a block's specific attribute and not the value of a block's name.

 

Thanks

Posted
John,

 

Thank you so much for your reply. It really helped me see what the different lines do. In response to your questions...

 

1) No I did not write the routine. A friend provided it to me. He got it from someone who got it from someone else. So I'm not surprised that there are irrelevant elements in this routine.

 

2) What I would like to be able to do is to modify this routine so that a leader is generated. The text of that leader would be the value of a block's specific attribute and not the value of a block's name.

 

Thanks

 

Not sure about that what you exactly need

Give that a try

 

(defun c:11 ()

(command "undo" "end" "undo" "begin")
(setvar "luprec" 0)
(setvar "orthomode" 0)
(while 
(setq ent (nentsel "\nSelect arribute only (or press Enter to Exit) >>"))
(setq en (car ent)
     elist (entget en)
     attvalue (cdr (assoc 1 elist))
     pt (cadr ent)
     )
(command "leader" pt pause "" attvalue "") 
)
(setvar "orthomode" 0)
(setvar "luprec" 2)
(command "undo" "end")
)

 

~'J'~

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...