@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