Jump to content

Recommended Posts

Posted

Can a block be designed with an attribute that advances numerically each time it is apllied? I have hundreds of points that I must aplly a tag block to and each tag must be a different number. The only way I know so far is to insert each block, then go back and renumber each one by one. There has got to be a quicker way.

Posted

Thank you but I have no understanding of code writting and their apllication.

Posted

There's no way to do what you want with Autocad commands that I know of. For a quick tutorial on how to load and run a Lisp application, see here

http://www.cadtutor.net/faq/questions/28/How+do+I+use+an+AutoLISP+routine%3F

 

This code, by ASMI, from the previous link works well

(defun c:atnum (/ oldStart oldEcho oldSize oldBlock temBl *error*) 

 (defun *error* (msg) 
   (setvar "CMDECHO" oldEcho) 
   (princ) 
   ); end *error* 
 
 (if(not atnum:Size)(setq atnum:Size 1.0)) 
 (if(not atnum:Num)(setq atnum:Num 1)) 
 (setq  oldStart atnum:Num 
  oldSize atnum:Size  
  oldEcho(getvar "CMDECHO") 
  ); end setq 
 (setvar "CMDECHO" 0) 
 (setq atnum:Num 
   (getint 
     (strcat "\nSpecify start number <"(itoa atnum:Num)">: "))) 
 (if(null atnum:Num)(setq atnum:Num oldStart))
 (setq atnum:Size 
   (getreal 
     (strcat "\nSpecify block scale <"(rtos atnum:Size)">: "))) 
 (if(null atnum:Size)(setq atnum:Size oldSize))
 (if atnum:Block(setq oldBlock atnum:Block))
 (setq temBl
    (entsel(strcat "\nSelect block <"
        (if atnum:Block atnum:Block "not difined") "> > "))); end setq
 (cond
   ((and atnum:Block(not temBl)(tblsearch "BLOCK" atnum:Block))
   (setq atnum:Block oldBlock)
    ); end condition #1
   ((= 1(cdr(assoc 66(entget(car temBl)))))
   (setq atnum:Block(cdr(assoc 2(entget(car temBl)))))
   ); end condition #2
   (t
    (princ "\nBlock not contains attribute! ")
    (setq atnum:Block nil)
    ); end condition #3
   ); end cond
 (if atnum:Block
   (progn
     (princ "\n>>> Pick insertion point or press Esc to quit <<<\n ")
(while T  
 (command "-insert" atnum:Block "_s" atnum:Size pause "0"(itoa atnum:Num))
   (setq atnum:Num(1+ atnum:Num)) 
 ); end while
     ); end progn
   ); end if
 (princ) 
 ); end of c:atnum

Posted

This is close. The tutorial is the type of behavior I need. each time I aplly the block the number in the block increases by one. The Code listed above still requests that I input the attribute number each time.

  • 3 weeks later...
Posted

Try this one - I wrote it about 10 years ago to post process the Attributes (i.e. Insert all the Blocks you need and then change their Item Number). It also allows for a constant prefix - if you don't want a prefix, just hit enter at the prompt. It also will only do the numbers from 1 to 99 - if you want 3 digits (1 - 999) or more, let me know and I'll adjust it for you.

 

Note, There isn't any error trapping in this one - just a plain vanilla get the job done one... Start it with ITMINC command

 

(defun C:ITMINC ()

(setq olderr *error* *error* RSETVAR)

(SETVAR "CMDECHO" 0)

(setq prefix(getstring "Enter Prefix of Item No:"))

(setq prefix(strcase prefix))

(setq itnum(getint "Starting Item No :"))

(while (

(prompt "Select Attribute :")

(terpri)

(if (> 10 itnum) (setq infil "0") (setq infil ""))

(command "attedit" "Y" "*" "*" "*" pause "" "Value" "R" (prin1(strcat prefix infil (itoa itnum))) "")

(setq itnum (+ 1 itnum))

(terpri)

)

(setvar "cmdecho" 1)

(setq *error* olderr) ; Restore old *error* handler

(princ)

)

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...