Engineer_Yasser Posted April 12, 2024 Posted April 12, 2024 (edited) Please , I need help to break closed polylines at corners only, not all vertices. As shown in the attached picture. Test.dwg Edited April 12, 2024 by Engineer_Yasser Quote
XDSoft Posted April 12, 2024 Posted April 12, 2024 [XDrX-PlugIn(141)] break closed polylines at corners (theswamp.org) https://www.theswamp.org/index.php?topic=59452 1.The API provides a ready-made method for calculating the angle between each segment of a polyline. (xdrx-getpropertyvalue pline "allinnerangles") (xdrx-getpropertyvalue pline "allouterangles") (xdrx-getpropertyvalue pline "angles") 2.Get the vertices whose angle between segments is not 0 or PI, and then use xdrx-curve-getsplitcurves to break. (defun c:xdtb_plbrkatcorner (/ angles pts ss x y) (if (setq ss (xdrx-ssget (xdrx-string-multilanguage "\n选择多段线<退出>:" "\nSelect Polylines<Exit>:") ' ((0 . "*polyline")) ) ) (progn (xdrx-begin) (mapcar '(lambda (x) (setq angles (xdrx-getpropertyvalue x "vertices" "angle") angles (mapcar '(lambda (x y) (list x y) ) (car angles) (cadr angles) ) angles (vl-remove-if (function (lambda (x) (or (equal (last x) 0.0 1e-5) (equal (last x) pi 1e-5) ) ) ) angles ) pts (mapcar 'car angles ) ) (xdrx-curve-getsplitcurves x pts) ) (xdrx-ss->ents ss) ) (xdrx-end) ) ) (princ) ) Quote
Engineer_Yasser Posted April 12, 2024 Author Posted April 12, 2024 (edited) 22 hours ago, XDSoft said: [XDrX-PlugIn(141)] break closed polylines at corners (theswamp.org) https://www.theswamp.org/index.php?topic=59452 1.The API provides a ready-made method for calculating the angle between each segment of a polyline. (xdrx-getpropertyvalue pline "allinnerangles") (xdrx-getpropertyvalue pline "allouterangles") (xdrx-getpropertyvalue pline "angles") 2.Get the vertices whose angle between segments is not 0 or PI, and then use xdrx-curve-getsplitcurves to break. (defun c:xdtb_plbrkatcorner (/ angles pts ss x y) (if (setq ss (xdrx-ssget (xdrx-string-multilanguage "\n选择多段线<退出>:" "\nSelect Polylines<Exit>:") ' ((0 . "*polyline")) ) ) (progn (xdrx-begin) (mapcar '(lambda (x) (setq angles (xdrx-getpropertyvalue x "vertices" "angle") angles (mapcar '(lambda (x y) (list x y) ) (car angles) (cadr angles) ) angles (vl-remove-if (function (lambda (x) (or (equal (last x) 0.0 1e-5) (equal (last x) pi 1e-5) ) ) ) angles ) pts (mapcar 'car angles ) ) (xdrx-curve-getsplitcurves x pts) ) (xdrx-ss->ents ss) ) (xdrx-end) ) ) (princ) ) Thanks For Your Help Edited April 13, 2024 by Engineer_Yasser 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.