As stated in the title, I am trying to get a function which lets me straighten collinear segments in a closed polylines by removing the useless vertex in the middle. I would prefer to use angular fuzz as an input in the function.
I found @Kent1Cooper 's PLDiet (2009 version) on https://forums.intellicadms.com/viewtopic.php?t=1622 and adapted it as a function instead of a command :
;;; PLDIET.lsp (version 2009) [command name: PLD]
; [ Edited the post to remove the old code...]
; [ See update posts below ]
Using this following function call in the testing drawing attached to this post,
(KC:PLD 99999 0.003 "Retain" (ssget '((0 . "LWPOLYLINE"))))
I was unable to straighten 2 perfectly colinear segments (identified in the test drawing).
Does some one knows how could i fix this?
Solved! Go to Solution.
Solved by 1LandSurveyor. Go to Solution.
UPDATE : I'm pretty sure i have found the reason why. The 2 collinear segments that won't straighten in my test drawing are the first and last segments of the closed polyline and the comparison is thus never made for this case.
I will try to implement this...
UPDATE : I have just found the 2019 updated version of the Kent's PLDIET command from [message 24] in this thread https://forums.autodesk.com/t5/autocad-forum/reduce-polyline-points/m-p/9117542/highlight/true#M9986...
I will look into that...
Here is my final version.
I achieve exactly what i was looking for.
Thanks a lot for your wonderful code @Kent1Cooper .
; PLDiest.lsp
; Kent Cooper, last edited 30 October 2019
; Modified version by 1LandSurveyor 2021-12-08 :
; Added a part to account for the start point of a closed
; polyline possibly being in the middle of a straigth line.
; Modified to be used as a function whithin another command.
; Added Collinearity fuzz/tolerance as input.
; Added Redundant vertex detection as input.
; INPUTS :
; PLDdist : Maximum distance between non-collinear vertices to straighten [in drawing units]
; PLDcid : Maximum angular change in direction to straighten [in degrees]
; PLD2ptFuzz : Redundant vertex detection fuzz/tolerance. [in drawing units]
; PLDcollFuzz : Collinear fuzz/tolerance. [in degrees]
; PLDarc : Retain or Straighten arc segments ["Retain" or "Straighten"]
; pldss : SS of polylines to put on a diet [type (ssget '((0 . "LWPOLYLINE")))]
One may test this lisp using :
(KC:PLD 1e-5 180 1e-4 6e-4 "Retain" (ssget '((0 . "LWPOLYLINE"))))
In order to simplify a closed polyline without changing its shape outside fuzz values.