请求大神帮忙将以下代码修改成循环的代码
(defun c:1()(setq cmdmode (getvar "cmdecho"))
(setvar "cmdecho" 0)
(if (= dir_lisp nil)
(command "insert" "d:\\autolisp\\lispblock" '(quit)))
(setq dir_lisp "d:\\Autolisp\\")
(dcl_auto)
(prin1)
)
(defun dcl_auto()
(setq dcl_id (load_dialog (strcat dir_lisp "dcl\\auto")))
(new_dialog "auto" dcl_id)
(def_auto)
(action_tile "cyh_b00001" "(setq ddtype 1) (ok_auto)")
(action_tile "cyh_b00002" "(setq ddtype 2) (ok_auto)")
(action_tile "cyh_b00003" "(setq ddtype 3) (ok_auto)")
(action_tile "cyh_b00004" "(setq ddtype 4) (ok_auto)")
(action_tile "cyh_b00005" "(setq ddtype 5) (ok_auto)")
(action_tile "cyh_b00006" "(setq ddtype 6) (ok_auto)")
(action_tile "cyh_b00007" "(setq ddtype 7) (ok_auto)")
(action_tile "cyh_b10001" "(setq ddtype 11) (ok_auto)")
(action_tile "cyh_b10002" "(setq ddtype 12) (ok_auto)")
(action_tile "cyh_b10003" "(setq ddtype 13) (ok_auto)")
(action_tile "cyh_b10004" "(setq ddtype 14) (ok_auto)")
(action_tile "cyh_b10005" "(setq ddtype 15) (ok_auto)")
(action_tile "cyh_b10006" "(setq ddtype 16) (ok_auto)")
(action_tile "accept" "(ok_auto)")
(setq dd (start_dialog))
(if (= dd 1) (draw_auto))
)
(defun def_auto()
(if (= bl_draw nil)
(set_tile "bili_draw" "2500")
(set_tile "bili_draw" (rtos bl_draw)))
(if (= bl_auto nil)
(set_tile "bili" "1")
(set_tile "bili" (rtos bl_auto)))
(if (= auto_txh nil)
(set_tile "text_h" "2.5")
(set_tile "text_h" (rtos auto_txh)))
(if (= auto_txd nil)
(set_tile "text_d" "1.2")
(set_tile "text_d" (rtos auto_txd)))
(setq sldkey_list '("cyh_b00001" "cyh_b00002" "cyh_b00003" "cyh_b00004" "cyh_b00005" "cyh_b00006" "cyh_b00007" "cyh_b10001" "cyh_b10002" "cyh_b10003" "cyh_b10004" "cyh_b10005" "cyh_b10006"))
(setq sld_list '("cyh_b00001" "cyh_b00002" "cyh_b00003" "cyh_b00004" "cyh_b00005" "cyh_b00006" "cyh_b00007" "cyh_b10001" "cyh_b10002" "cyh_b10003" "cyh_b10004" "cyh_b10005" "cyh_b10006"))
(mapcar 'show_sld sldkey_list sld_list)
(setq ddtype 1)
(mode_tile "cyh_b00001" 2)
)
(defun show_sld(key sld)
(setq x (dimx_tile key))
(setq y (dimy_tile key))
(start_image key)
(fill_image 0 0 x y -2)
(slide_image 0 0 x y (strcat dir_lisp "sld\\" sld))
(end_image)
)
(defun ok_auto()
(setq bl_draw (atof (get_tile "bili_draw")))
(setq bl_auto (atof (get_tile "bili")))
(setq auto_txd (atof (get_tile "text_d")))
(setq auto_txh (atof (get_tile "text_h")))
(setq auto_text (get_tile "changdu"))
(done_dialog 1)
)
(defun draw_auto()
(setq pt0 (getpoint "/n 请输入起点:"))
(setq pt0 (list (car pt0) ( cadr pt0)))
(setq pt0_1 (getpoint pt0))
(setq pt0_1 (list (car pt0_1) ( cadr pt0_1)))
(setq r0 (angle pt0 pt0_1))
(setq myosmode (getvar "osmode"))
(setvar "osmode" 0)
(auto_detext)
(setq i_t 0)
(while (/= (nth i_t auto_ss) nil)
(setq leth_auto (nth i_t auto_ss))
(draw_sample)
(setq i_t (1+ i_t))
)
(setvar "osmode" myosmode)
(setvar "CMDECHO" cmdmode)
(prin1)
)
;分散长字符串
(defun auto_detext()
(setq auto_textlen (strlen auto_text))
(setq text_t "")
(setq auto_ss nil)
(while (> auto_textlen 0)
(setq txet_c (substr auto_text 1 1))
(if (/= txet_c "+")
(setq text_t (strcat text_t txet_c))
(if (/= text_t"")
(progn
(setq auto_ss (cons text_t auto_ss))
(setq text_t ""))))
(setq auto_text (substr auto_text 2 (- (strlen auto_text) 1)))
(if (and (< auto_textlen 2) (/= text_t""))
(progn
(setq auto_ss (cons text_t auto_ss))
(setq text_t "")))
(setq auto_textlen (1- auto_textlen)))
(setq auto_ss (reverse auto_ss))
)
;画单个组件
(defun draw_sample()
(setq bl_draw1 (/ 1000 bl_draw))
(setq pt1 (polar pt0 r0 (* bl_auto 1.5)))
(setq pt2 (polar pt0 r0 (- (* (atof leth_auto) bl_draw1) (* bl_auto 1.5))))
(setq pt1_1 (polar pt0 r0 (* bl_auto 2.1)))
(setq pt2_1 (polar pt0 r0 (- (* (atof leth_auto) bl_draw1) (* bl_auto 2.1))))
(setq pt3 (polar pt0 r0 (* (atof leth_auto) bl_draw1)))
(setq pt4 (polar (polar pt0 r0 (/ (* (atof leth_auto) bl_draw1) 2)) (+ r0 (/ PI 2)) auto_txd))
(cond ((= ddtype 1)
(progn
(command "layer" "s" "0" "")
(command "pline" pt1 "w" 0.5 0.5 pt2 "")
(command "layer" "s" "0" "")
(command "insert" "cyh_a00001" "x" bl_auto "y" bl_auto "r" 0 pt3 "")))
((= ddtype 2)
(progn
(command "layer" "s" "0" "")
(command "pline" pt1 "w" 0.5 0.5 pt2 "")
(command "layer" "s" "0" "")
(command "insert" "cyh_a00002" "x" bl_auto "y" bl_auto "r" 0 pt3 "")))
((= ddtype 3)
(progn
(command "layer" "s" "0" "")
(command "pline" pt1 "w" 0.5 0.5 pt2 "")
(command "layer" "s" "0" "")
(command "insert" "cyh_a00003" "x" bl_auto "y" bl_auto "r" 0 pt3 "")))
((= ddtype 4)
(progn
(command "layer" "s" "0" "")
(command "pline" pt1 "w" 0.5 0.5 pt2 "")
(command "layer" "s" "0" "")
(command "insert" "cyh_a00004" "x" bl_auto "y" bl_auto "r" 0 pt3 "")))
((= ddtype 5)
(progn
(command "layer" "s" "0" "")
(command "pline" pt1 "w" 0.5 0.5 pt2 "")
(command "layer" "s" "0" "")
(command "insert" "cyh_a00005" "x" bl_auto "y" bl_auto "r" 0 pt3 "")))
((= ddtype 6)
(progn
(command "layer" "s" "0" "")
(command "pline" pt1 "w" 0.5 0.5 pt2 "")
(command "layer" "s" "0" "")
(command "insert" "cyh_a00006" "x" bl_auto "y" bl_auto "r" 0 pt3 "")))
((= ddtype 7)
(progn
(command "layer" "s" "0" "")
(command "pline" pt1 "w" 0.5 0.5 pt2 "")
(command "layer" "s" "0" "")
(command "insert" "cyh_a00007" "x" bl_auto "y" bl_auto "r" 0 pt3 "")))
((= ddtype 11)
(progn
(command "layer" "s" "0" "")
(command "pline" pt1 "w" 0.5 0.5 pt2 "")
(command "layer" "s" "0" "")
(command "insert" "cyh_a10001" "x" bl_auto "y" bl_auto "r" (/ (* r0 180) PI) pt3 "")))
((= ddtype 12)
(progn
(command "layer" "s" "0" "")
(command "pline" pt1 "w" 0.5 0.5 pt2 "")
(command "layer" "s" "0" "")
(command "insert" "cyh_a10002" "x" bl_auto "y" bl_auto "r" (/ (* r0 180) PI) pt3 "")))
((= ddtype 13)
(progn
(command "layer" "s" "0" "")
(command "pline" pt1 "w" 0.5 0.5 pt2 "")
(command "layer" "s" "0" "")
(command "insert" "cyh_a10003" "x" bl_auto "y" bl_auto "r" (/ (* r0 180) PI) pt3 "")))
((= ddtype 14)
(progn
(command "layer" "s" "0" "")
(command "pline" pt1 "w" 0.5 0.5 pt2 "")
(command "layer" "s" "0" "")
(command "insert" "cyh_a10004" "x" bl_auto "y" bl_auto "r" (/ (* r0 180) PI) pt3 "")))
((= ddtype 15)
(progn
(command "layer" "s" "0" "")
(command "pline" pt1 "w" 0.5 0.5 pt2 "")
(command "layer" "s" "0" "")
(command "insert" "cyh_a10005" "x" bl_auto "y" bl_auto "r" (/ (* r0 180) PI) pt3 "")))
((= ddtype 16)
(progn
(command "layer" "s" "0" "")
(command "pline" pt1 "w" 0.5 0.5 pt2 "")
(command "layer" "s" "0" "")
(command "insert" "cyh_a10006" "x" bl_auto "y" bl_auto "r" (/ (* r0 180) PI) pt3 "")))
)
(command "text" "s" "cyh_y00001" "j" "c" pt4 auto_txh (/ (* r0 180) PI) leth_auto)
(setq pt0 pt3)
)
因为整个功能要实,还涉及到图块以及dcl和sld文件,文件较多,没有一一上传。
dcl里面有一个输入长度的位置,但我并不想在dcl对话里面输入,而是手动输入,原输入格式是如50+64+54
长度在本代码里面是(setq auto_text (get_tile "changdu"))
还想实现将代码循环,每输入一个长度,运行一次代码,前一次终点为下一次起点,并询问是否设置新的角度
先谢谢大神 又一个搞通信的同行。 想到一块去了,我也准备这么弄 兄弟弄出来了吗?
页:
[1]