Author Topic: Reversing Polylines  (Read 7770 times)

0 Members and 1 Guest are viewing this topic.

NoLisper

  • Guest
Reversing Polylines
« on: March 19, 2004, 12:28:04 PM »
I'm looking for a lisp routine for
  reversing polylines (lights & heavies).
  Any help will be much appreciated.

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9248
Reversing Polylines
« Reply #1 on: March 19, 2004, 12:52:06 PM »
...i hate it when people double post questions.
“Common sense is not so common.” ~Voltaire

--> Donate to TheSwamp.org <--

NoLisper

  • Guest
Reversing Polylines
« Reply #2 on: March 19, 2004, 07:01:12 PM »
Se7en

  My apology, I didn't know this forum is
  also similar to A....k. Comments like that
  what you posted are common there.

  All the nice words I've heard about this
  forum seems useless anyway. Sorry for
  bothering you guys (I didn't know that
  this is also CADalog.com forum).

Mark

  • Custom Title
  • Seagull
  • Posts: 28683
Reversing Polylines
« Reply #3 on: March 19, 2004, 07:17:19 PM »
- NoLisper
Pay no attention to him, he's just cranky coz it's still freezing up there in snowbird land.
TheSwamp.org  (serving the CAD community since 2003)

CADaver

  • Guest
Reversing Polylines
« Reply #4 on: March 19, 2004, 08:59:19 PM »
Wait a minute, let's talk about this.  NoLisper here, posts the same question in several places, and doesn't see a problem as long as he gets his answer.  But it's a royal pain in the butt to spend some time answering a question in one thread, only to find that se7en has answered it in a another.  But it's okay I've wasted my time as long as NoLisper gets his answer.  It'd be different if his question went un-answered on one forum, but that rarely happens.  Then he has the balls to take shots at the very guys he wants to donate their time to solve his problems.  putz.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16717
  • Superior Stupidity at its best
Reversing Polylines
« Reply #5 on: March 19, 2004, 09:38:18 PM »
I would concur with CADaver to a point, however, those of us who regularly visit several web site forums are likely to see double or even triple posts. Multiple posts of the same question in the same forum realm is unacceptable.....

To make this point in NoLisper's favor, I would say that it is indeed preferable to post on many different sites to get the broadest and most complete answer to a question. Now, lets look at the facts here....

The original post was made at EST 12:25pm at the other place....
Follow up post was made here at EST 12:28pm

The question was answered at EST 12:50pm at the other place....
Obviously someone at the other place answered the question first.

He did no different than I or anyone else in need of help would have done....I just would not have been as impatient about it....
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9248
Reversing Polylines
« Reply #6 on: March 19, 2004, 10:05:00 PM »
NoLisper, You are no dummy. you and i both know that. Im not putting you down in any way. (I have no beef with you at all!) I just thought it was odd that you --who i know is smarter then the avg. poster-- would do something that seemed ...odd
“Common sense is not so common.” ~Voltaire

--> Donate to TheSwamp.org <--

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9248
Reversing Polylines
« Reply #7 on: March 19, 2004, 10:09:09 PM »
BTW, if you want NoLisper we can Chat. Got irc? if not go here: http://theswamp.org/phpBB2/viewtopic.php?p=12885#12885
“Common sense is not so common.” ~Voltaire

--> Donate to TheSwamp.org <--

NoLisper

  • Guest
Reversing Polylines
« Reply #8 on: March 20, 2004, 12:33:47 AM »
My apologies again for my double post.
   I am not aware that this forum is an
   extension of Cadalog forum. I am not
   forcing those who have posted a response
   to spend their precious time on answering
   my question.

  As for you CADaver, I thought you're an
  intelligent and professional person but your
  rudeness somewhat belies that fact. If you
  don't want to answer, you have all the option
  to do so.

  Again thanks everyone for your help.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16717
  • Superior Stupidity at its best
Reversing Polylines
« Reply #9 on: March 20, 2004, 08:15:12 AM »
Quote from: NoLisper
My apologies again for my double post.

Think no more of it....you posted on two distinctly different forums...

Quote from: NoLisper
I am not aware that this forum is an extension of Cadalog forum.
It is indeed NOT an extension of Cadalog, rather another forum with the same like minded people that visit Cadalog. The names are the same but the forum is completely different.

Quote from: NoLisper
I am not forcing those who have posted a response to spend their precious time on answering my question.

Indeed you are not, it would not be possible anyway.

Quote from: NoLisper
As for you CADaver, I thought you're an intelligent and professional person but your rudeness somewhat belies that fact. If you don't want to answer, you have all the option to do so.

Don't put too much thought into it...As you will soon find out, (if you visit on a regular basis) we all at some point have grated on someone elses nerves. It is what makes us unique. We can speak our mind without fear of pissing other people off... at least not permanently...I would caution you though..if you cannot take being called names, being made fun of, or if your feelings are easily hurt (kinda like ol' Dent). Then perhaps this is not the place for you to be. As an open community of like minded people we always welcome new victims to punish...you would indeed be no different. It is what makes us unique. I would suggest though, that you make an effort to register on either or both of these sites and become a regular contributor to "give back" some of the help you have received.

Quote from: NoLisper
Again thanks everyone for your help.

Not that we did anything... at least not here....
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

CADaver

  • Guest
Reversing Polylines
« Reply #10 on: March 20, 2004, 12:25:25 PM »
Quote from: NoLisper
 As for you CADaver, I thought you're an
  intelligent and professional person but your
  rudeness somewhat belies that fact. .


"MY" rudeness??

Quote from: NoLisper
All the nice words I've heard about this forum seems useless anyway.


I guess answering a shot like that is rude.  Okay, I'm rude.

CADaver

  • Guest
Reversing Polylines
« Reply #11 on: March 20, 2004, 12:33:08 PM »
To be honest, I don't have any trouble with posting the same question on several sites.  There are different posters who answer questions at different times, each with a different viewpoint.  My only problem, is with someone bashing an entire site because he didn't like a response, especially a site from which he wants help.  If you have a beef, take it up with the poster, not the site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10362
Reversing Polylines
« Reply #12 on: March 20, 2004, 06:05:15 PM »
Just to see if I could do it, here is my attempt at reversing a LWpolyline.
I took a differant approach that of Tee Square Graphics.
In there version all width information was lost so I decided to reverse the
vertex list and update the entity.

More testing is required to make sure it works in all cases. :)

PS I am clewless as to what the 210 code extrusion direction does
PSPS  Perhaps one of the heavy hitters here will add the code for
old style polylines.

** Edited to work with open lwplines

Code: [Select]
;;;           Polyline Reverse        
;;;      plr.lsp by Charles Alan Butler
;;;            Copyright 2004          
;;;  by Precision Drafting & Design All Rights Reserved.
;;;  Contact at ab2draft@TampaBay.rr.com
;;;
;;;   Version Alpha 0.2 March 20,2004
;;;
;;;   THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED
;;;   WARRANTY.  ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR
;;;   PURPOSE AND OF MERCHANTABILITY ARE HEREBY DISCLAIMED.
;;;                                                                    ;
;;;  You are hereby granted permission to use, copy and modify this    ;
;;;  software without charge, provided you do so exclusively for       ;
;;;  your own use or for use by others in your organization in the     ;
;;;  performance of their normal duties, and provided further that     ;
;;;  the above copyright notice appears in all copies and both that    ;
;;;  copyright notice and the limited warranty and restricted rights   ;
;;;  notice below appear in all supporting documentation.              ;
;;;
(defun c:plr (/ elst vlst newlst new-vlst code42 code210
              obj nam pair clo)
  (command "_.undo" "_be")
  (while (null (setq en1 (entsel "\nPick an object to reverse: "))))
  (setq nam  (car en1)
        elst (entget nam)
        obj  (cdr (assoc 0 elst))
        clo  (= 1 (logand 1 (cdr (assoc 70 (entget nam)))))
  )
  (cond
    ((= obj "LWPOLYLINE")
     (setq new-vlst (list (assoc 10 elst))) ; start point
     (while (setq pair (car elst))
       (cond
         ((= (car pair) 10) ; vertex
          ;; collect vertex list
          (while (member (caar elst) '(10 40 41 42))
            (setq vlst (cons (car elst) vlst)
                  elst (cdr elst))
          ) ; end while
         )
         ((= (car pair) 210) ; extru direction??
          (setq code210 pair
                elst    (cdr elst))
         )
         ((setq newlst (cons pair newlst)
                elst   (cdr elst))
         )
       ) ; end cond stmt
     ) ; end while
     ;;  newlst= entlist less vertex list
     ;;  vlst= vertex list
     (while vlst ;  reverse vertex list
       (if (= (car (setq pair (car vlst))) 42) ; bulge
         ;; reverse the bulge
         (setq code42 (cons 42 (* (cdr pair) -1))
               vlst   (cdr vlst))
       )
       (if (= (car (setq pair (car vlst))) 41)
         ;; reverse the width position
         (setq vlst     (cdr vlst)
               new-vlst (cons (cons 40 (cdr pair)) new-vlst)
               new-vlst (cons (cons 41 (cdr (car vlst))) new-vlst)
               vlst     (cdr vlst))
       )
       (if code42 ; add bulge back to list
         (setq new-vlst (cons code42 new-vlst)
               code42   nil)
       )
       (if (= (car (setq pair (car vlst))) 10)
         (setq new-vlst (cons pair new-vlst)
               vlst     (cdr vlst))
       )
     ) ; end while
     (if clo ; closed pline
       (setq new-vlst (cdr new-vlst)) ; remove the start pt
       (setq new-vlst (reverse(cdr (reverse new-vlst))))
     )
     ;;  new-vlst contains the reverse vertex list
     (setq newlst (append new-vlst newlst))
     (if code210
       (setq newlst (append (list code210) newlst))
     )
     (entmod (reverse newlst))
     (entupd nam) ; Regenerates the polyline entity
    )
    ((= obj "POLYLINE")
     (prompt "\nNot yet working... Old Style Polyline."))
    ((prompt "\nObject selected is not a polyline"))
  ) ; end cond stmt
  (princ)
) ; end defun
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9248
Reversing Polylines
« Reply #13 on: March 20, 2004, 08:47:34 PM »
Let the facts speak for them selves...

"He" hasent responded to any questions anyone has asked of "him".

"He" hasent taken the five min. to join us. (Our comunity.)

"He" has only slamed other members of our comunity. (If someone comes in and slams a member of our comunity im gonna want to smoke 'em so bad I can harldy contain myself. ...In fact this is the fouth post ive typed. Each gets a bit nicer so im just gonna end this now before I get to mad.)

BTW, Look what I found:

Code: [Select]
;  Subject:      Re: invert the direction of a polyline
;  From:         vnestr@netvision.net.il (Vladimir Nesterovsky)
;  Date:         1997/03/01
;  Newsgroups:   comp.cad.autocad
;
;  Try this:

   ;; This is (C.) by Vladimir Nesterovsky, 1997
   ;; e-mail: vnestr@netvision.net.il
   ;; YOU MAY USE THIS CODE ONLY FOR *NON-COMMERCIAL*
   ;; PURPOSES AND ONLY IF YOU RETAIN
   ;; THIS HEADER COMPLETE AND UNALTERED
   ;; you must contact me if you want to use it commercially
   (defun c:invpl( )
    (r-ss-foreach
      (ssget '((0 . "POLYLINE")))
      'inv-pl)
    (princ"\nInverted!")
    (princ))

   ;; repeat (foo e-name) for each e-name in SelSet
   ;; in reversed order
   (defun r-ss-foreach ( ss qfoo / n )
    (if (= 'PICKSET (type ss))
     (repeat (setq n (fix (sslength ss))) ;; a little fix
      (apply qfoo (list (ssname ss (setq n (1- n))))))))

   (defun dxf(a b)(cdr(assoc a b)))

   ;;Invert polyline
   (defun inv-pl( e / d0 di d bl pl swl ewl )
     (setq d0 (entget e '("*"))) ;; keep xdata
     (while (/= "SEQEND" (dxf 0 (setq di
              (entget (setq e (entnext e))))))
       (setq  d di
             pl (cons (dxf 10 d) pl)
            swl (cons (dxf 40 d) swl)
            ewl (cons (dxf 41 d) ewl)
             bl (cons (-(dxf 42 d)) bl) ))
     (setq  ;; cycle the lists
           bl  (append (cdr  bl) (list (car  bl)))
           swl (append (cdr swl) (list (car swl)))
           ewl (append (cdr ewl) (list (car ewl))) )

     (entmake d0)
     (mapcar
      '(lambda(p b sw ew)(entmake
        (subst (cons 10 p)(assoc 10 d)
         (subst (cons 42 b)(assoc 42 d)
          (subst (cons 40 sw)(assoc 40 d)
           (subst (cons 41 ew)(assoc 41 d)
             d))))))
       pl bl ewl swl)
     (entmake(list '(0 . "SEQEND")(cons 8 (dxf 8 d0))))
     (entdel (dxf -1 d0))
     (redraw (entlast))
     (princ)
   )
;;; Changes:
;;; 1997/11/06: slight improvements:
;;;                inv-pl to carry width info and keep EED
“Common sense is not so common.” ~Voltaire

--> Donate to TheSwamp.org <--

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16717
  • Superior Stupidity at its best
Reversing Polylines
« Reply #14 on: March 20, 2004, 11:03:20 PM »
Quote from: Se7en
BTW, Look what I found:


Now... that's the spirit.....:)
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal