I need a LISP solution to sequentially number attributes

I need a LISP solution to sequentially number attributes

Anonymous
Not applicable
978 Views
4 Replies
Message 1 of 5

I need a LISP solution to sequentially number attributes

Anonymous
Not applicable

I've attached a sample DWG that I need a solution for it, I've more than 200 layouts that all of them have my own template with attributes text, however I need a routine to change my numbers to be sequentially without changing it one by one. for example in the attached file I've DWG_NO which is WWE-01 for all the layouts. I want the number to be sequentially for all layouts without selecting the template and change each one. note that template is a block. thanks in advance

0 Likes
Accepted solutions (1)
979 Views
4 Replies
Replies (4)
Message 2 of 5

Moshe-A
Mentor
Mentor

@Anonymous hi,

 

if attribute DWG_NO should have the layout name then it could be solved with FIELD (no lisp is needed)

 

moshe

 

0 Likes
Message 3 of 5

dbhunia
Advisor
Advisor
Accepted solution

@Anonymous wrote:

I've attached a sample DWG that I need a solution for it, I've more than 200 layouts that all of them have my own template with attributes text, however I need a routine to change my numbers to be sequentially without changing it one by one. for example in the attached file I've DWG_NO which is WWE-01 for all the layouts. I want the number to be sequentially for all layouts without selecting the template and change each one. note that template is a block. thanks in advance


 

Try this......(For this Particular Block "AWD_TB_11x17" with the particular Tag Name "DWG_NO" in any drawing)

 

(defun C:tabnumber (/ layt_lst lay_list blk_name tag_name layoutname);;Put temp variables
(vl-load-com)
(setq blk_name "AWD_TB_11x17"
      tag_name "DWG_NO"
      l -1
      tab (getvar 'CTAB)
)
(vlax-for layt (vla-get-layouts (vla-get-ActiveDocument (vlax-get-acad-object)))
	(if (> (vla-get-TabOrder layt) 0)
	    (setq layt_lst (cons (cons (vla-get-TabOrder layt) (vla-get-Name layt)) layt_lst))
	)
)
(setq layt_lst (vl-sort layt_lst '(lambda (x y) (< (car x) (car y)))))
(foreach layt layt_lst
   (setq layoutname (cons (cdr layt) layoutname))
)
(setq lay_list (reverse layoutname))
(repeat (length lay_list)
  (setq lay_name (nth (setq l (+ l 1)) lay_list))
  (setvar 'CTAB lay_name)
  (setq ss (ssget "_A" (list '(0 . "INSERT")(cons 2 blk_name)(cons 410 lay_name))))
    (repeat (setq NOS (sslength ss))
	  (vlax-for blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
	    (if (= (vla-get-Name blk) blk_name)
		(progn
		(setq obj (vlax-ename->vla-object (ssname SS (setq NOS (- NOS 1)))))
			(foreach att (vlax-invoke Obj 'GetAttributes)
			  (if (= (vla-get-Tagstring att) tag_name)
			      (progn
				(vla-put-textstring att lay_name)
			      )
			  )
			)
		)
	     )
	   )
    )
)
(setvar 'CTAB tab)
(princ)
)

 


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 4 of 5

Anonymous
Not applicable

@Moshe-A I have no idea how field works, please explain to me if it possible, thanks

0 Likes
Message 5 of 5

Anonymous
Not applicable

@dbhunia thanks sir it worked perfectly

0 Likes