Jump to content

Recommended Posts

Posted

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.

Posted

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))
   

Posted

I just flip the line around - click on the center, type Rotate, type in 180 .. hit enter. Flips the line for me every time.

Posted

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 :P )

Posted

^ Just make it match the original object's linetype and then entdel it and it will be perfect.

Posted

Not at all experienced at writing my own lisp routines, but this one works GREAT!! Thank you LEE MAC!

Posted
^ 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 :)

Posted
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 :thumbsup:

Posted

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))

Posted
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.

Posted
And, that's why Lee Mac is so appreciated in the "pro" forums.

 

:D, thanks Tankman :)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...