明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1422|回复: 0

请各位帮我看看这个程序问题出在什么地方?

[复制链接]
发表于 2005-6-17 17:22:00 | 显示全部楼层 |阅读模式
;(defun c:test()
;(setq file-new (getfiled "选择数据文件" "d:/" "dat" 8))
;(setq zg (getreal " 输入字高< 0.4 >:"))
;(if (not zg) (setq ZG 0.4))
;(command "layer" "m" "kzd" "color" "red" "" "")
;(setq file (open file-new "r"))
(setq zg 0.4)
(setq BMG "abc" pts nil)
(setq file(open "d://data2.txt" "r"))
(while (setq text0(read-line file))
(setq len (strlen text0)
n1(vl-string-search "," text0)
n2(vl-string-search "," text0 (+ n1 1))
n3(vl-string-search "," text0 (+ n2 1))
n4(vl-string-search "," text0 (+ n3 1))
dh(substr text0 1 n1)
bm(substr text0 (+ n1 2) (- n2 n1 1))
y(atof(substr text0(+ n2 2) (- n3 n2 1)))
x(atof(substr text0(+ n3 2) (- n4 n3 1)))
h(substr text0(+ n4 2) (- len n4 1))
pt-crd(list y x)
pt-dh(list (+ y 0.2) x)
pt-gc(list (+ y 0.5) x)
);setq束

(if (= bmg bm)
(progn
(setq str (vl-string-translate "," " " text0))
(setq str (read (strcat "(" str ")")))
(setq pts (append pts (list (cddr str))))
);progn
(progn
(setq pts2 (mapcar '(lambda (e1 e2) (list (distance e1 e2) e1 e2)) (reverse (cdr (reverse pts))) (cdr pts)))
(setq pts2 (vl-sort pts2 '(lambda (e1 e2) (> (car e1) (car e2)))))
(command "pline")
(mapcar 'command pts)
(command "")
(setq ptm1 (cadar pts2) ptm2 (caddar pts2))
(setq ptc (mapcar '(lambda (e1 e2) (/ (+ e1 e2) 2)) ptm1 ptm2))
(setq ang (angle ptm1 ptm2))
(command "text" "j" "c" ptc zg (angtos ang) bmg)
(setq pts nil str nil)
(setq str (vl-string-translate "," " " text0))
(setq str (read (strcat "(" str ")")))
(setq pts (append pts (list (cddr str))))
);progn
);if
(setq bmg bm)
);while
;-----------------------------------------------------------------
(setq pts2 (mapcar '(lambda (e1 e2) (list (distance e1 e2) e1 e2)) (reverse (cdr (reverse pts))) (cdr pts)))
(setq pts2 (vl-sort pts2 '(lambda (e1 e2) (> (car e1) (car e2)))))
(command "pline")
(mapcar 'command pts)
(command "")
(setq ptm1 (cadar pts2) ptm2 (caddar pts2))
(setq ptc (mapcar '(lambda (e1 e2) (/ (+ e1 e2) 2)) ptm1 ptm2))
(setq ang (angle ptm1 ptm2))
(command "text" "j" "c" ptc zg (angtos ang) bmg)
;-----------------------------------------------------------------
(command "")
(close file)
(command "zoom" "e")
(princ) 这个程序是根据数据文件的数数据,连线并注记线段名称,格式如下: 1,abc,-49.265,382.975,-10.577
2,abc,-49.327,386.58,-10.407
3,abc,-56.292,386.823,-9.923
4,eee,-56.109,383.79,-10.672
5,eee,-56.06,383.707,-10.679
6,eee,-59.786,386.658,-9.742
程序根据第二项即,所有abc的连成一条线,并在最长的那线段间注记上abc;eee的连成另外一条线,且也是要注记eee.谢谢各位
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-17 15:52 , Processed in 0.244871 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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