明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3565|回复: 5

一段spline转化成polyline的代码,但是和原图有误差,请高手指点。

[复制链接]
发表于 2003-12-8 15:55:00 | 显示全部楼层 |阅读模式
(defun c:sptrace (/ ent spline cur pl end keep)
(setq cur nil)
(setq pl '((0 . "LWPOLYLINE")
     (100 . "AcDbEntity")
     (67 . 0)
     (8 . "0")
     (100 . "AcDbPolyline")
     (90 . 7)
     (70 . 0)
     (43 . 0.0)
     (38 . 0.0)
     (39 . 0.0)
    )
   )
(setq end '(210 0.0 0.0 1.0));define polyline group codes
(while (not (progn (princ "\rSelect Spline: ") ;select spline to convert
    (setq spline (ssget ":s" '((0 . "SPLINE"))))
     )
)
)
(initget "Yes No")
(setq keep (getkword "Keep Original Spline [Yes/No]: "));keep original line or not
(setq spline (ssname spline 0)); get ename
(if (/= keep "No")
   (progn
     (entmake (entget spline));copy spline
     (setq spline (entlast));get ename of new spline
     )
   )
(setq ent spline); copy ename to new variable
(command "splinedit" ent "refine" "elevate" 26 "x" "x");add extra control points
(setq ent (entget ent)); get data for spline
(setq pl (subst (assoc 8 ent) (assoc 8 pl) pl)); set polylines layer to same as spline
(if (= (rem (cdr (assoc 70 ent)) 2) 1);is spline closed
   (setq pl (subst (cons 70 1) (assoc 70 pl) pl));set polyline closed
   (setq pl (subst (cons 70 0) (assoc 70 pl) pl));set polyline open
)
(repeat (length ent);loop
   (progn
     (if (eq (car (car ent)) 10);get control point data
(setq cur (append cur (list (car ent))))
     )
     (setq ent (cdr ent));get next element in list
   )
)
(setq pl (subst (cons 90 (length cur)) (assoc 90 pl) pl));set number of points in polyline
(repeat (length cur);loop
   (progn;add polyline point data
     (setq pl
    (append
      pl
      (list (car cur) (cons 40 0.0) (cons 41 0.0) (cons 42 0.0))
    )
     )
     (setq cur (cdr cur));get next element in list
   )
)
(setq pl (append pl (list end)));add normal vector to polyline data
(entmake pl);make polyline
(entdel (cdr (assoc -1 (entget spline))));entdel spline, original or copy
(princ);exit quietly
)
发表于 2003-12-8 16:02:00 | 显示全部楼层
本帖最后由 作者 于 2003-12-8 16:37:21 编辑

。。。
发表于 2003-12-25 07:57:00 | 显示全部楼层
是 啊,误差比较大啊,有改进的方法吗
发表于 2003-12-29 05:26:00 | 显示全部楼层
要用vla方法才行
发表于 2004-6-29 06:01:00 | 显示全部楼层
请教无痕老师,vla方法的详细解释?恕我无知!
发表于 2004-6-29 08:35:00 | 显示全部楼层
不用VLA吧,VL扩展函数就可以了


参考帮助文件中函数参考中的VISUAL LISP扩展函数,曲线测量中的部分函数,应该就明白了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-10-1 02:32 , Processed in 0.171981 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表