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
@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
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
Search this Discussion Group, and I think you'll find several ways of doing those things. For instance, for Attributes:
and for Text:
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.
Can't find what you're looking for? Ask the community or share your knowledge.