[LISP][原创]铁路线绘制
;把spline变成铁路线示图<BR>;ljc 2004.3<BR>(DEFUN O1O( name cd / cm tc os q zd qd ang qdz zdy w1 w2 w3 w4 p1p2 p3 p4 ) ;name--spline的图元名 cd铁路线的宽度<BR> (setq cm(getvar "cmdecho") tc(getvar "clayer") os(getvar "osmode"))<BR> (command "osnap" "off")<BR> (setq cd(/ cd 2))<BR> (setq q(entget name))<BR> (setq Zd (cdr(assoc 10 q)))<BR> (setq qd (cdr(LAST q))) <BR> (SETQ ANG (ANGLE QD ZD))<BR> (SETQ qdz (polar qd (+ ANG ( / PI 2)) cd))<BR> (setq qdy (polar qd (- ANG ( / PI 2)) cd))<BR> (command "offset" cd name qdz "")<BR> (setq w1(entlast)) <BR> (setq p1 (cdr(assoc 10 (entget w1))))<BR> (setq p2 (cdr(last (entget w1))))<BR> (command "offset" cd name qdy "") <BR> (setq w2(entlast)) <BR> (setq p4 (cdr(assoc 10 (entget w2))))<BR> (setq p3 (cdr(last (entget w2)))) <BR> (command "line" p1 p4 "") (setq w3(entlast)) <BR> (command "line" p2 p3 "") (setq w4(entlast)) <BR> (command "-bhatch" "p" "solid" "s" w1 w2 w3 w4 "" "")<BR> (command "erase" w1 w2 w3 w4 name "")<BR> (setvar "cmdecho" cm)<BR> (setvar "osmode" os)<BR> (setvar "clayer" tc)<BR>)<BR>(defun c:tl( / line n0 j linex q qd zd cdd ang qdz dqy)<BR> (setq cm(getvar "cmdecho") tc(getvar "clayer") os(getvar "osmode"))<BR> (command "osnap" "off")<BR> (print "请选择铁路线:") (print)<BR> (setq line (ssget '((0 . "SPLINE"))))<BR> (setq ds(getint "请输黑白段长度:"))<BR> (setq cd(getreal "请输入绘制铁路线的宽度:"))<BR> (command "ucs" "" "")<BR> (command "erase" (ssget "x" '((0 . "point"))) "")<BR> (setq n0 (sslength line))<BR> (setq j 0 n2 0)<BR> (repeat n0<BR> (setq linex (ssname line j)) <BR> (setq cdd(/ cd 2))<BR> (setq q(entget linex))<BR> (setq Zd (cdr(assoc 10 q)))<BR> (setq qd (cdr(LAST q))) <BR> (SETQ ANG (ANGLE QD ZD))<BR> (SETQ qdz (polar qd (+ ANG ( / PI 2)) (* 10 cd)))<BR> (setq qdy (polar qd (- ANG ( / PI 2)) (* 10 cd)))<BR> (command "offset" cdd linex qdz linex qdy "")<BR> (command "measure" linex ds "")<BR> (command)<BR> (setq point (ssget "x" '((0 . "point"))))<BR> (setq n (sslength point))<BR> (setq i 0 ii 0)<BR> (repeat n<BR> (setq p1 (cdr(assoc 10 (entget(ssname point i)))))<BR> (command "erase" (ssname point i) "") <BR> (command "zoom" "w" (polar p1 (* pi 0.75) ds ) (polar p1 (* pi -0.25) ds ) )<BR> (command "break" (list (car p1) (cadr p1) (caddr p1)) "@" )<BR> (if (= 2 ii) (setq ii 0))<BR> (if (= 0 ii) (o1o (entlast) cd) (command "erase" (entlast) ""))<BR> (setq ii (1+ ii)) <BR> (setq i (+ i 1))<BR> ) <BR> (setq j (+ j 1)) <BR> (if (= 2 ii) (o1o linex cd) (command "erase" linex ""))<BR> )<BR> (command "zoom" "e" "")<BR>(setvar "cmdecho" cm)<BR> (setvar "osmode" os)<BR> (setvar "clayer" tc)<BR>)<BR>(print "敲入tL运行程序---LJC") (PRINT) <BR><BR>----------------------------------------------<BR>天这样的蓝, 树这样的绿,<BR>生活原来这样的, 安宁和美丽...... 兄弟,你画的铁路在不同比例尺下显示的宽度是不是会变化啊,能不能实现在不同比例尺下显示的是同一宽度啊,也就是说铁路线的符号必须是半比例尺的,我目前在做的程序需要实现这个功能,拜托你帮我思考思考好吗? 不好意思,今天才看到你的回复,我想知道你需要什么样的比例,你能给我一个例子吗? <TABLE class=tablebody2 style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all" width="90%" border=0><TBODY>
<TR>
<TD style="FONT-SIZE: 9pt; LINE-HEIGHT: 12pt" width="100%">
<IMG alt=发贴心情 src="http://www.mjtd.com/bbs/skins/default/topicface/face1.gif" border=0> <B></B><BR>不好意思,你能告诉我 怎么用 谢谢
</TD></TR></TBODY></TABLE> <P>请教兄弟:</P>
<P>错误: 参数类型错误: lselsetp nil</P>
<P>怎么解决</P>
<P> </P> 我们自己使用的简单!三条线,中间这条改一下线形就行了! <TABLE class=tablebody2 style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all" width="90%" border=0>
<TBODY>
<TR>
<TD style="FONT-SIZE: 9pt; LINE-HEIGHT: 12pt" width="100%"><BR>
<P>请教兄弟:我下载后加载运行发现</P>
<P>错误: 参数类型错误: lselsetp nil</P>
<P>怎么解决</P></TD></TR></TBODY></TABLE> 逐行调试! <P>操做</P>
<P>1,先绘制一条spine </P>
<P>2,然后加载lt.lsp</P>
<P>3,在命令行输入lt</P>
<P>4,选择spline,输入宽度及长度</P>
<P>5,黑白段会跟随spine在屏幕中间流动,</P>
<P>6,等待结束</P>
<P> </P> <P>下了 ,只是有个问题长度和宽度应该不限整数 就更好了</P>