Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

i need a lisp to automaticlly add value to existing attribute in all blocks

8 REPLIES 8
Reply
Message 1 of 9
armati
652 Views, 8 Replies

i need a lisp to automaticlly add value to existing attribute in all blocks

hey im using autocad 2013 and i have 2000 blocks called Drain_bore

and they have BORE_NUMBER attribute for example:
720/1/
719/1/

687/1/

 

while the first 3 digits represent area code and the next digit represent item code

i need a lisp that would automaticlly number all the blocks in my drawing without changing the existing attribute for example:

720/1/1

720/1/2

720/1/3

719/1/1

719/1/2

687/1/1

687/1/2

 

so basiclly just adding a number in incrementals of +1 after the actual value

please help

 

8 REPLIES 8
Message 2 of 9
3wood
in reply to: armati

Let's say you have 3 off 720/1, then which one is 702/1/1?

Message 3 of 9
artur_isa
in reply to: 3wood

usually the blocks are always connected (working with water infrastructures) 
so i would prefer if i choose the first block and it will automaticlly continue from there like this:

(zero is a manhole and ------- is a connecting line)

0----------------------------0-------------------------0

720/1/1               720/1/2            720/1/3

 

 

most of the times i will have something like this

 

0    540/1/1         0 530/1/1                                                                                                  0 721/1/3

|                           |                                                                                                                |

|                           |                                                                                                                |

|                           |                                                                                                                |

0-------------------------0--------------------------------0                                             0------------------------------0------------------0

| 720/1/1            720/1/2                     720/1/3                                     721/1/1                   721/1/2          721/1/4

|

|

|

0  540/1/2

 

Message 4 of 9
3wood
in reply to: artur_isa

It looks there is not much logical rule for the number sequence. The numbers follow the pipe line network.

Message 5 of 9
Ajilal.Vijayan
in reply to: artur_isa

Can you post a sample drawing or part of that drawing to check ?

Message 6 of 9
artur_isa
in reply to: Ajilal.Vijayan

gave an example of street 413

 

 

xxxx/yy/zz

 

xxxx-street code (e.g. 413)

yy- accessory code (0 means manhole)

zz-id number so we can individualize them in data extraction

 

possible?

Message 7 of 9
Ajilal.Vijayan
in reply to: artur_isa

Please ignore if you already tried this.

 

A quick thing in mind is ...have you considered ATTOUT and ATTIN commands from Express tools ?

ATTOUT will give you an output as attached and edit the Manhole name using excel and use ATTIN to bring back the changes in the drawing.

Message 8 of 9
artur_isa
in reply to: Ajilal.Vijayan

yes i know but the numbering must go in series like first manhole and then the second manhole connected to it on same street

and in excel its pretty random..

Message 9 of 9
Ajilal.Vijayan
in reply to: artur_isa

Yes if you ATTOUT, have to sort the manhole names in excel or have to select in order from AutoCAD.

 

Also try this lisp routine.

Spoiler
(vl-load-com)
(defun C:ADDIN ( / base_MH eNAME base_name eNAME EOBJ st_code item_code num tn Sl_Ln)
(setq base_MH (entsel "\nSelect the Base Manhole:"))
(setq base_name nil)
(setq eNAME (car base_MH))
   (setq EOBJ (vlax-ename->vla-object eNAME))
   (if (= (vla-get-hasattributes EOBJ) :vlax-true)
 	(progn
 	  (foreach N (vlax-safearray->list
 		   (variant-value (vla-getattributes EOBJ)))
	    
	    (if (= (vla-get-tagstring N) "BORE_NUMBER")
	      (setq base_name (vla-get-textstring N))
             )	    
);for each
	  );progn
	  
	  (progn
(alert "No attributes found for this block\n")
     (exit)
	 );progn
     );if

(if base_name
(progn
(setq st_code (substr base_name 1 3));street code
(setq item_code (substr base_name 5 1));item code
(setq num 1);increment

(princ "\nSelect the continous Manholes")
(setq Slctn (SSGET ))
(setq Sl_Ln (sslength Slctn))

(setq tn 0)
(repeat Sl_Ln
(setq Obj (ssname Slctn tn))
(setq EOBJ (vlax-ename->vla-object Obj))
(if (= (vla-get-hasattributes EOBJ) :vlax-true)
 	(progn
 	  (foreach N (vlax-safearray->list
 		   (variant-value
 			 (vla-getattributes EOBJ)
 		   )
 		 )
	    (if (= (vla-get-tagstring N) "BORE_NUMBER")
	      (vla-put-textstring N (strcat st_code "/" item_code "/" (itoa num)))
             )
	    
);for each
	  );progn
     );if
(setq tn ( + tn 1))
(setq num ( + num 1))

);repeat



);progn
);if
  );defun

	
  

 

You have to select the First Manhole text and the subsequnet manhole text in order.

 

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

Post to forums  

Autodesk Design & Make Report

”Boost