Reverse of some lines

Reverse of some lines

BB8x
Advocate Advocate
1,199 Views
11 Replies
Message 1 of 12

Reverse of some lines

BB8x
Advocate
Advocate

Hi all

 

I am looking lisp to Reverse some lines (not polylines or 3d polies) . Only lines with an angle <90,360) (including 90, excluding 360) should be reversed 

 

Thanks

0 Likes
1,200 Views
11 Replies
Replies (11)
Message 2 of 12

roland.r71
Collaborator
Collaborator

@BB8x wrote:

Hi all

 

I am looking lisp to Reverse some lines (not polylines or 3d polies) . Only lines with an angle <90,360) (including 90, excluding 360) should be reversed 

 

Thanks


This little gem here by @Kent1Cooper might be of use to you(?)

Re: Reverse direction of any directional entity

 

(it can do the polies too)

0 Likes
Message 3 of 12

pbejse
Mentor
Mentor

@BB8x wrote:

I am looking lisp to Reverse some lines (not polylines or 3d polies) . Only lines with an angle <90,360) (including 90, excluding 360) should be reversed 


 

Curious is to why ?

 

0 Likes
Message 4 of 12

CADaSchtroumpf
Advisor
Advisor

Hi, very quicly!

 

((lambda ( / js n dxf_ent p_10 p_11)
  (setq js (ssget '((0 . "LINE"))))
  (cond
    (js
      (repeat (setq n (sslength js))
        (setq
          dxf_ent (entget (ssname js (setq n (1- n))))
          p_10 (cdr (assoc 10 dxf_ent))
          p_11 (cdr (assoc 11 dxf_ent))
        )
        (cond
          ((and (<= (angle p_10 p_11) (* 0.5 pi)) (> (angle p_10 p_11) 0.0))
            (setq dxf_ent (subst (cons 10 p_11) (assoc 10 dxf_ent) dxf_ent))
            (entmod (subst (cons 11 p_10) (assoc 11 dxf_ent) dxf_ent))
          )
        )
      )
    )
  )
  (prin1)
))
0 Likes
Message 5 of 12

Kent1Cooper
Consultant
Consultant

@BB8x wrote:

.... I am looking lisp to Reverse some lines (not polylines or 3d polies) . Only lines with an angle <90,360) (including 90, excluding 360) should be reversed ....


Can you clarify what you mean by <90,360 ?  A Line at an angle of 360° would "report" as being at an angle of , so what does that really represent?  Do you mean Lines at an angle of more than 0° up to and including 90°?  Or do you perhaps mean from 90° or more up to but not including 360°?

 

By the way, the routine of mine that @roland.r71 linked to is great for what it does, but it requires you to select  the thing(s) you want to reverse, so you would need to know which Lines need it.  Since that's not apparent looking at a Line in a drawing, do I assume correctly that you want a routine to determine by itself which ones need to be reversed, from a User selection or maybe from all Lines in the drawing?

Kent Cooper, AIA
0 Likes
Message 6 of 12

Sea-Haven
Mentor
Mentor

Sounds like a quadrant thing so all lines go in one direction ie to right.

0 Likes
Message 7 of 12

Kent1Cooper
Consultant
Consultant

@Sea-Haven wrote:

Sounds like a quadrant thing so all lines go in one direction ie to right.


I don't think so -- for that the range would be 90 to 270.  (Or maybe that's what they meant.)

Kent Cooper, AIA
0 Likes
Message 8 of 12

roland.r71
Collaborator
Collaborator

It could even mean he wishes to mirror the lines, but that's actually why i posted kent's function.

It will do exactly what he asked. Reverse some lines, by visual selection.

 

I was kinda expecting a reply, about how it should be something completely different. 😁

0 Likes
Message 9 of 12

Sea-Haven
Mentor
Mentor

Where is my crystal ball ? Oh yeah that's right I had it polished over at Cadtutor.

0 Likes
Message 10 of 12

BB8x
Advocate
Advocate

Thing is to keep line type not upside down

Turning this -----Ɐ----- to this -----A-----

0 Likes
Message 11 of 12

Kent1Cooper
Consultant
Consultant

@BB8x wrote:

Thing is to keep line type not upside down

Turning this -----Ɐ----- to this -----A-----


[Aside from the fact that the presumed upside-down-A character didn't come through....]

 

Then it sounds like you do  want a range between 90° and 270°, not 360°.  It would be typical to not  reverse at 90° exactly, and to reverse  270° exactly, and to reverse everything in between, but not anything less than 90° nor more than 270°.  Is that what you need?

 

Also, are you aware that linetypes with text can be defined so that the text is always in the more-upright direction, no matter what direction the Line runs?  You may be able to simply change a little bit of coding to have them work that way, and not need any routine.  Just replace R= in the text specification(s) with U=.  See >Help about it< for more information.

Kent Cooper, AIA
0 Likes
Message 12 of 12

Sea-Haven
Mentor
Mentor

Having dealt with this problem many times much easier if lines are connected to pick a line, set correct direction then use pedit and join will make the line type pattern continuous over the entire length of the line/s segment. Look at a series of lines making a U using your single lines a ---->---- would go ----<------>------ which is wrong when looking at U etc. For lettering line types yes.

 

screenshot227.png

0 Likes