您好,我正在学习lisp,所以我决定写一个代码来计算打印后的纸张长度和打印成本
我知道用excel或计算器很容易计算,但对我来说这是一个练习。
对于我的所有图形,要设置块和文本大小的比例,我使用此lisp
( DEFUN C:SETSC () (SETQ CURSC (getvar "useri1" )) (princ "the printing scale is 1:")(princ cursc) (setq newsc (getint "\ngive a new scale 1:")) (setvar "useri1" newsc) (setq a1 (getvar "useri1")) (princ "\n the new printing scale is 1:")(princ newsc)(princ))
这是我写的代码,但有几个问题
我想选择两行,捕捉行的长度,然后计算打印长度、打印面积和打印成本
(defun c:SD (/ scl lnx lny ex ey area cost) (setq scl (getvar "useri1")) (setq ex (entsel "\n select first line :")) (setq lnx (/ scl (getdist ex))) (setq ey (entsel "\n select second line :")) (setq lny (/ scl (getdist ey))) (setq area ( * lnx lny));the cost for the printing is 1.42€ / sq.m (this price is for the example) (setq cost ( * 1.42 area))(princ (strcat "The length of the print paper and the cost is" "\n length x = " (rtos lnx 2 2) " m" "\n length y = " (rtos lny 2 2) " m" "\n Area = " (rtos area 2 2) " sq.m" "\n cost = " (rtos cost 2 2) " €" ) ) (princ)) ; end defun
该代码中的问题是
a) 仅选择一行
b) 不打印结果
看看测试。dwg,你会理解的
当我选择长度为118.80的行时,请打印此错误
比你。。
测验图纸