AUTOMATIC NUMBERING

AUTOMATIC NUMBERING

muhamed_ragab92
Enthusiast Enthusiast
2,000 Views
15 Replies
Message 1 of 16

AUTOMATIC NUMBERING

muhamed_ragab92
Enthusiast
Enthusiast

how can i number the attribute blocks as in image - i want to increment variable x from 1 and by 1 , can i find lisp make it

0 Likes
Accepted solutions (1)
2,001 Views
15 Replies
Replies (15)
Message 2 of 16

Anonymous
Not applicable
0 Likes
Message 3 of 16

_gile
Consultant
Consultant

Hi,

 

You can also use the Increment plugin. This is not LISP but it allows to increment an attribute while inserting blocks or increment attributes of already inserted blocks by selecting them one by one or accordin to X and Y axis for a selection.

 

The above screencast shows the French version working which is identical to the English one.

 

 

 

Screencast will be displayed here after you click Post.

f6a86b2f-7014-48c5-a60d-a9bc1fbe317e

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 4 of 16

muhamed_ragab92
Enthusiast
Enthusiast

can you tell me how it work because i loaded it and cant use it

Message 5 of 16

muhamed_ragab92
Enthusiast
Enthusiast

can you explain me how it work in my case ?

0 Likes
Message 6 of 16

Anonymous
Not applicable

@muhamed_ragab92 wrote:

can you tell me how it work because i loaded it and cant use it


Open the program in Notepad and follow the instructions below:

Capturar.JPG

0 Likes
Message 7 of 16

_gile
Consultant
Consultant

If the blocks are already inserted (as in the provided picture), after having set the start value, you can:

  • choose the "Selection" tab > check the "Block" check box > choose the block name in the drop down list > choose the attribute tag in the drop down list > select the blocks one by one so that each selection incements the attribute value ;
  • choose the "Auto" tab > check the "Block" radio button > choose the block name in the drop down list > choose the attribute tag in the drop down list > choose the incrementation order > select the blocks.

 

All this is described in the screencast (at 1:58 for "Selection" mode and at 3:15 for "Auto" mode)



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 8 of 16

muhamed_ragab92
Enthusiast
Enthusiast

this method is acceptable with one block but  i want several of another blocks with same attribute as example FAX/L1 and make X variable to increment from 1 by 1

 

0 Likes
Message 9 of 16

muhamed_ragab92
Enthusiast
Enthusiast

THANKS It's worked but with one type of block , can i use it with many blocks with same attribute

 

0 Likes
Message 10 of 16

_gile
Consultant
Consultant

Sorry, but the program was designed to work with one block at a time.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 11 of 16

Anonymous
Not applicable

@muhamed_ragab92 You can try this:

(defun c:Demo (/ pre post i j ss1 dat ent etdata found)
 (if (and
       (/= (setq pre (getstring "\nPrefix: ")) "")
       (not (initget (+ 2 4)))
       (setq post (getint "\nNumber: "))
     )
  (progn
   (setq j 0) 
   (while (setq ss1 (ssget '((0 . "insert")(66 . 1))))
    (setq i -1)
    (repeat (sslength ss1) 
     (setq i (1+ i))
     (setq dat (strcat pre (itoa (+ post j)))
	   ent (ssname ss1 i) j (1+ j) found nil)
      
     (while (and (setq ent (entnext ent)) (not found))
      (setq etdata (entget ent))
      (if (and
	   (eq (cdr (assoc 0 etdata)) "ATTRIB")
	   (eq (strcase (cdr (assoc 2 etdata))) "TEST")
	  )
       (progn
        (entmod (subst (cons 1 dat) (assoc 1 etdata) etdata))
        (entupd ent)
        (setq found t)
       ); progn
      ); if
     ); inner while
    ); repeat
   ); outer while
  ); progn
 ); if
 (princ)
)

FAX_L.gif

0 Likes
Message 12 of 16

muhamed_ragab92
Enthusiast
Enthusiast

are you sure it work , i try it but not working with me and its not the same in picture , increment number not show

0 Likes
Message 13 of 16

Anonymous
Not applicable

@Anonymous wrote:

@muhamed_ragab92 You can try this:

(defun c:Demo (/ pre post i j ss1 dat ent etdata found)
 (if (and
       (/= (setq pre (getstring "\nPrefix: ")) "")
       (not (initget (+ 2 4)))
       (setq post (getint "\nNumber: "))
     )
  (progn
   (setq j 0) 
   (while (setq ss1 (ssget '((0 . "insert")(66 . 1))))
    (setq i -1)
    (repeat (sslength ss1) 
     (setq i (1+ i))
     (setq dat (strcat pre (itoa (+ post j)))
	   ent (ssname ss1 i) j (1+ j) found nil)
      
     (while (and (setq ent (entnext ent)) (not found))
      (setq etdata (entget ent))
      (if (and
	   (eq (cdr (assoc 0 etdata)) "ATTRIB")
	   (eq (strcase (cdr (assoc 2 etdata))) "TEST")
	  )
       (progn
        (entmod (subst (cons 1 dat) (assoc 1 etdata) etdata))
        (entupd ent)
        (setq found t)
       ); progn
      ); if
     ); inner while
    ); repeat
   ); outer while
  ); progn
 ); if
 (princ)
)

 


@muhamed_ragab92 Sorry!
replace pink text with your TAG name.

0 Likes
Message 14 of 16

muhamed_ragab92
Enthusiast
Enthusiast

can you add suffix in this script ?

0 Likes
Message 15 of 16

Anonymous
Not applicable
Accepted solution

@muhamed_ragab92 Something like ?

(defun c:Demo (/ pre post i j ss1 dat ent etdata found)
 (if (and
       (/= (setq pre (getstring "\nPrefix: ")) "")
       (/= (setq suf (getstring "\nSuffix: ")) "")
       (not (initget (+ 2 4)))
       (setq post (getint "\nNumber: "))
     )
  (progn
   (setq j 0) 
   (while (setq ss1 (ssget '((0 . "insert")(66 . 1))))
    (setq i -1)
    (repeat (sslength ss1) 
     (setq i (1+ i))
     (setq dat (strcat pre (itoa (+ post j)) suf)
	   ent (ssname ss1 i) j (1+ j) found nil)  
     (while (and (setq ent (entnext ent)) (not found))
      (setq etdata (entget ent))
      (if (and
	   (eq (cdr (assoc 0 etdata)) "ATTRIB")
	   (eq (strcase (cdr (assoc 2 etdata))) "TEST")
	  )
       (progn
        (entmod (subst (cons 1 dat) (assoc 1 etdata) etdata))
        (entupd ent)
        (setq found t)
       ); progn
      ); if
     ); inner while
    ); repeat
   ); outer while
  ); progn
 ); if
 (princ)
)

"Accept as Solution" if it has solved the problem.

0 Likes
Message 16 of 16

muhamed_ragab92
Enthusiast
Enthusiast

Thanks so much , its worked with me after i edit the name attribute "test"