Jump to content

Please help to break closed polylines at corners


Recommended Posts

Posted (edited)

Please , I need help to break closed polylines at corners only, not all vertices.

As shown in the attached picture.

 

Test.dwg

11111111111111.png

Edited by Engineer_Yasser
Posted

Video_2024-04-12_172255.gif.70c2cb5dd30fa07225031e06d04fa906.gif

 

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

 

Posted (edited)
22 hours ago, XDSoft said:

Video_2024-04-12_172255.gif.70c2cb5dd30fa07225031e06d04fa906.gif

 

[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 by Engineer_Yasser

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