Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

exsiting block increment

6 REPLIES 6
Reply
Message 1 of 7
Anonymous
846 Views, 6 Replies

exsiting block increment

i have a block with numeric text inside a circle, if i copy that existing block then the numeric should increment or decrement, can anyone help me, and also for normal text

6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: Anonymous

For Text: (defun c:mnum () (defun *error* (msg) (setvar "osmode" oldos) (setvar "orthomode" oldortho) (setvar "dimzin" olddimzin) (princ msg) (princ) );defun (setq oldos (getvar "osmode")) (setq oldortho (getvar "orthomode")) (setq olddimzin (getvar "dimzin")) (setvar "osmode" 512) (setvar "orthomode" 0) (setvar "dimzin" 1) (setq a (list 0 0)) (alert "\n After Finishing, Press ESC Key") (setq ht (getreal "\n Enter the Text Height")) (if (= nil ht) (progn (if (not (tblsearch "style" "MM_ARIAL")) (command "style" "MM_ARIAL" "verdana" ht "" "" "" "")) );progn );if (setq ini (getreal "\n Enter the Initial Value:")) (setq inc (getreal "\n Enter the Increment Value:")) ;(setq dec (getint "\n Enter the Number of Decimal Points")) (while (/= nil a) (setq po (getpoint "\n Pick the point for Insert the text")) (command "text" "j" "mc" po "0" (rtos ini 2 0)) (setq ini (+ ini inc)) );while (setvar "osmode" oldos) (setvar "orthomode" oldortho) (setvar "dimzin" olddimzin) );defun
Message 3 of 7
Anonymous
in reply to: Anonymous

I hope this attachment may be useful to you for Text increament
Message 4 of 7
pbejse
in reply to: Anonymous


@Anonymous wrote:

i have a block with numeric text inside a circle, if i copy that existing block then the numeric should increment or decrement, can anyone help me, and also for normal text


  • I assume you meant a Block with only one (1) attribute?
  • And by normal text you mean a TEXT/MTEXT enitiy and not inside a block?
  • Increment/Decrement  by 1?
  • The text value for new block will follow the source block (+/-)?

 

This code was written with the above conditions

 

(defun c:CopyIncrement (/ Block ent NumText Blk Symbol pt1 pt2 NewObj)
;;;	pbe July 2001	;;;
;;;			;;;
      (vl-load-com)
        (prompt "\rSelect Block/Text:")
        (cond
              ((and
      	(setq Block (ssget "_+.:S:L" '((0 . "INSERT,*TEXT"))))
        (setq Block (ssname Block 0))
      	(setq NumText
                   (if (and (eq (cdr (assoc 0
                                            (entget Block)))
                                "INSERT")
                            (setq Blk  (member '(66 . 1)
                                               (entget Block))))
                         (cdr (assoc 1 (entget (entnext Block))))
                         (cdr (assoc 1 (entget Block)))))
        (progn
	(if (not Symbol) (setq Symbol "+"))
	(initget  "+ -")
	(setq Symbol
		  (cond
		    ((getkword
		        (strcat "\nChoose [+/-]: <" Symbol ">: ")
		      )
		    )(Symbol))
		)
	)
	(setq ent (vlax-ename->vla-object Block))
	(setq pt1 (getpoint "\nPick Base Point:"))
	(while 
      	(setq pt2 (getpoint pt1 "\nNext Point"))
          	(vlax-invoke (setq NewObj (vla-copy ent)) 'Move pt1 pt2)
		(vla-put-textstring
		      (if (not Blk)
		            NewObj
		            (car (vlax-invoke NewObj 'GetAttributes))
		            )
		      (setq NumText
		                 (itoa ((eval (read (strcat "1" symbol)))
		                             (atoi Numtext)))))
        (setq pt1 pt2 ent NewObj)(princ (strcat "\nNext Number:\t " NumText))
              				)
        			)
               		)
              )
	(princ)
        )

 

 

So if the block \text has a value of "12", depending on the option (+/-) the value for the new block/text will follow the previous one. i.e. "13" "14" if + and "11" "10" for -

 

Hope this helps


 

Message 5 of 7
Kent1Cooper
in reply to: Anonymous

Search this Discussion Group, and I think you'll find several ways of doing those things.  For instance, for Attributes:

 

http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/copy-and-increment-attributes/td-p/12...

 

and for Text:

 

http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Copy-and-Increment-Text/m-p/840715/hi...

Kent Cooper, AIA
Message 6 of 7
3wood
in reply to: Anonymous

You can copy the block with attribute or the text first, then pick them in order and use ALTEXT to increase / decrease the number in the picking order.

Or use INNB to pick up the block with one attribute first, then insert it with increased number attribute.

 

3wood

CAD KITS

Message 7 of 7
stevor
in reply to: Anonymous

If these numbers are also used in some accounting process,

and you cannot easily count each occurrence,

then you can use ssget to get all the texts/attributes,

sort then, and find the next index value, and the duplicates and gaps.

S

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report