大家好,
我是这个论坛的新手,LISP。
但我正在实习,我的老板想让我在写代码的时候学到更多?
这就是我做的:
这是一个自动编号系统,有一个领导者,但我想它相当不稳定?大多数情况下,它是有效的,但通常只有第二次。第一次键入posnumber时,它会重复appload?
- (defun c:POSNumbering ( )
- (princ "\nAutolabel - Dutch Offshore Innovators - Clint de Bruijn")
- (setq NN (getint "\nStarting Number:") )
- (setq number (itoa NN))
- (while
- (setq p1 (getpoint "\nPick a POINT on the screen:") )
- (setq p1x (car p1))
- (setq p1y (cadr p1))
- (setq b (car p1))
- (setq c (cadr p1))
- (princ b)
- (princ ",")
- (princ c)
- (setq p2 (getpoint "\nPick a POINT on the screen:") )
- (setq p2x (car p2))
- (setq p2y (cadr p2))
- (princ b)
- (princ ",")
- (princ c)
- (command "leader" p1 p2 "" "" "N")
- (setq p3 (list (+ p2x 500) (+ p2y 400)))
- (setq p4 (list (+ p2x 500) (+ p2y -400)))
- (setq p5 (list (+ p2x -500) (+ p2y 400)))
- (setq p6 (list (+ p2x -500) (+ p2y -400)))
- (if (and (>= p2x p1x) (>= p2y p1y)) (command "rectangle" p2 p3))
- (if (and (> p2x p1x) (< p2y p1y)) (command "rectangle" p2 p4))
- (if (and (< p2x p1x) (> p2y p1y)) (command "rectangle" p2 p5))
- (if (and (<= p2x p1x) (<= p2y p1y)) (command "rectangle" p2 p6))
- (setq p7 (list (+ p2x 250) (+ p2y 200)))
- (setq p8 (list (+ p2x 250) (+ p2y -200)))
- (setq p9 (list (+ p2x -250) (+ p2y 200)))
- (setq p10 (list (+ p2x -250) (+ p2y -200)))
- (if (and (>= p2x p1x) (>= p2y p1y)) (command "Text" "Middle" p7 "200" "0" number ""))
- (if (and (> p2x p1x) (< p2y p1y)) (command "Text" "Middle" p8 "200" "0" number ""))
- (if (and (< p2x p1x) (> p2y p1y)) (command "Text" "Middle" p9 "200" "0" number ""))
- (if (and (<= p2x p1x) (<= p2y p1y)) (command "Text" "Middle" p10 "200" "0" number ""))
- (setq number (itoa (setq NN (+ NN 1))))
- )
- )
[/noparse]代码标记(您可以修改帖子-只需单击编辑帖子)。。。
现在谈谈你的问题。。。
您可以将当前的osmode设置(OSNAP)保存在一些随机(setq)变量中。。。(setq osm(getvar‘osmode))
然后,您可以将“osmode(OSNAP)variable Previor calculations”设置为0-关闭OSNAP。。。(setvar“osmode 0)
在计算(例程)结束时,您可以将保存的“osmode”设置恢复到其以前的状态。。。(setvar‘osmode osm)
本地化所有使用的变量p1、p2,。。。包括现在提出的用于OSNAP的osm。。。(defun c:yourcommandfunction(/var1 var2…varn)
在例程类型(princ)的末尾,静默退出以避免在命令提示下返回nil。。。
如果您希望不必在“osmode”中使用此技巧,但强烈建议您在每个命令调用中提供的每个点参数之前指定“\u non”字符串,如(命令“矩形”p1 p2),以便正确的行应如(命令“\u.rectangle”“\u non”p1“\u non”p2)。。。尝试在所有命令前加上“_”标志,以避免不同版本的AutoCAD软件之间的语言障碍“_”标志;和“”用于调用命令的内置版本的签名。。。
作为开场白,这一切从我现在开始。。。
M、 R。 |