董堃 发表于 2008-4-30 18:04:00

[求助]我的程序为什么会这样

<p>请大侠帮忙</p><p>程序运行后在第二个对话框就不能进行下去了</p><p>老师一个等待符号</p><p></p>

ZZXXQQ 发表于 2008-4-30 18:30:00

<p>程序是自己写的吗?怎么缺对话框指针变量?</p><p>一定要在加载对话框时保存对话框指针,不然后面的UNLOAD_DIALOG无法执行,也没法显示第二个对话框。</p>

董堃 发表于 2008-4-30 18:34:00

<p>自己写的,第二个对话框能显示,但是不能继续完成,达不到要求,</p><p>能不能帮忙解决下,谢谢!</p>

ZZXXQQ 发表于 2008-4-30 18:45:00

只从表面上改了两个程序。先试试。

(defun c:fl()
(if (setq dcl_id (load_dialog "fl")) (progn
(if (new_dialog "fl" dcl_id "") (progn
   (s_img "flimg")
   (s_img "yfimg")
   (s_img "lfimg")
   (action_tile "accept" "(setq k 1)(s_pgon)(done_dialog 1)")
   (action_tile "cancel" "(done_dialog 0)")
   (start_dialog)
)
   (ALERT "Unable to display dialog box!\n无法显示对话框!")
)
   (UNLOAD_DIALOG DCL_ID)
)
(ALERT "Unable to open dialog box!\n无法装载对话框!")
)
(princ)
)
(defun s_pgon()         ;按钮状态判定子程序   
(cond
((= (get_tile "ffl") "1") (c:fangfl))
((= (get_tile "yfl") "1") (c:yuanfl))
((= (get_tile "lfl") "1") (c:lianfl))
)
)

ZZXXQQ 发表于 2008-4-30 19:25:00

本帖最后由 作者 于 2008-5-1 20:14:35 编辑

这是全部改好的程序,再试试。


(defun c:fl ()
(setq re 1)
(if (setq dcl_id (load_dialog "fl")) (progn
(while (> re 0)
   (if (new_dialog "fl" dcl_id "") (progn
    (s_img "flimg")
    (s_img "yfimg")
    (s_img "lfimg")
    (action_tile "accept" "(s_pgon) (done_dialog 1)")
    (setq re (start_dialog))
(if (= re 1) (eval (read extt)))
   )
    (ALERT "Unable to display dialog box!\n无法显示对话框!")
   )
)
   (UNLOAD_DIALOG DCL_ID)
)
(ALERT "Unable to open dialog box!\n无法装载对话框!")
)
(princ)
)
(defun s_pgon ()         ;按钮状态判定子程序
(cond
((= (get_tile "ffl") "1") (setq extt "(c:fangfl)"))
((= (get_tile "yfl") "1") (setq extt "(c:yuanfl)"))
((= (get_tile "lfl") "1") (setq extt "(c:lianfl)"))
)
)
;_______________________________________________________________________
;_______________________________________________________________________
;方法兰绘制子程序
(defun c:fangfl ()
(if (new_dialog "ffl" dcl_id "") (progn
(s_img "flimg")
(set_tile "h" "6")
(set_tile "d1" "25.0")
(set_tile "d2" "50.0")
(set_tile "d3" "25.0")
(set_tile "d4" "50.0")
(action_tile "accept" "(fsd) (done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)")
(setq re1 (start_dialog))
)
(ALERT "Unable to display dialog box!\n无法显示对话框!")
)
(if (= re1 1) (progn
(setq zd (getpoint "\n输入中心点:"))
(setq zxx (car zd))
(setq zxy (cadr zd))
(setq yx (/ d4 2.0))
(setq yy (/ d3 2.0))
(setq kx (/ h 2.0))
(setq ky (/ d1 2.0))
(setq p1 (list (+ zxx yx) (+ zxy yy)))
   (setq p2 (list (- zxx yx) (+ zxy yy)))
    (setq p3 (list (- zxx yx) (- zxy yy)))
   (setq p4 (list (+ zxx yx) (- zxy yy)))
      (setq p5 (list (+ zxx kx) (+ zxy ky)))
       (setq p6 (list (- zxx kx) (+ zxy ky)))
      (setq p7 (list (- zxx kx) (- zxy ky)))
         (setq p8 (list (+ zxx kx) (- zxy ky)))
(command "line" p1 p2 p3 p4 p1 "")
(command "circle" p5 (/ d2 2.0))
(command "circle" p6 (/ d2 2.0))
(command "circle" p7 (/ d2 2.0))
(command "circle" p8 (/ d2 2.0))
))
)
(defun fsd ()
(setqh (abs (atoi (get_tile "h"))))
(setq d1 (abs (atof (get_tile "d1"))))
   (setq d2 (abs (atof (get_tile "d2"))))
    (setq d3 (abs (atof (get_tile "d3"))))
   (setq d4 (abs (atof (get_tile "d4"))))
)
;_____________________________________________________________________________
;_____________________________________________________________________________
;圆法兰绘制子程序
(defun c:yuanfl (/ d df)
(if (new_dialog "yfl" dcl_id "") (progn
(s_img "yfimg")
(set_tile "h" "6")
(set_tile "d1" "10.0")
(set_tile "d2" "30.0")
(set_tile "d3" "50.0")
(set_tile "d4" "20.0")
(action_tile "accept" "(ysd) (done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)")
(setq re1 (start_dialog))
)
(ALERT "Unable to display dialog box!\n无法显示对话框!")
)
(if (= re1 1) (progn
(setq zd (getpoint "\n输入中心点:"))
(command "circle" zd d3 "")(command "circle" zd d4 "")
(setq pp (polar zd (/ pi 2) d2))
(command "circle" pp d1 "")(setq en (entlast))
(command "array" en "" "p" zd h "" "")
))
)
(defun ysd ()
(setqh (abs (atoi (get_tile "h"))))
(setq d1 (abs (atof (get_tile "d1"))))
   (setq d2 (abs (atof (get_tile "d2"))))
    (setq d3 (abs (atof (get_tile "d3"))))
   (setq d4 (abs (atof (get_tile "d4"))))
)
;_____________________________________________________________________________
;_____________________________________________________________________________
;两孔法兰绘制子程序
(defun c:lianfl (/ osm point x1 y1 zd zxx zxy f1 f2 f3 f4 p1 p2 p3 p4)
(if (new_dialog "lfl" dcl_id "") (progn
(s_img "lfimg")
(set_tile "h" "50.0")
(set_tile "d1" "25.0")
(set_tile "d2" "50.0")
(set_tile "d3" "25.0")
(set_tile "d4" "50.0")
(action_tile "accept" "(lsd) (done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)")
(setq re1 (start_dialog))
)
(ALERT "Unable to display dialog box!\n无法显示对话框!")
)
(if (= re1 1) (progn
(setq zd (getpoint "\n输入中心点:"))
(setq zxx (car zd))
(setq zxy (cadr zd))
(setq x1 (- zxx h))
(setq x2 (+ zxx h))
(setq f1 (list x1 zxy))
(setq f2 (list x2 zxy))
(setq f3 (/ d3 2.0))
(setq f4 (/ d4 2.0))
(command "circle" f2 f4)
(command "circle" f2 d2)
(setq en3 (entlast))
(command "circle" f1 f4)
(command "circle" f1 d2)
(setq en1 (entlast))
(command "circle" zd f3)
(command "circle" zd d1)
(setq en2 (entlast))
(setq ang (angle f1 f2))
(setq p1 (polar f1 (+ ang (/ pi 2)) d2))
(setq p2 (polar f1 (- ang (/ pi 2)) d2))
(setq p3 (polar zd (+ ang (/ pi 2)) d1))
(setq p4 (polar zd (- ang (/ pi 2)) d1))
(setq p5 (polar f2 (+ ang (/ pi 2)) d2))
(setq p6 (polar f2 (- ang (/ pi 2)) d2))
(command "line" "tan" p1 "tan" p3 "")
(setq rn1 (entlast))
(command "line" "tan" p2 "tan" p4 "")
(setq rn2 (entlast))
(command "line" "tan" p5 "tan" p3 "")
(setq rn3 (entlast))
(command "line" "tan" p6 "tan" p4 "")
(setq rn4 (entlast))
(command "trim" rn1 rn2 rn3 rn4 ""
            (list en1 (polar f1 ang d2))
      (list en3 (polar f2 ang (* -1 d2)))
            (list en2 (polar zd angd1))
      (list en2 (polar zd ang (* -1 d1))) "")
))
(princ)
)
(defun lsd ()
(setqh (abs (atof (get_tile "h"))))
(setq d1 (abs (atof (get_tile "d1"))))
   (setq d3 (abs (atof (get_tile "d3"))))
    (setq d4 (abs (atof (get_tile "d4"))))
)
(defun s_img (key)         ;图像加载子程序
(cond
((= key "flimg") (setq sld "ffl"))
((= key "yfimg") (setq sld "yfl"))
((= key "lfimg") (setq sld "lfl"))
)
(setq tmpx (dimx_tile key))
(setq tmpy (dimy_tile key))
(start_image key)
(fill_image 0 0 tmpx tmpy -2)
(slide_image 0 0 tmpx tmpy sld)
(end_image)
)

fl:dialog {
label="法兰设计专家【参数设计】";
spacer;
:row {
label="法兰样式";
:column {
   :text {label="         方法兰";}
   :image {key="flimg";width=30;aspect_ratio=1;color=0;fixed_width=true;}
}
:column {
   :text {label="             圆法兰";}
   :image {key="yfimg";width=30;aspect_ratio=1;color=0;fixed_width=true;}
}
:column {
   :text {label="         两孔法兰";}
   :image {key="lfimg";width=30;aspect_ratio=1;color=0;fixed_width=true;}
}
}
spacer_1;
:radio_row {
label="选择法兰样式";
:spacer {width=7;}
:radio_button {key="ffl";label="绘制方法兰";value="1";}
:spacer {width=10;}
:radio_button {key="yfl";label="绘制圆法兰";value="0";}
:spacer {width=12;}
:radio_button {key="lfl";label="绘制两孔法兰";value="0";}
:spacer { }
}
spacer_1;
ok_cancel;
}
ffl:dialog {
label="法兰设计专家【方法兰参数】";
:column {
fixed_width=true;
:image {key="flimg";width=70;aspect_ratio=1;color=0;fixed_width=true;}
:spacer { }
:column {
   label="参数输入";
   :row {
    :edit_box {key="d4";label="外形x";value="60";}
    :edit_box {key="d2";label="孔径";value="10";}
    :edit_box {key="d3";label="外形y";value="60";}
   }
   :row {
    :edit_box {key="h";label="孔距x";value="40";}
    :spacer {width=16;}
    :edit_box {key="d1";label="孔距y";value="30";}
   }
   :spacer { }
}
:spacer { }
}
ok_cancel;
}
yfl:dialog {
label="法兰设计专家【圆法兰参数】";
:column {
:spacer { }
:image {key="yfimg";width=70;aspect_ratio=1;color=0;fixed_width=true;}
:column {
   label="参数输入";
   :row {
    :edit_box {key="d4";label="大孔半径";value="20";}
    :edit_box {key="d2";label="分度圆半径";value="30";}
    :edit_box { key="d3";label="大圆半径";value="50";}
   }
   :row {
    :edit_box {key="h";label="小孔个数";value="6";}
    :spacer {width=24;}
    :edit_box {key="d1";label="小孔直径";value="10";}
   }
   :spacer { }
}
:spacer { }
}
ok_cancel;
}
lfl:dialog {
label="法兰设计专家【两孔法兰参数】";
:column {
:spacer { }
:image {key="lfimg";width=70;aspect_ratio=1;color=0;fixed_width=true;}
:column {
   label="参数输入";
   :row {
    :edit_box {key="d4";label="大圆半径";value="50";}
    :spacer {width=24;}
    :edit_box {key="d3";label="小圆半径";value="30";}
   }
   :row {
    :edit_box {key="h";label="小孔距离";value="50";}
    :spacer {width=24; }
    :edit_box {key="d1";label="小孔直径";value="15";}
   }
   :spacer { }
}
:spacer { }
}
ok_cancel;
}

董堃 发表于 2008-4-30 20:09:00

<p><strong><font face="Verdana" color="#da2549">ZZXXQQ</font></strong><strong><font face="Verdana" color="#da2549">版主</font></strong></p><p><font face="Verdana" color="#000000"><strong>出现</strong><font color="#ff00ff">Unable to display dialog box!\n无法显示对话框!</font>&nbsp;&nbsp; </font></p>

董堃 发表于 2008-4-30 20:27:00

本帖最后由 作者 于 2008-4-30 20:32:24 编辑 <br /><br /> <p>参数类型错误: numberp: nil</p><p>第二个对话框没有图像了</p>

董堃 发表于 2008-4-30 21:21:00

<p>改成这样后</p><p></p><p>出现</p><p>命令: fl<br/>; 错误: 参数类型错误: numberp: nil<br/>命令:</p>

ZZXXQQ 发表于 2008-5-1 20:17:00

<strong>五楼已改。</strong>

董堃 发表于 2008-5-3 18:16:00

<p><font face="Verdana" color="#da2549"><font color="#000000">谢谢</font><strong>ZZXXQQ</strong></font></p><p><strong><font face="Verdana" color="#da2549"></font></strong></p>
页: [1] 2
查看完整版本: [求助]我的程序为什么会这样