rrulep Posted September 10, 2014 Posted September 10, 2014 Hi everyone. Is there any lisp that could change the radius of polyline to zero. Quote
MSasu Posted September 10, 2014 Posted September 10, 2014 This is a task that can be solved without a custom tool; please check the built-in command PEDIT with its Decurve option. Quote
rrulep Posted September 10, 2014 Author Posted September 10, 2014 This is a task that can be solved without a custom tool; please check the built-in command PEDIT with its Decurve option. Hi The decurve option flattens the curve only. If possible, when I select the polyline, it should ask the user to specify the radius of all the curves in a polyline. Quote
rrulep Posted September 10, 2014 Author Posted September 10, 2014 Hi The decurve option flattens the curve only. If possible, when I select the polyline, it should ask the user to specify the radius of all the curves in a polyline. Here's what I've got using the pedit with its decurve option. before the pedit command (decurve option) after the pedit command (decurve option) Quote
MSasu Posted September 10, 2014 Posted September 10, 2014 Alternatively try to use FILLET with Polyline option and Radius set to 0. Quote
rrulep Posted September 10, 2014 Author Posted September 10, 2014 Alternatively try to use FILLET with Polyline option and Radius set to 0. That's what I'm doing right now but it's take time if I'm working with very long polyline with hundreds of curve. Quote
Tharwat Posted September 10, 2014 Posted September 10, 2014 Maybe this . (defun c:Test (/ ss ) (if (setq ss (ssget "_:L" '((0 . "LWPOLYLINE")))) ((lambda (i / sn) (while (setq sn (ssname ss (setq i (1+ i)))) (entmod (mapcar '(lambda (x) (if (eq (car x) 42) '(42 . 0.) x)) (entget sn))) (entupd sn))) -1) ) (princ) ) Quote
rrulep Posted September 10, 2014 Author Posted September 10, 2014 Maybe this . (defun c:Test (/ ss ) (if (setq ss (ssget "_:L" '((0 . "LWPOLYLINE")))) ((lambda (i / sn) (while (setq sn (ssname ss (setq i (1+ i)))) (entmod (mapcar '(lambda (x) (if (eq (car x) 42) '(42 . 0.) x)) (entget sn))) (entupd sn))) -1) ) (princ) ) Hi tharwat.. The result is the same with Mircea's suggestion using the pedit with its decurve option. Its just flattened the curve in a polyline. Quote
rrulep Posted September 10, 2014 Author Posted September 10, 2014 Hi tharwat.. The result is the same with Mircea's suggestion using the pedit with its decurve option. Its just flattened the curve in a polyline. Hi tharwat You might be confused with what I want to achieve. The lisp should do something like this on the image below. Quote
suriwaits Posted September 10, 2014 Posted September 10, 2014 (edited) http://www.cadtutor.net/forum/archive/index.php/t-49834.html (defun c:FP (/ ss) ;; Alan J. Thompson, 08.31.10 (initget 4) (setvar 'filletrad (cond ((getdist (strcat "\nSpecify fillet radius <" (rtos (getvar 'filletrad)) ">: "))) ((getvar 'filletrad)) ) ) (if (setq ss (ssget "_:L" '((0 . "LWPOLYLINE")))) ((lambda (i / e) (while (setq e (ssname ss (setq i (1+ i)))) (command "_.fillet" "_polyline" e) ) ) -1 ) ) (princ) ) Edited September 10, 2014 by suriwaits Quote
eldon Posted September 10, 2014 Posted September 10, 2014 Perhaps you could do it manually, but with another technique. First of all explode the polyline. Then erase all arc segments. Then using Pedit and a suitable fuzz distance, rejoin all straight line sections to make a polyline. Quote
Stefan BMR Posted September 10, 2014 Posted September 10, 2014 (defun c:test (/ ss r i) (if (setq ss (ssget ":L" '((0 . "LWPOLYLINE")))) (progn (if (setq r (getdist (strcat "\nFillet radius <" (rtos (getvar 'filletrad)) ">: "))) (setvar 'filletrad (abs r)) ) (repeat (setq i (sslength ss)) (command "fillet" "p" (ssname ss (setq i (1- i)))) ) ) ) (princ) ) Quote
rrulep Posted September 11, 2014 Author Posted September 11, 2014 Hi here's what I've written but I want to trim the red line that overlapped on the white line showing only the redlines that extended outside the curves. (defun c:pol () (if (not (tblsearch "LAYER" "C-ROAD_CURV_TAN")) (entmake '((0 . "LAYER") (100 . "AcDbSymbolTableRecord") (100 . "AcDbLayerTableRecord") (2 . "C-ROAD_CURV_TAN") (70 . 0) (62 . 10) (370 . -3) (6 . "Continuous") ) ) ) (setq poly (ssget '((0 . "LWPOLYLINE")))) (command "copy" poly "" "0,0" "0,0" "") (setq poly2 (entlast)) (command "CHANGE" poly2 "" "P" "la" "C-ROAD_CURV_TAN" "") (setvar "FILLETRAD" 0.0) (command "fillet" "p" poly2 "") (princ) ) Quote
Lee Mac Posted September 13, 2014 Posted September 13, 2014 Here's another method: ([color=BLUE]defun[/color] c:decurve ( [color=BLUE]/[/color] vertexdata b c e i l p q r s x ) ([color=BLUE]defun[/color] vertexdata ( e ) ([color=BLUE]if[/color] ([color=BLUE]setq[/color] e ([color=BLUE]member[/color] ([color=BLUE]assoc[/color] 10 e) e)) ([color=BLUE]cons[/color] ([color=BLUE]list[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 10 e)) ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 42 e))) (vertexdata ([color=BLUE]cdr[/color] e))) ) ) ([color=BLUE]if[/color] ([color=BLUE]setq[/color] s ([color=BLUE]ssget[/color] [color=MAROON]"_:L"[/color] '((0 . [color=MAROON]"LWPOLYLINE"[/color]) (-4 . [color=MAROON]"<>"[/color]) (42 . 0.0)))) ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] i ([color=BLUE]sslength[/color] s)) ([color=BLUE]setq[/color] e ([color=BLUE]entget[/color] ([color=BLUE]ssname[/color] s ([color=BLUE]setq[/color] i ([color=BLUE]1-[/color] i)))) l (vertexdata e) r [color=BLUE]nil[/color] ) ([color=BLUE]if[/color] ([color=BLUE]setq[/color] c ([color=BLUE]=[/color] 1 ([color=BLUE]logand[/color] 1 ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 70 e))))) ([color=BLUE]setq[/color] l ([color=BLUE]append[/color] l ([color=BLUE]list[/color] ([color=BLUE]car[/color] l)))) ) ([color=BLUE]while[/color] ([color=BLUE]cadr[/color] l) ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]/=[/color] 0.0 ([color=BLUE]setq[/color] b ([color=BLUE]cadar[/color] l))) ([color=BLUE]setq[/color] p ([color=BLUE]polar[/color] ([color=BLUE]caar[/color] l) ([color=BLUE]+[/color] ([color=BLUE]angle[/color] ([color=BLUE]caar[/color] l) ([color=BLUE]caadr[/color] l)) ([color=BLUE]-[/color] ([color=BLUE]/[/color] [color=BLUE]pi[/color] 2) ([color=BLUE]*[/color] 2 ([color=BLUE]atan[/color] b)))) ([color=BLUE]/[/color] ([color=BLUE]*[/color] ([color=BLUE]distance[/color] ([color=BLUE]caar[/color] l) ([color=BLUE]caadr[/color] l)) ([color=BLUE]1+[/color] ([color=BLUE]*[/color] b b))) 4 b) ) ) ([color=BLUE]setq[/color] q ([color=BLUE]inters[/color] ([color=BLUE]caar[/color] l) ([color=BLUE]polar[/color] ([color=BLUE]caar[/color] l) ([color=BLUE]+[/color] ([color=BLUE]angle[/color] p ([color=BLUE]caar[/color] l)) ([color=BLUE]/[/color] [color=BLUE]pi[/color] 2.0)) 1.0) ([color=BLUE]caadr[/color] l) ([color=BLUE]polar[/color] ([color=BLUE]caadr[/color] l) ([color=BLUE]+[/color] ([color=BLUE]angle[/color] p ([color=BLUE]caadr[/color] l)) ([color=BLUE]/[/color] [color=BLUE]pi[/color] 2.0)) 1.0) [color=BLUE]nil[/color] ) ) ) ([color=BLUE]setq[/color] r ([color=BLUE]vl-list*[/color] q ([color=BLUE]caar[/color] l) r)) ([color=BLUE]setq[/color] r ([color=BLUE]cons[/color] ([color=BLUE]caar[/color] l) r)) ) ([color=BLUE]setq[/color] l ([color=BLUE]cdr[/color] l)) ) ([color=BLUE]if[/color] ([color=BLUE]not[/color] c) ([color=BLUE]setq[/color] r ([color=BLUE]cons[/color] ([color=BLUE]caar[/color] l) r))) ([color=BLUE]entmake[/color] ([color=BLUE]append[/color] ([color=BLUE]subst[/color] ([color=BLUE]cons[/color] 90 ([color=BLUE]length[/color] r)) ([color=BLUE]assoc[/color] 90 e) ([color=BLUE]reverse[/color] ([color=BLUE]member[/color] ([color=BLUE]assoc[/color] 39 e) ([color=BLUE]reverse[/color] e))) ) ([color=BLUE]mapcar[/color] '([color=BLUE]lambda[/color] ( x ) ([color=BLUE]cons[/color] 10 x)) ([color=BLUE]reverse[/color] r)) ([color=BLUE]list[/color] ([color=BLUE]assoc[/color] 210 e)) ) ) ) ) ([color=BLUE]princ[/color]) ) ([color=BLUE]princ[/color]) Quote
GP_ Posted September 13, 2014 Posted September 13, 2014 (if (setq s (ssget "_:L" '((0 . "LWPOLYLINE") (-4 . "") (42 . 0.0)))) ..... ..... Quote
rrulep Posted September 15, 2014 Author Posted September 15, 2014 Here's another method: ([color=BLUE]defun[/color] c:decurve ( [color=BLUE]/[/color] vertexdata b c e i l p q r s x ) ([color=BLUE]defun[/color] vertexdata ( e ) ([color=BLUE]if[/color] ([color=BLUE]setq[/color] e ([color=BLUE]member[/color] ([color=BLUE]assoc[/color] 10 e) e)) ([color=BLUE]cons[/color] ([color=BLUE]list[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 10 e)) ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 42 e))) (vertexdata ([color=BLUE]cdr[/color] e))) ) ) ([color=BLUE]if[/color] ([color=BLUE]setq[/color] s ([color=BLUE]ssget[/color] [color=MAROON]"_:L"[/color] '((0 . [color=MAROON]"LWPOLYLINE"[/color]) (-4 . [color=MAROON]"<>"[/color]) (42 . 0.0)))) ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] i ([color=BLUE]sslength[/color] s)) ([color=BLUE]setq[/color] e ([color=BLUE]entget[/color] ([color=BLUE]ssname[/color] s ([color=BLUE]setq[/color] i ([color=BLUE]1-[/color] i)))) l (vertexdata e) r [color=BLUE]nil[/color] ) ([color=BLUE]if[/color] ([color=BLUE]setq[/color] c ([color=BLUE]=[/color] 1 ([color=BLUE]logand[/color] 1 ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 70 e))))) ([color=BLUE]setq[/color] l ([color=BLUE]append[/color] l ([color=BLUE]list[/color] ([color=BLUE]car[/color] l)))) ) ([color=BLUE]while[/color] ([color=BLUE]cadr[/color] l) ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]/=[/color] 0.0 ([color=BLUE]setq[/color] b ([color=BLUE]cadar[/color] l))) ([color=BLUE]setq[/color] p ([color=BLUE]polar[/color] ([color=BLUE]caar[/color] l) ([color=BLUE]+[/color] ([color=BLUE]angle[/color] ([color=BLUE]caar[/color] l) ([color=BLUE]caadr[/color] l)) ([color=BLUE]-[/color] ([color=BLUE]/[/color] [color=BLUE]pi[/color] 2) ([color=BLUE]*[/color] 2 ([color=BLUE]atan[/color] b)))) ([color=BLUE]/[/color] ([color=BLUE]*[/color] ([color=BLUE]distance[/color] ([color=BLUE]caar[/color] l) ([color=BLUE]caadr[/color] l)) ([color=BLUE]1+[/color] ([color=BLUE]*[/color] b b))) 4 b) ) ) ([color=BLUE]setq[/color] q ([color=BLUE]inters[/color] ([color=BLUE]caar[/color] l) ([color=BLUE]polar[/color] ([color=BLUE]caar[/color] l) ([color=BLUE]+[/color] ([color=BLUE]angle[/color] p ([color=BLUE]caar[/color] l)) ([color=BLUE]/[/color] [color=BLUE]pi[/color] 2.0)) 1.0) ([color=BLUE]caadr[/color] l) ([color=BLUE]polar[/color] ([color=BLUE]caadr[/color] l) ([color=BLUE]+[/color] ([color=BLUE]angle[/color] p ([color=BLUE]caadr[/color] l)) ([color=BLUE]/[/color] [color=BLUE]pi[/color] 2.0)) 1.0) [color=BLUE]nil[/color] ) ) ) ([color=BLUE]setq[/color] r ([color=BLUE]vl-list*[/color] q ([color=BLUE]caar[/color] l) r)) ([color=BLUE]setq[/color] r ([color=BLUE]cons[/color] ([color=BLUE]caar[/color] l) r)) ) ([color=BLUE]setq[/color] l ([color=BLUE]cdr[/color] l)) ) ([color=BLUE]if[/color] ([color=BLUE]not[/color] c) ([color=BLUE]setq[/color] r ([color=BLUE]cons[/color] ([color=BLUE]caar[/color] l) r))) ([color=BLUE]entmake[/color] ([color=BLUE]append[/color] ([color=BLUE]subst[/color] ([color=BLUE]cons[/color] 90 ([color=BLUE]length[/color] r)) ([color=BLUE]assoc[/color] 90 e) ([color=BLUE]reverse[/color] ([color=BLUE]member[/color] ([color=BLUE]assoc[/color] 39 e) ([color=BLUE]reverse[/color] e))) ) ([color=BLUE]mapcar[/color] '([color=BLUE]lambda[/color] ( x ) ([color=BLUE]cons[/color] 10 x)) ([color=BLUE]reverse[/color] r)) ([color=BLUE]list[/color] ([color=BLUE]assoc[/color] 210 e)) ) ) ) ) ([color=BLUE]princ[/color]) ) ([color=BLUE]princ[/color]) Hi Lee your version is much faster than mine. Is it possible to draw only the lines outside the arcs or remove the lines that overlapped on the original polyline? Quote
Lee Mac Posted September 15, 2014 Posted September 15, 2014 your version is much faster than mine. Excellent, thanks Is it possible to draw only the lines outside the arcs or remove the lines that overlapped on the original polyline? The program will recreate the polyline with all arc segments removed & replaced with linear segments, therefore, you can delete the original polyline if desired (or this deletion can easily be added to the code). Lee Quote
rrulep Posted September 16, 2014 Author Posted September 16, 2014 hi lee i only want to removed the straight line that overlapped to the original polyline 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.