Jump to content

polyline curves set to zero radius


rrulep

Recommended Posts

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.

Link to comment
Share on other sites

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)

curve.PNG

 

after the pedit command (decurve option)

staright.PNG

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

Capture.jpg

Link to comment
Share on other sites

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 by suriwaits
Link to comment
Share on other sites

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.

PolylineToZeroRadius.PNG

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Is it possible to draw only the lines outside the arcs or remove the lines that overlapped on the original polyline?

Link to comment
Share on other sites

your version is much faster than mine.:thumbsup:

 

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

Link to comment
Share on other sites

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