lisp需要一些帮助
你好我对lisp文件有一个小问题,该文件从DWG中提取坐标,并用前缀和计数器标记它们,然后将它们导出到文本文件。
如果有人能建议如何正确退出这个Lisp程序,我将不胜感激。
(defun run ()
(setq pll (getstring "\nPlease Enter of new file (name.ext) :"))
(setq pl (open pll "w"))
(setq ang ( getreal "\nPlease Enter DV Angle: " ) )
(setq n ( getstring "\nPlease Enter TAXI name: " ) )
(initget (+ 1 2 4))
(setq a ( getint "\nPlease Enter MH number: " ) )
;(setq e (getstring "\nget no. of first Point :"))
;(setq a (atoi e))
(while (> a 0)
(setq aa 1)
(while (<= aa 4)
(setq p (getpoint "\nselect point :"))
(setq v1 (strcat "\n " (itoa a) " " (itoa aa) " "))
(setq d (polar p (dtr 90) 0))
(setq f (itoa aa))
(setq k (itoa a))
(setq g (strcat n "-" k "-P-" f))
(command "layer" "m" "number" "c" "3" "" "")
(command "text" "m" d 0.2 ang g)
(setq num (entlast))
;(command "change" num "" "layer" "" number "")
(command "change" num "" "p" "layer" "number" "")
(command "layer" "m" "point" "c" "1" "" "")
(command "point" p)
(setq pt (entlast))
;(command "change" pt "" layer "" point "")
(command "change" pt "" "p" "layer" "point" "")
(setq x (car p))
(setq x (rtos x 2 4))
(setq x (strcat x " "))
(setq v2 x)
(setq y (cadr p))
(setq y (rtos y 2 4))
(setq y (strcat y " "))
(setq v3 y)
(princ V1 pl)
(princ v2 pl)
(princ v3 pl)
(setq aa (+ aa 1))
)
(setq a (+ a 1))
)
(command "layer" "m" "txt" "c" "5" "" "")
(close pl)
(redraw)
(princ)
)
(defun c:I ()
(run)
(setq fil (getstring "\nget name of the file (name.ext) :"))
(setq p1 (getpoint "select insertion point :"))
(setq p2 (polar p1 0.0 35.0))
(setq p3 (polar p1 0.0 105.0))
(setq p4 (polar p1 (/ (* -1 pi) 2) 20.0))
(setq p5 (polar p4 0.0 35.0))
(setq p6 (polar p4 0.0 70.0))
(setq p7 (polar p4 0.0 105.0))
(setq p8 (polar p2 (/ (* -1 pi) 2) 10.0))
(setq p9 (polar p8 0.0 35.0))
(setq p10 (polar p8 0.0 70.0))
(setq p11 (polar p8 (* -1 pi) 15.0))
(setq p12 (polar p8 (/ pi 2) 5.0))
(setq p13 (polar p8 (/ (* -1 pi) 2) 5.0))
(setq p14 (polar p12 0.0 35.0))
(setq p15 (polar p13 0.0 17.5))
(setq p16 (polar p13 0.0 52.5))
(setq p1- (polar p1 (/ (* -1 pi) 2) 2000000000.0))
(command "text" "m" p11 3.0 0.0 "POINT NO.")
(command "text" "m" p14 3.0 0.0 "COORDINATES")
(command "text" "m" p15 3.0 0.0 "X")
(command "text" "m" p16 3.0 0.0 "Y")
(command "line" p1 p4 "")
(setq L14 (entlast))
(command "line" p2 p8 p5 "")
(setq L285 (entlast))
(command "line" p9 p6 "")
(setq L96 (entlast))
(command "line" p3 p10 p7 "")
(setq L3107 (entlast))
(command "line" p1 p2 p3 "")
(command "line" p8 p9 p10 "")
(command "pline" p4 p5 p6 p7 "")
(setq L4567 (entlast))
(setq fill (open fil "r"))
(read-line fill)
(setq new ())
(setq j 0.0)
(setq p44 p4)
(while (setq S (read-line fill))
(setq pt (polar p44 (/ (* -1 pi) 2) (+ 5 j)))
(setq pt1 (polar pt 0.0 12.5))
(setq pt2 (polar pt 0.0 50))
(setq pt3 (polar pt 0.0 85))
(setq t1 (substr S 1 4))
(setq t11 (strcat n t1))
(setq t2 (substr S 5 18))
(setq t3 (substr S 23 32))
(command "text" "m" pt1 3.0 0.0 t11)
(command "text" "m" pt2 3.0 0.0 t2)
(command "text" "m" pt3 3.0 0.0 t3)
(setq p4 (polar p4 (/ (* -1 pi) 2) 10.0))
(setq p5 (polar p5 (/ (* -1 pi) 2) 10.0))
(setq p6 (polar p6 (/ (* -1 pi) 2) 10.0))
(setq p7 (polar p7 (/ (* -1 pi) 2) 10.0))
(command "offset" (+ j 10.0) (list L4567 p4) p1- "")
(setq new (entlast))
(command "extend" new "" (list L14 P4) "")
(command "extend" new "" (list L285 p5) "")
(command "extend" new "" (list L96 p6) "")
(command "extend" new "" (list L3107 p7) "")
(setq j (+ j 10.0))
)
;(close)
(close fill)
)
(defun dtr (x)
;define degrees to radians function
(* pi ( / x 180.0))
;divide the angle by 180 then
;multiply the result by the constant PI
)
(princ)
最后的
(setq mytext (strcat "Row1" "\\P" "row2" "\\P" "row3"))
(command "MTEXT" "0,0" "Height" 50"Width" "0" mytext "")
谢谢你的支持。
昨天,我为主循环添加了一个上限,它确实对我起了作用。
(defun run()(setq pll(getstring”\n请输入新文件(name.ext):)(setq pl(open pll“w”)(setq ang(getreal”\n请输入DV角度:)(setq n(getstring”\n请输入出租车名称:)(initget(+1 2 4))(setq a(getint”\n请输入第一个MH的编号:)(setq als(getint”\n请输入最后一个MH的编号:);(setq e(getstring“\n第一点的设置编号:”);(setq a(atoi e))(而(
页:
[1]