exsiting block increment

Anonymous

exsiting block increment

Anonymous
Not applicable

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

0 Likes
Reply
857 Views
6 Replies
Replies (6)

Anonymous
Not applicable
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
0 Likes

Anonymous
Not applicable
I hope this attachment may be useful to you for Text increament
0 Likes

pbejse
Mentor
Mentor

@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


 

0 Likes

Kent1Cooper
Consultant
Consultant

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
0 Likes

3wood
Advisor
Advisor

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

0 Likes

stevor
Collaborator
Collaborator

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
0 Likes