乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 66|回复: 5

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

[复制链接]

8

主题

17

帖子

2

银币

初来乍到

Rank: 1

铜币
49
发表于 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
)
回复

使用道具 举报

6

主题

60

帖子

3

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
84
发表于 2003-12-8 16:02:00 | 显示全部楼层

。。。
回复

使用道具 举报

4

主题

11

帖子

5

银币

初来乍到

Rank: 1

铜币
27
发表于 2003-12-25 07:57:00 | 显示全部楼层
是 啊,误差比较大啊,有改进的方法吗
回复

使用道具 举报

20

主题

872

帖子

10

银币

中流砥柱

Rank: 25

铜币
952
发表于 2003-12-29 05:26:00 | 显示全部楼层
要用vla方法才行
回复

使用道具 举报

2

主题

6

帖子

2

银币

初来乍到

Rank: 1

铜币
14
发表于 2004-6-29 06:01:00 | 显示全部楼层
请教无痕老师,vla方法的详细解释?恕我无知!
回复

使用道具 举报

26

主题

3072

帖子

10

银币

社区元老

Rank: 75Rank: 75Rank: 75

铜币
3177
发表于 2004-6-29 08:35:00 | 显示全部楼层
不用VLA吧,VL扩展函数就可以了
参考帮助文件中函数参考中的VISUAL LISP扩展函数,曲线测量中的部分函数,应该就明白了
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-8-18 19:29 , Processed in 2.694746 second(s), 65 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表