视口错误(&R)
我有一个LISP程序,我已经放在一起(在这里有一些帮助),它基本上基于拾取点绘制引线,并根据用户输入的高程添加文本标签。它工作正常,但我遇到了几个问题:1) 如果我在paperspace中的视口中运行程序,并在例程中进行缩放,则命令行会显示
视口被视图锁定。切换到图纸空间。
切换回模型空间。
命令:
我的例程依赖于来自命令行的用户输入,因此在这一点上,用户在例程中迷失了方向。一旦将视口设置为适当的打印比例,我们通常会锁定视口。有没有办法抑制“不需要的”命令行文本?
2) 我有一个错误处理功能,但是如果我在下一次运行命令时在例程的中间输入或退出,它会在文本命令的中间启动(就像它仍然挂在例程的中间一样)。看来我错过了一些可以解决这个问题的东西。有什么想法吗?
谢谢
TJ公司
(希望我把这个代码发对了…)
;**************************************************************
; routine to place proposed spot elevations w/user entered elev
; places text labels above leader
; version 1.1 ~ Oct 2008 ~ TJ Frazier
;**************************************************************
(defun c:pspot3 (/ spotloc E N Z BC scale loop lead1 lead2 elevstrtop elevstrbot *error*
top height tempang1 tempang2 tempang3 tclabel bclabel oldtext)
; function to convert radians to degrees
(defun r2d (tempang)
(* 180.0 (/ tempang pi))
); end r2d
; error handling function
(defun *error*(msg)
(setvar "osmode" oldosnap)
(setvar "cmdecho" oldcmdecho)
(setvar "dimasz" olddimasz)
(princ "\nConsole break or Error. Exit... ")
(princ)
); end *error*
(setq oldcmdecho (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq olddimasz (getvar "dimasz"))
(setvar "dimasz" 0.0)
(setq oldosnap (getvar "osmode"))
(setq oldlayer (getvar "clayer"))
(setq oldtext (getvar "textstyle"))
(setq scale (getvar "dimscale"))
(command "-layer" "m" "P Spot" "c" "7" "" "L" "" "" "") ; set current layer & color
(command "-text" "s" "PSpot" "" "" "") ; set current text style
(setq elevstrtop "6")
(while (setq spotloc (getpoint "\nPick location for spot: ")) ; until "enter" get location for spot
(setq E (car spotloc))
(setq N (cadr spotloc))
(progn
(setq lead1 (getpoint spotloc "\nPick label location: "))
(setq lead2 (getpoint lead1 "\nPick label angle: "))
(setq tempang1 (angle lead1 lead2))
(setq tempang2 (- tempang1 1.5708))
(setq tempang3 (+ tempang1 1.5708))
(command "pline" spotloc lead1 lead2 "")
(initget "Yes No")
(setq top (getkword "\nLabeling curb elevs <Yes>/No? "))
(and (not top)
(setq top "Yes"))
(if (= top "Yes") ; if spot is top also draw bottom
(progn
(setq Z (getreal "\nEnter top elevation: ")) ; get top elev
(setq elevstrtop (rtos Z 2 2))
(setvar "osmode" 0)
(command "-insert" "spt9" (list E N Z) (* scale 0.1) "" "") ; insert block at top elev
(setq height (getreal "\nHeight of curb (inches)? "))
(setq BC (- Z (* height 0.0833)))
(setq elevstrbot (rtos BC 2 2))
(command "-insert" "spt9" (list E N BC) (* scale 0.1) "" "") ; insert block at bottom elev
(if (> (car lead2) (car lead1))
(progn
(command "text" "j" "br" lead2 (* scale 0.1) (r2d tempang1) (strcat "TC" elevstrtop))
(setq tclabel (entlast))
(command "text" "j" "tr" lead2 (* scale 0.1) (r2d tempang1) (strcat "BC" elevstrbot))
(setq bclabel (entlast))
(command "move" tclabel bclabel "" lead2 (polar lead2 tempang3 (/ (sqrt scale) 2)))
) ; end progn
(progn
(command "text" "j" "bl" lead2 (* scale 0.1) (+ 180.0 (r2d tempang1)) (strcat "TC" elevstrtop))
(setq tclabel (entlast))
(command "text" "j" "tl" lead2 (* scale 0.1) (+ 180.0 (r2d tempang1)) (strcat "BC" elevstrbot))
(setq bclabel (entlast))
(command "move" tclabel bclabel "" lead2 (polar lead2 tempang2 2))
) ; end progn
) ;end if
) ; end progn
(progn
(setq Z (getreal "\nEnter elevation: ")) ; get elev
(setq elevstrtop (rtos Z 2 2))
(setvar "osmode" 0)
(command "-insert" "spt9" (list E N Z) (* scale 0.1) "" "") ; insert block at elevation
(if (> (car lead2) (car lead1))
(command "text" "j" "br" lead2 (* scale 0.1) (r2d tempang1) elevstrtop)
(command "text" "j" "bl" lead2 (* scale 0.1) (+ 180.0 (r2d tempang1)) elevstrtop)
) ; end if
) ; end progn
) ; end if
(setvar "osmode" oldosnap)
);end progn
);end while
(setvar "cmdecho" oldcmdecho)
(setvar "dimasz" olddimasz)
(setvar "clayer" oldlayer)
(setvar "textstyle" oldtext)
(princ)
)
我不确定是否有任何解决方案可用于在锁定的视口中缩放或平移生成的命令行消息垃圾邮件,即。,
Viewport is view-locked. Switching to Paper space.
Switching back to Model space.
我无法使用互联网搜索找到一个。以下解决方案适合我。如果您使用此解决方案,非常重要的是您已经为特定例程定义了一个错误函数,以便在出现错误时(SETVAR“NOMUTT”1)不会保持打开状态,因此将(SETVAR“NOMUTT”0)放在错误例程的早期。解决方案非常简单。只需在需要在命令行执行单个响应的代码之前输入所需消息并将“nomutt”设置为1,然后将nomutt设置为0。
(PRINC“您的函数的消息文本”)
(普林斯)
(SETVAR“NOMUTT”1)
>>
(SETVAR“NOMUTT”0)
下面是我使用的autolisp示例:
(PROGN
(PRINC "\nSelect objects: ")
(PRINC)
(SETVAR "nomutt" 1)
(SETQ mltss (SSGET
(LIST (CONS -4 "<OR")
(CONS 0 "TEXT")
(CONS 0 "MTEXT")
(CONS -4 "OR>")
) ;_ end of LIST
) ;_ end of SSGET
) ;_ end of SETQ
(SETVAR "nomutt" 0)
) ;_ end of PROGN
HTH公司
我知道我是 哈哈,不久前我写了一个非常类似的子程序。
页:
[1]