Author Topic: [XDrX-PlugIn(11)] Single line To double line  (Read 1223 times)

0 Members and 2 Guests are viewing this topic.

xdcad

  • Swamp Rat
  • Posts: 527
[XDrX-PlugIn(11)] Single line To double line
« on: November 27, 2023, 05:46:14 AM »
Yesterday, I discussed with my friends on the forum the problem of xdrx-curve-getsplitcurves interrupting ultra-short-term lines. I felt that it was suitable for the following, so I wrote it.
xdrx-curve-getsplitcurves is not used here, but xdrx-curve-intersectbreak is used



After bidirectional offset, all intersection points are interrupted, and then a tolerance "_shortlen" is defined. Anything less than this is deleted, and the short lines at the lower intersection corners are cleaned up.



Code - Auto/Visual Lisp: [Select]
  1. (defun c:tt ()
  2.   (defun _delete-shortlen (ss)
  3.     (mapcar '(lambda (x)
  4.                (if (< (xdrx-getpropertyvalue x "length") _shortlen)
  5.                  (xdrx-entity-delete x)
  6.                )
  7.              )
  8.             (xdrx-pickset->ents ss)
  9.     )
  10.   )
  11.   (setq _shortlen 10.0);;define shortlen length
  12.   (if (and (setq ss (xdrx-ssget
  13.                       "\nSelect a double-line curve <Exit>:"
  14.                       '((0 . "line,*polyline,arc"))
  15.                     )
  16.            )
  17.            (setq wid (getreal "\nDouble line width<exit>:"))
  18.       )
  19.     (progn
  20.       (xdrx-begin)
  21.       (xdrx-setmark)
  22.       ;; Mark the newly generated entity
  23.       (mapcar '(lambda (x)
  24.                  (xdrx-curve-offset x (/ wid 2.0))
  25.                  (xdrx-curve-offset x (- (/ wid 2.0)))
  26.                )
  27.               (xdrx-pickset->ents ss)
  28.       )
  29.       (setq ss1 (xdrx-getss))
  30.       ;;The newly generated entity after getting the mark
  31.       (xdrx-setproperty ss1 "color" 7)
  32.       (setq ss2 (xdrx-curve-intersectbreak ss1))
  33.       ;;All curves in the selection set are interrupted at the intersection points
  34.       (_delete-shortlen ss2)
  35.       (xdrx-end)
  36.     )
  37.   )
  38.   (princ)
  39. )
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
https://github.com/xdcad
https://sourceforge.net/projects/xdrx-api-zip/
http://bbs.xdcad.net

hcbn1997

  • Newt
  • Posts: 31
Re: [XDrX-PlugIn(11)] Single line To double line
« Reply #1 on: December 03, 2023, 03:14:40 AM »
SO GOOD, THANKS BRO