dirtlegg Posted April 3, 2009 Posted April 3, 2009 I am using Autocad 2002. This is concerning linetypes with text...re ---san--- or ---gas---. When I draw the line from right to left, the text is upside down. Is there an easy way to reverse this once the line is drawn rather than redrawing it from left to right? The lines in question are over 12000 feet long. Quote
Lee Mac Posted April 3, 2009 Posted April 3, 2009 Try this (others have probably already made LISPs similar, but this will work for lines) (defun c:revlin (/ lin) (if (and (setq lin (car (entsel "\nSelect Line to Reverse: "))) (eq "LINE" (cdadr (entget lin)))) (progn (command "_line" (cdr (assoc 11 (entget lin))) (cdr (assoc 10 (entget lin))) "")) (princ "\nNothing Selected - or this ain't no line! ")) (princ)) Quote
NaeKid Posted April 3, 2009 Posted April 3, 2009 I just flip the line around - click on the center, type Rotate, type in 180 .. hit enter. Flips the line for me every time. Quote
Lee Mac Posted April 3, 2009 Posted April 3, 2009 This will reverse Lines and *Polylines (defun c:revver (/ *error* varlst ovar ss eLst vLst Vert) (vl-load-com) (defun *error* (msg) (if ovar (mapcar 'setvar varlst ovar)) (princ (strcat "\nError: " (strcase msg))) (princ)) (setq varlst '("CLAYER" "CMDECHO" "OSMODE") ovar (mapcar 'getvar varlst)) (mapcar 'setvar (cdr varlst) '(0 0)) (if (setq ss (ssget (list (cons 0 "LINE,*POLYLINE") (if (getvar "CTAB")(cons 410 (getvar "CTAB")) (cons 67 (- 1 (getvar "TILEMODE"))))))) (progn (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) (setq eLst (entget ent)) (setvar "CLAYER" (cdr (assoc 8 eLst))) (cond ((eq "LINE" (cdadr eLst)) (command "_line" (cdr (assoc 11 eLst)) (cdr (assoc 10 eLst)) "")) ((eq "LWPOLYLINE" (cdadr eLst)) (setq vLst (reverse (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= 10 (car x))) eLst)))) (command "_pline") (mapcar 'command vLst) (command)) ((eq "POLYLINE" (cdadr eLst)) (setq Vert (entnext ent)) (while (not (eq "SEQEND" (cdadr (entget Vert)))) (setq vLst (cons (cdr (assoc 10 (entget Vert))) vLst))) (command "_3dpoly") (mapcar 'command vLst) (command))))) (princ "\n<!> No Line or *Polyline Selected <!>")) (mapcar 'setvar varlst ovar) (princ)) (I was bored ) Quote
uddfl Posted April 3, 2009 Posted April 3, 2009 ^ Just make it match the original object's linetype and then entdel it and it will be perfect. Quote
dirtlegg Posted April 3, 2009 Author Posted April 3, 2009 Not at all experienced at writing my own lisp routines, but this one works GREAT!! Thank you LEE MAC! Quote
Lee Mac Posted April 3, 2009 Posted April 3, 2009 ^ Just make it match the original object's linetype and then entdel it and it will be perfect. Haha - I'm so silly at times - of course, I completely forgot about the task at hand... I just focussed on reversing the line Quote
Lee Mac Posted April 3, 2009 Posted April 3, 2009 Not at all experienced at writing my own lisp routines, but this one works GREAT!! Thank you LEE MAC! Cheers, but as Uddfl says, it could be better Quote
Lee Mac Posted April 3, 2009 Posted April 3, 2009 Ok this is better, allows for lines that aren't set to linetype "bylayer", and deletes the original line. (defun c:revver (/ *error* varlst ovar ss eLst vLst Vert) (vl-load-com) (defun *error* (msg) (if ovar (mapcar 'setvar varlst ovar)) (princ (strcat "\nError: " (strcase msg))) (princ)) (setq varlst '("CLAYER" "CMDECHO" "OSMODE") ovar (mapcar 'getvar varlst)) (mapcar 'setvar (cdr varlst) '(0 0)) (if (setq ss (ssget (list (cons 0 "LINE,*POLYLINE") (if (getvar "CTAB")(cons 410 (getvar "CTAB")) (cons 67 (- 1 (getvar "TILEMODE"))))))) (progn (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) (setq eLst (entget ent)) (setvar "CLAYER" (cdr (assoc 8 eLst))) (cond ((eq "LINE" (cdadr eLst)) (command "_line" (cdr (assoc 11 eLst)) (cdr (assoc 10 eLst)) "")) ((eq "LWPOLYLINE" (cdadr eLst)) (setq vLst (reverse (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= 10 (car x))) eLst)))) (command "_pline") (mapcar 'command vLst) (command)) ((eq "POLYLINE" (cdadr eLst)) (setq Vert (entnext ent)) (while (not (eq "SEQEND" (cdadr (entget Vert)))) (setq vLst (cons (cdr (assoc 10 (entget Vert))) vLst) Vert (entnext Vert))) (command "_3dpoly") (mapcar 'command vLst) (command))) (if (assoc 6 eLst) (command "_chprop" (entlast) "" "_LT" (cdr (assoc 6 eLst)) "")) (entdel ent))) (princ "\n<!> No Line or *Polyline Selected <!>")) (mapcar 'setvar varlst ovar) (princ)) Quote
Tankman Posted April 4, 2009 Posted April 4, 2009 Haha - I'm so silly at times - of course, I completely forgot about the task at hand... I just focused on reversing the line And, that's why Lee Mac is so appreciated in the "pro" forums. Quote
Lee Mac Posted April 4, 2009 Posted April 4, 2009 And, that's why Lee Mac is so appreciated in the "pro" forums. , thanks Tankman Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.