调用DCL、LISP中的输入
你好!我正在同时探索lisp和dcl。我的DCL如下所示。每当完成命令并再次执行相同命令时,值都会重置(pic2)。
我希望在按“Ok”编辑特定输入而不是再次键入整个数据后,每当我再次使用dcl时,这些值都保持不变。我怎么可能这么做?
这是我使用的dcl代码。
CHECKING : dialog {
label = "CHECKING";
: row {
:boxed_row {
label = "PARAMETERS";
: edit_box { key = "a"; label = "Wind Pressure (kPa)"; edit_width = 8;}
: edit_box {key = "b"; label = "Tributary Width (mm)"; edit_width = 8;}
: edit_box {key = "c"; label = "Unsupported Length (mm)"; edit_width = 8;}
}
}
: row {
:boxed_column {
label = "SECTION PROPERTIES (ALUMINUM)";
: edit_box { key = "d"; label = "Moment of Inertia (mm^4)"; edit_width = 8;}
: edit_box {key = "e"; label = "Area (mm^2)"; edit_width = 8;}
: edit_box {key = "f"; label = "Extreme Fiber (mm)"; edit_width = 8;}
: edit_box {key = "g"; label = "Allowable Stress (MPa)"; edit_width = 8;}
}
:boxed_column {
label = "SECTION PROPERTIES (STEEL)";
: edit_box { key = "h"; label = "Moment of Inertia (mm^4)"; edit_width = 8;}
: edit_box {key = "i"; label = "Area (mm^2)"; edit_width = 8;}
: edit_box {key = "j"; label = "Extreme Fiber (mm)"; edit_width = 8;}
: edit_box {key = "k"; label = "Allowable Stress (MPa)"; edit_width = 8;}
}
}
: button {
key = "accept";
label = " &OK ";
is_default = true;
mnemonic = "S";
}
: button {
key = "cancel";
label = " Cancel ";
is_default = false;
is_cancel = true;
}
}
这是lisp代码:
(defun saveVars()
(setq wp(distof(get_tile "a")))
(setq tw(distof(get_tile "b")))
(setq L(distof(get_tile "c")))
(setq Im(distof(get_tile "d")))
(setq Am(distof(get_tile "e")))
(setq cm(distof(get_tile "f")))
(setq Fbm(distof(get_tile "g")))
(setq Is(distof(get_tile "h")))
(setq As(distof(get_tile "i")))
(setq cs(distof(get_tile "j")))
(setq Fbs(distof(get_tile "k")))
)
(defun C:CC()
(if(not(setq dcl_id (load_dialog "CHECKING.dcl")))
(progn
(alert "The DCL file could not be loaded!")
(exit)
)
(progn
(if (not(new_dialog "CHECKING" dcl_id))
(progn
(alert "CHECKING.DCL file could not be loaded!")
(exit)
)
(progn
(action_tile "accept" "(saveVars)(done_dialog 2)")
(action_tile "cancel" "(done_dialog 1)")
(setq ddiag(start_dialog))
(unload_dialog dcl_id)
(if(= ddiag 1)
(princ "\n END")
)
(if(= ddiag 2)
(progn
(setq IT(+ Im (* 2.87 Is)))
(setq moment(/ (* wp tw L L) 8000))
(setq stress(/ (* moment cm) Im))
(setq stressratio(/ stress Fbm))
(setq deflection(/ (* 5 wp tw L L L L) (* 384000 69600 IT)))
(setq allowdeflection(/ L 175))
(setq defratio(/ deflection allowdeflection))
(setq pt1 (getpoint))
(setq pt2 (getpoint))
(command "_mtext" pt1 pt2 "\n Actual Bending Stress =" (rtos stress 2 2)
"\n Allowable Bending Stress =" (rtos Fbm 2 2)
"\n Stress Ratio =" (rtos stressratio 2 2)
"\n Actual Deflection =" (rtos deflection 2 2)
"\n Allowable Deflection =" (rtos allowdeflection 2 2)
"\n Deflection Ratio =" (rtos defratio 2 2) ""
)
)
)
)
)
)
)
)
还有一件事。关于多行文字输出。输出是这样的。数值结果总是出现在下一行。
我希望结果是这样的,单位是文本(兆帕,毫米,等等)
有人对此有意见吗?提前感谢。:)
另一个。dcl中带有mm^4和mm^2的标签,如何在没有“^”符号的情况下进行上标。我在网上找不到它。
dcl非常有限,所以可能不可能,还没有研究过。
只是快速修复,现在没有太多时间
(defun C:CC () ; normally you would declare all your variables here
(if (not(setq dcl_id (load_dialog "CHECKING.dcl")))
(progn (alert "The DCL file could not be loaded!") (exit))
(progn (if (not (new_dialog "CHECKING" dcl_id))
(progn (alert "CHECKING.DCL file could not be loaded!") (exit))
(progn (cc_set_tiles);;; added this to set your variables
(action_tile "accept" "(saveVars)(done_dialog 2)")
(action_tile "cancel" "(done_dialog 1)")
(setq ddiag (start_dialog))
(unload_dialog dcl_id)
(if (= ddiag 1)
(princ "\n END"))
(if (= ddiag 2)
(progn (setq IT (+ Im (* 2.87 Is)))
(setq moment (/ (* wp tw L L) 8000))
(setq stress (/ (* moment cm) Im))
(setq stressratio (/ stress Fbm))
(setq deflection (/ (* 5 wp tw L L L L) (* 384000 69600 IT)))
(setq allowdeflection (/ L 175))
(setq defratio (/ deflection allowdeflection))
(setq pt1 (getpoint "\nGet 1st point : "))
(setq pt2 (getcorner pt1 "\nGet 2nd point : "))
(setq msg (strcat "\nActual Bending Stress = "
(rtos stress 2 2)
"\nAllowable Bending Stress = "
(rtos Fbm 2 2)
"\nStress Ratio = "
(rtos stressratio 2 2)
"\nActual Deflection = "
(rtos deflection 2 2)
"\nAllowable Deflection = "
(rtos allowdeflection 2 2)
"\nDeflection Ratio = "
(rtos defratio 2 2)))
(apply 'vl-cmdf (list "_mtext" pt1 pt2 msg "")))))))))
; tl = tile list / vl = variable list
(defun cc_set_tiles ( / tl vl)
(mapcar '(lambda (x y) (set_tile x (if (null (vl-symbol-value y)) "" (vl-princ-to-string (vl-symbol-value y)))))
(list "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k") (list 'wp 'tw 'L 'Im 'Am 'cm 'Fbm 'Is 'As 'cs 'Fbs))
)
Rlx更快,无论如何,还有另一种方法:
(defun C:CC(/);正如Rlx所说,通常您会在这里声明所有变量;;此子函数将获取所有互动程序的值,并返回(
我为一些亚洲语言编写了utf-8函数,所以我很确定dcl支持unicode
mm^2=mm\U+00B2
mm^4=mm\U+2074
我同意Grrr的观点,我宁愿将一个值列表存储到一个变量(*MyList*),也不愿在我的绘图中有一组变量。但从lisp开始,这可能有点挑战性。尽管如此,为什么不在高速公路上用正确的方式学习呢
吉普,效果很好!很高兴知道!thanx! 顺便说一句,Op的代码没有数据(输入)检查什么,但让他(或她)休息一下(现在)
哦,忘记了Op第一篇文章中的最后一个问题:你创建了一个多行文字,所以你的getpoints的形状(我使用getpoint+getcorner)决定了你的行是否被剪短。只需选择一个更宽的矩形。。。如果它仍然太短,只需点击刚刚创建的多行文字并拖动它。。。明白吗?
是的,为变量编写太多的代码是一种痛苦,而这足以将它们存储在一个列表中。
也许每个人都达到了OP的水平,所以我尽量不把他搞糊涂,故意避免使用太多地图车和lambda。
我也注意到了这一点,但我建议OP尽量缩短和更好地理解他的代码,然后进行任何未来的改进/修复。
所以我认为一个简单的列表操作和使用foreach函数对他来说是一个很好的开始
我不知道一个人能写出四次unicode字符,很好!
啊,刚刚记得(我出错的地方),当我回来时,我尝试用CHR处理一些特殊字符,它确实有效(对于一些字符),但当我在家运行相同的代码时,结果完全不同。所以我确实应该使用UTF-8(如果我要使用它,很少使用特殊字符),但知道它总是很好的
哦,快到周末了,祝你们周末愉快
页:
[1]
2