; offset increment numbering with change direction - 2023.04.28 exceeds
(vl-load-com)
(defun c:WCOPY ( / ss util en ent alignpt obj originalnum basept ang deg dist rotateold rotateinput rotatememory newnewobj ss2 en2 ent2 alignpt2 counter)
(sssetfirst nil)
(setvar "cmdecho" 0)
(setq counter 0)
;error control
(defun *error* ( msg )
(if (>= counter 1)
(progn
(setq alignpt2 (cdr (assoc 11 (entget (entlast)))))
(if (= alignpt alignpt2)
(progn
(vla-delete newnewobj)
(princ "\n Temporary Object Deleted.")
)
)
);end of progn
);end of if
(if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
(princ (strcat "\n Error: " msg))
)
(setvar 'cmdecho 1)
(princ)
)
(setq util (vla-get-utility (vla-get-activedocument (vlax-get-acad-object))))
(setq ss (ssadd))
(princ "\n Select Original Number (Text) : ")
(if (setq ss (ssget '((0 . "TEXT"))))
(if (= (sslength ss) 1)
(progn
(setq en (ssname ss 0))
(setq ent (entget en))
(setq alignpt (cdr (assoc 11 ent)))
(setq obj (vlax-ename->vla-object en))
(setq originalnum (atoi (vl-princ-to-string (vlax-get-property obj 'TextString))))
(setq basept (getpoint "\n Pick Base Point : "))
(setq ang (angle basept alignpt))
(setq deg (* 180.0 (/ ang pi)))
(setq dist (distance basept alignpt))
(cond
((or (<= 315 deg) (< deg 45))
(setq rotateold "D")
(princ "\n Direction : Right")
)
((and (<= 45 deg) (< deg 135))
(setq rotateold "W")
(princ "\n Direction : Up")
)
((and (<= 135 deg) (< deg 225))
(setq rotateold "A")
(princ "\n Direction : Left")
)
((and (<= 225 deg) (< deg 315))
(setq rotateold "S")
(princ "\n Direction : Down")
)
)
(command "_tjust" ss "" "mc")
(while (= 1 1)
(setq rotateinput (strcase (getstring "\n Change Direction? Up(W), Down(S), Left(A), Right(D), Keep Previous Direction(SpaceBar)")))
(if (= rotateinput "")
(if (= rotatememory "")
(progn
(setq rotateinput rotateold)
)
(progn
(setq rotateinput rotatememory)
)
)
(progn)
)
(princ "\n Direction : ")
(princ rotateinput)
(cond
((= rotateinput "W")
(princ "Up(W) Selected.")
(cond
((= rotateold "D")
(setq newdeg (+ deg 90))
)
((= rotateold "W")
(setq newdeg deg)
)
((= rotateold "A")
(setq newdeg (- deg 90))
)
((= rotateold "S")
(setq newdeg (+ deg 180))
)
(t
(setq newdeg deg)
)
)
)
((= rotateinput "A")
(princ "Left(A) Selected.")
(cond
((= rotateold "D")
(setq newdeg (+ deg 180))
)
((= rotateold "W")
(setq newdeg (+ deg 90))
)
((= rotateold "A")
(setq newdeg deg)
)
((= rotateold "S")
(setq newdeg (- deg 90))
)
(t
(setq newdeg deg)
)
)
)
((= rotateinput "S")
(princ "Down(S) Selected.")
(cond
((= rotateold "D")
(setq newdeg (- deg 90))
)
((= rotateold "W")
(setq newdeg (+ deg 180))
)
((= rotateold "A")
(setq newdeg (+ deg 90))
)
((= rotateold "S")
(setq newdeg deg)
)
(t
(setq newdeg deg)
)
)
)
((= rotateinput "D")
(princ "Right(D) Selected.")
(cond
((= rotateold "D")
(setq newdeg deg)
)
((= rotateold "W")
(setq newdeg (- deg 90))
)
((= rotateold "A")
(setq newdeg (+ deg 180))
)
((= rotateold "S")
(setq newdeg (+ deg 90))
)
(t
(setq newdeg deg)
)
)
)
(t
(setq newdeg deg)
)
)
(setq ang (* pi (/ (+ newdeg 180) 180)))
;(princ ang)
(setq basept (polar alignpt ang dist))
;(princ basept)
(setq newnewobj (vla-copy obj))
(setq counter (+ counter 1))
(setq ss2 nil)
(setq ss2 (ssadd))
(setq en2 (vlax-vla-object->ename newnewobj))
(ssadd en2 ss2)
(vlax-put-property newnewobj 'TextString (+ originalnum 1))
(setq ent2 (entget en2))
(command "_move" ss2 "" basept pause)
;(command "_pasteclip" pause)
(setq originalnum (+ originalnum 1))
(setq rotatememory rotateinput)
);end of while
)
(progn
(princ "\n Select 1 Text Only.")
(c:WCOPY)
)
)
)
(setvar "cmdecho" 1)
(princ)
)
Long time no see.
this uses command instead of grread.
because I want to be able to see the preview & using osnap. Move Command is easy way for me.
Command : WCOPY
1. Select 1 Text (Number)
2. Pick Base Point
3. lisp check your Direction
4. Select Direction - Press W/A/S/D or SpaceBar
5. Pick Target Point