Author Topic: [XDrX-PlugIn(79)] SPLINE to Polyline  (Read 374 times)

0 Members and 1 Guest are viewing this topic.

xdcad

  • Swamp Rat
  • Posts: 514
[XDrX-PlugIn(79)] SPLINE to Polyline
« on: January 04, 2024, 04:44:13 AM »
The curves generated by some 3D software are all SPLINE. You can use the following program to convert them into perfect LWPOLYLINE. For curves that cannot be directly converted into LINE or ARC, you can use continuous double arc fitting with first-order derivatives to make them completely smooth.

Keep the fewest nodes, keep only two vertices for straight line segments, and generate arcs for arcs.

API that requires the second update on 2024.01.04




Code: [Select]
(defun c:xdtb_spl2poly (/ ss)
  (xdrx-begin)
  (if (setq ss (xdrx-ssget
(xdrx-string-multilanguage
   "\n选择要转换的SPLINE<退出>:"
   "\nSelect SPLINE to convert<Exit>:"
)
'((0 . "spline"))
       )
      )
    (progn
      (xdrx-setvar "progressenabled" 1)
      (setq ss (xdrx-spline->curve ss t t))
;first T,erase spline, second T,convert lwpolyline
      (xdrx-prompt
(xdrx-string-formatex
  (xdrx-string-multilanguage
    "\n成功转换成 %d 多段线."
    "\nSuccessfully converted to %d polyline."
  )
  (sslength ss)
)
      )
    )
  )
  (xdrx-end)
  (princ)
)
« Last Edit: January 04, 2024, 12:50:09 PM by xdcad »
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