在文件上运行lisp
大家好,我对在关闭的文件上运行lisp感兴趣,这可能吗。我可以同时在两个图形上运行lisp吗?
在这种情况下,似乎最好使用scrpit文件 我的下一个问题是关于我应该如何删除某一长度的行,比如说1'
(defun dlfoot ()
(setvar "cmdecho" 0)
(setq pt1 (getvar "limmin"))
(setq pt2 (getvar "limmax"))
(setq ss1 (ssget "w" pt1 pt2))
(ssget "X" (list (cons 0 "line")))
???
(comannd "erase" ss1"")
(command redraw")
(setvar "cmdecho" 1)
(princ)
)
也许:
(defun c:dlfoot(/ Tol ss eLst pt1 pt2)
(vl-load-com)
(setq Tol 0.001)
(if (setq ss (ssget "X" (list (cons 0 "LINE")
(if (getvar "CTAB")
(cons 410 (getvar "CTAB"))
(cons 67 (- 1 (getvar "TILEMODE")))))))
(progn
(foreach x(mapcar 'cadr (ssnamex ss))
(setq eLst (entget x)
pt1(cdr (assoc 10 eLst))
pt2(cdr (assoc 11 eLst)))
(if (not (equal (distance pt1 pt2) 1.0 Tol))
(ssdel x ss)))
(if (not (zerop (sslength ss)))
(command "_erase" ss "")))
(princ "\n<!> No Lines Found <!>"))
(princ))
你的编码进步太快了。嗯,我的车落后了不少。主要是因为我的cad经理不相信“浪费时间”,我希望他能见到你
哈哈,我以前的经理也不喜欢我在工作中写代码,但这确实节省了你的时间
记住上面的代码,我在代码中包含了一个公差,位于顶部(当前设置为0.001),但如果您愿意,您可能希望将其设置为更低(或更高)或0。
李 因为你主修数学,你能解释一下什么是整数的阶乘吗?什么时候最好用?
;This is a programming example of a recursive function
;which calculates the factorial of an integer.
(defun factor (y)
(cond ((= 0 y) 1)
(t(* y (factor (1- y))))
)
)
(defun C:FACT (/ x)
(initget 7) ;x must not be null, negative or zero
(setq x (getint "Enter an integer: "))
(factor (float x))
)
阶乘是指整数乘以其下的所有整数(直到1):
即
5.(5阶乘)=5 x 4 x 3 x 2 x 1=120
4.(4阶乘)=4 x 3 x 2 x 1=24
等
这在许多不同的应用程序中都很有用-例如,计算一组n个不同对象的排序方式的数量是n!
或者在(1+x)^n的二项式展开中,系数的表达式中使用阶乘:
1+nx+(n(n-1)/2!)x^2+(n(n-1)(n-2)/3!)*x^3等
有关阶乘的更多信息,请参阅此处:
http://en.wikipedia.org/wiki/Factorial
有关二项式展开的更多信息,请参阅此处:
http://en.wikipedia.org/wiki/Binomial_expansion
希望这有帮助
李
页:
[1]