你好,我找到了这个:
http://cad-notes.com/2010/12/autolisp-exercise-using-block-and-conditional-if/
我根据自己的一些需要对其进行了修改,但我无法使osnap端点和交集函数在直线上工作(setvar“OSMODE”33),为什么?
- ;;Level0 put in level arrow in level 0 in different direktions.
- (defun c:Level0 (/ oldcmdecho oldosnap cnglobalscale labelposition levelarrowtype y x zerolevelposition y1 x1)
- ;;setting up before the real work is going on
- (setq oldcmdecho (getvar "cmdecho"))
- (setq oldosnap (getvar "osmode"))
- (setvar "cmdecho" 0)
- ;;checking the scale
- (if (= cnglobalscale nil) ; this will check if user already has defined the drawing scale
- (setq cnglobalscale (getreal "\nSet Global Scale for CN Annotation <1/1>: "))
- )
- (if (= cnglobalscale nil) ; this will check if the user choose default value
- (setq cnglobalscale 1)
- )
- (initget 1)
- (while (setq labelposition (getpoint "\nPick Label Position for zerolevel: "))
- (setvar "OSMODE" 33)
- (setq levelarrowtype (getpoint "\nPick Direction of level arrow"))
- (setvar "OSMODE" 0)
- ;;setting up the zerolevel position
- (setq y 0)
- (setq x (car labelposition))
- (setq zerolevelposition (list x y))
- ;;getting direction on level arrow
- (setq y1 (cadr levelarrowtype))
- (setq x1 (car levelarrowtype))
- ;;Labelling the level
- (setq label "%%p 0.00")
- ;;setting conditions
- (cond ((and(>= y1 0) (> x1 x)) (command "_-insert" "kote3" zerolevelposition cnglobalscale cnglobalscale 0 label))
- ((and(<= y1 0) (> x1 x)) (command "_-insert" "kote4" zerolevelposition cnglobalscale cnglobalscale 0 label))
- ((and(>= y1 0) (< x1 x)) (command "_-insert" "kote1" zerolevelposition cnglobalscale cnglobalscale 0 label))
- ((and(<= y1 0) (< x1 x)) (command "_-insert" "kote2" zerolevelposition cnglobalscale cnglobalscale 0 label))
- )
- (setvar "osmode" oldosnap)
- (setvar "cmdecho" oldcmdecho)
- (princ)
- )
- )
或者保持osmode设置不变,只需在命令“insert”的调用中添加“_non”
- (while [color=blue][b](progn[/b][/color]
- [b][color=blue] (setvar "OSMODE" 33) [/color][/b]
- [b][color=blue] (setq labelposition (getpoint "\nPick Label Position for zerolevel: "))[/color][/b]
- [b][color=blue] (setq levelarrowtype (getpoint labelposition "\nPick Direction of level arrow")))[/color][/b]
- (setvar "OSMODE" 0)
- .....
|