DJB 发表于 2022-7-8 11:26:47

转换样条曲线

能否将样条线转换回法线/多段线?

Tiger 发表于 2022-7-8 11:43:31

也许会爆炸?

ReMark 发表于 2022-7-8 11:52:46

这应该充分回答您的问题:
 
http://rkmcswain.blogspot.com/2007/06/spline-to-polyline.html

DJB 发表于 2022-7-8 12:04:07

我试过爆炸,但没用

DJB 发表于 2022-7-8 12:10:15

叶喝彩道。
 
这是该链接上有效的解决方案之一
 
另存为R12DXF-如果将图形另存为R12 DXF格式,则所有样条曲线都将转换为多段线图元。
 
 
再次感谢!

Lee Mac 发表于 2022-7-8 12:23:34

写得很快,将来可能会有所帮助:
 

(defun c:sp2pl(/ segs doc spc ss sglen i pt ptlst nPoly)
(vl-load-com)

(setq segs 100)

(setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object))
       spc (if (zerop (vla-get-activespace doc))
             (if (= (vla-get-mspace doc) :vlax-true)
               (vla-get-modelspace doc)
               (vla-get-paperspace doc))
             (vla-get-modelspace doc)))

(if (setq ss (ssget '((0 . "SPLINE"))))
   (progn
   (foreach Obj(mapcar 'vlax-ename->vla-object
                     (vl-remove-if 'listp
                     (mapcar 'cadr (ssnamex ss))))
       (setq sglen (/ (- (vlax-curve-getDistatParam Obj
                           (vlax-curve-getEndParam Obj))
                         (vlax-curve-getDistatParam Obj
                           (vlax-curve-getStartParam Obj))) segs) i -1 ptlst nil)
       (while (and (setq pt (vlax-curve-getPointatDist Obj (* sglen (setq i (1+ i)))))
                   (>= (distance pt (vlax-curve-getEndPoint Obj)) sglen))
         (setq ptlst (cons pt ptlst)))
       (setq ptlst (apply 'append
                        (mapcar '(lambda (x) (list (car x) (cadr x)))
                                  (mapcar '(lambda (x) (trans x 0 1)) ptlst)))
             nPoly (vla-addLightweightPolyline spc
                     (vlax-make-variant
                     (vlax-safearray-fill
                         (vlax-make-safearray
                           vlax-vbDouble
                           (cons 0 (1- (length ptLst)))) ptlst))))
       (vla-put-layer nPoly (vla-get-layer Obj))
         (vla-put-linetype nPoly (vla-get-linetype Obj))
         (vla-put-linetypescale nPoly (vla-get-linetypescale Obj))
             (vla-put-color nPoly (vla-get-color Obj))
               (vla-delete Obj)))
   (princ "\n<!> No Splines Selected <!>"))
(princ))

ReMark 发表于 2022-7-8 12:27:21

JDB非常欢迎你,但真正值得称赞的是R.K.M。我只传递了他出色的建议。很高兴听到你的问题解决了。
页: [1]
查看完整版本: 转换样条曲线