Organic Posted April 15, 2009 Share Posted April 15, 2009 I'm hoping someone might be able to help me with the following which I need (I'm still only learning Lisp basics and are nowhere near up to this yet). I have lines with linetypes like ------E-------E---------E------ etc, although more often than not, these are often rotated the wrong way in the drawing (I don't draw them, I just work with them and fix them up before I can even start thinkign about doign anything else). The easiest way to deal with these is to generally rotate each line aroudn its midpoint 180d (its extremely random which ones are rotated and differs in eahc line). So what I am looking for is the following lisp routien if anyone knwos of one or would be kind enough to write one. Recognize that a line has been selected and determine the midpoint of it (I don't want to have to select the midpoint, just anywhere on the line). Rotate that line 180d around the midpoint. Quote Link to comment Share on other sites More sharing options...
eldon Posted April 15, 2009 Share Posted April 15, 2009 Instead of rotating the line by 180°, there are lisps around which reverse the direction of a line. Quote Link to comment Share on other sites More sharing options...
David Bethel Posted April 15, 2009 Share Posted April 15, 2009 One way to rotate a LINE is to swap end values: [b][color=BLACK]([/color][/b]defun c:rotline [b][color=FUCHSIA]([/color][/b]/ ss i en ed p10 p11[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]not ss[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]cons 0 [color=#2f4f4f]"LINE"[/color][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]if [b][color=RED]([/color][/b]getvar [color=#2f4f4f]"CTAB"[/color][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]cons 410 [b][color=PURPLE]([/color][/b]getvar [color=#2f4f4f]"CTAB"[/color][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]cons 67 [b][color=PURPLE]([/color][/b]- 1 [b][color=TEAL]([/color][/b]getvar [color=#2f4f4f]"TILEMODE"[/color][b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq i [b][color=NAVY]([/color][/b]sslength ss[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]not [b][color=MAROON]([/color][/b]minusp [b][color=GREEN]([/color][/b]setq i [b][color=BLUE]([/color][/b]1- i[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setq en [b][color=MAROON]([/color][/b]ssname ss i[b][color=MAROON])[/color][/b] ed [b][color=MAROON]([/color][/b]entget en[b][color=MAROON])[/color][/b] p10 [b][color=MAROON]([/color][/b]cdr [b][color=GREEN]([/color][/b]assoc 10 ed[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] p11 [b][color=MAROON]([/color][/b]cdr [b][color=GREEN]([/color][/b]assoc 11 ed[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] ed [b][color=MAROON]([/color][/b]subst [b][color=GREEN]([/color][/b]cons 10 p11[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]assoc 10 ed[b][color=GREEN])[/color][/b] ed[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]entmod [b][color=MAROON]([/color][/b]subst [b][color=GREEN]([/color][/b]cons 11 p10[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]assoc 11 ed[b][color=GREEN])[/color][/b] ed[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] -David Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 15, 2009 Share Posted April 15, 2009 This should work on Lines, LWpolylines and Polylines: [color=#8b4513];;; Line/Polyline Reverser by Lee McDonnell[/color] [b][color=BLACK]([/color][/b]defun c:revver [b][color=FUCHSIA]([/color][/b]/ *error* varlst ovar ss eLst vLst Vert[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]vl-load-com[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]defun *error* [b][color=NAVY]([/color][/b]msg[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]if ovar [b][color=MAROON]([/color][/b]mapcar 'setvar varlst ovar[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]princ [b][color=MAROON]([/color][/b]strcat [color=#2f4f4f]"\nError: "[/color] [b][color=GREEN]([/color][/b]strcase msg[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]princ[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq varlst '[b][color=NAVY]([/color][/b][color=#2f4f4f]"CLAYER"[/color] [color=#2f4f4f]"CMDECHO"[/color] [color=#2f4f4f]"OSMODE"[/color][b][color=NAVY])[/color][/b] ovar [b][color=NAVY]([/color][/b]mapcar 'getvar varlst[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]mapcar 'setvar [b][color=NAVY]([/color][/b]cdr varlst[b][color=NAVY])[/color][/b] '[b][color=NAVY]([/color][/b]0 0[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]if [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]cons 0 [color=#2f4f4f]"LINE,*POLYLINE"[/color][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]if [b][color=RED]([/color][/b]getvar [color=#2f4f4f]"CTAB"[/color][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]cons 410 [b][color=PURPLE]([/color][/b]getvar [color=#2f4f4f]"CTAB"[/color][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]cons 67 [b][color=PURPLE]([/color][/b]- 1 [b][color=TEAL]([/color][/b]getvar [color=#2f4f4f]"TILEMODE"[/color][b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]progn [b][color=MAROON]([/color][/b]foreach ent [b][color=GREEN]([/color][/b]vl-remove-if 'listp [b][color=BLUE]([/color][/b]mapcar 'cadr [b][color=RED]([/color][/b]ssnamex ss[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]setq eLst [b][color=BLUE]([/color][/b]entget ent[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]setvar [color=#2f4f4f]"CLAYER"[/color] [b][color=BLUE]([/color][/b]cdr [b][color=RED]([/color][/b]assoc 8 eLst[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]cond [b][color=BLUE]([/color][/b][b][color=RED]([/color][/b]eq [color=#2f4f4f]"LINE"[/color] [b][color=PURPLE]([/color][/b]cdadr eLst[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]command [color=#2f4f4f]"_line"[/color] [b][color=PURPLE]([/color][/b]cdr [b][color=TEAL]([/color][/b]assoc 11 eLst[b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b] [b][color=PURPLE]([/color][/b]cdr [b][color=TEAL]([/color][/b]assoc 10 eLst[b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b] [color=#2f4f4f]""[/color][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b][b][color=RED]([/color][/b]eq [color=#2f4f4f]"LWPOLYLINE"[/color] [b][color=PURPLE]([/color][/b]cdadr eLst[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]setq vLst [b][color=PURPLE]([/color][/b]reverse [b][color=TEAL]([/color][/b]mapcar 'cdr [b][color=OLIVE]([/color][/b]vl-remove-if-not '[b][color=GRAY]([/color][/b]lambda [b][color=AQUA]([/color][/b]x[b][color=AQUA])[/color][/b] [b][color=AQUA]([/color][/b]= 10 [b][color=LIME]([/color][/b]car x[b][color=LIME])[/color][/b][b][color=AQUA])[/color][/b][b][color=GRAY])[/color][/b] eLst[b][color=OLIVE])[/color][/b][b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]command [color=#2f4f4f]"_pline"[/color][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]mapcar 'command vLst[b][color=RED])[/color][/b] [b][color=RED]([/color][/b]command[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b][b][color=RED]([/color][/b]eq [color=#2f4f4f]"POLYLINE"[/color] [b][color=PURPLE]([/color][/b]cdadr eLst[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]setq Vert [b][color=PURPLE]([/color][/b]entnext ent[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]while [b][color=PURPLE]([/color][/b]not [b][color=TEAL]([/color][/b]eq [color=#2f4f4f]"SEQEND"[/color] [b][color=OLIVE]([/color][/b]cdadr [b][color=GRAY]([/color][/b]entget Vert[b][color=GRAY])[/color][/b][b][color=OLIVE])[/color][/b][b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b] [b][color=PURPLE]([/color][/b]setq vLst [b][color=TEAL]([/color][/b]cons [b][color=OLIVE]([/color][/b]cdr [b][color=GRAY]([/color][/b]assoc 10 [b][color=AQUA]([/color][/b]entget Vert[b][color=AQUA])[/color][/b][b][color=GRAY])[/color][/b][b][color=OLIVE])[/color][/b] vLst[b][color=TEAL])[/color][/b] Vert [b][color=TEAL]([/color][/b]entnext Vert[b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]command [color=#2f4f4f]"_3dpoly"[/color][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]mapcar 'command vLst[b][color=RED])[/color][/b] [b][color=RED]([/color][/b]command[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]if [b][color=BLUE]([/color][/b]assoc 6 eLst[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]command [color=#2f4f4f]"_chprop"[/color] [b][color=RED]([/color][/b]entlast[b][color=RED])[/color][/b] [color=#2f4f4f]""[/color] [color=#2f4f4f]"_LT"[/color] [b][color=RED]([/color][/b]cdr [b][color=PURPLE]([/color][/b]assoc 6 eLst[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] [color=#2f4f4f]""[/color][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]entdel ent[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]princ [color=#2f4f4f]"\n<!> No Line or *Polyline Selected <!>"[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]mapcar 'setvar varlst ovar[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]princ[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] Quote Link to comment Share on other sites More sharing options...
David Bethel Posted April 15, 2009 Share Posted April 15, 2009 Lee, Wow, I think things like bulges, pline width, thickness, color, UCS would be an issue. Also, not all POLYLINEs are 3dpoly. And meshes. If I remember, a true reverse poyline is a pretty involved process. My $0.02 -David Quote Link to comment Share on other sites More sharing options...
Organic Posted April 15, 2009 Author Share Posted April 15, 2009 Thanks guys, works just like I need. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 15, 2009 Share Posted April 15, 2009 Lee, Wow, I think things like bulges, pline width, thickness, color, UCS would be an issue. Also, not all POLYLINEs are 3dpoly. And meshes. If I remember, a true reverse poyline is a pretty involved process. My $0.02 -David Some good points David - well worthy of $0.02. I just made it quickly a while back - I suppose it will work in 80% of cases - but I can see how in the other 20% where there are arcs, heavy polylines, plines with varying widths etc it will cause an issue. Quote Link to comment Share on other sites More sharing options...
Organic Posted April 16, 2009 Author Share Posted April 16, 2009 Worked a treat when I used it today. Is there any way to do something similar like this for an arc, without changing the position of the arc? I.e. If I manually rotate the arc it loses its position etc and is no good. Quote Link to comment Share on other sites More sharing options...
David Bethel Posted April 16, 2009 Share Posted April 16, 2009 ARC angles ( 50 & 51 ) are always CCW. You could invert the UCS ( 210 ), change (0 0 1) to (0 0 -1) etc and then do a ( trans ) a lot of work and not always the result that I think that you'd want. -David Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 16, 2009 Share Posted April 16, 2009 ARC angles ( 50 & 51 ) are always CCW. You could invert the UCS ( 210 ), change (0 0 1) to (0 0 -1) etc and then do a ( trans ) a lot of work and not always the result that I think that you'd want. -David Nice idea David - but as you say - not sure I'd want to go messing around with UCS... Quote Link to comment Share on other sites More sharing options...
Commandobill Posted April 16, 2009 Share Posted April 16, 2009 This is completely hack but it works everytime. If you simply draw a ployline in the direction you want on the correct layer and join it to the poly line going the wrong direction it will make the polyline go the opposite direction. Like i said hack and basic but it works. Quote Link to comment Share on other sites More sharing options...
Organic Posted April 16, 2009 Author Share Posted April 16, 2009 This is completely hack but it works everytime. If you simply draw a ployline in the direction you want on the correct layer and join it to the poly line going the wrong direction it will make the polyline go the opposite direction. Like i said hack and basic but it works. Yeah that is what I am doing currently. If the above doesn't work, just make sure that the lien is "Enabled" and it will. Just looking for a neasier way to do this Quote Link to comment Share on other sites More sharing options...
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.