Jump to content

Recommended Posts

Posted

I have a LISP program that I've put together (with some help from here) that basically draws a leader based on pick points and adds text labels based on user-entered elevations. It works fine, but I'm running into a couple problems:

 

1) If I run the program in a viewport within paperspace and zoom while in the routine, the command line shows

 

Viewport is view-locked. Switching to Paper space.

Switching back to Model space.

Command:

 

My routine depends on user input from the command line, so at this point the user is lost in the middle of the routine. We do usually lock our viewports once they're setup at the proper scale for plotting. Is there a way to suppress the "unwanted" command line text?

 

2) I have an error handling function, but if I enter or escape out in the middle of the routine the next time I run the command it starts in the middle of the text command (like it's still hung up in the middle of the routine). It seems like I'm missing something that would clean this up. Any ideas?

 

Thanks,

TJ

 

(Hope I'm posting this code right...)

 
;**************************************************************
; 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)
)

  • 1 year later...
Posted

I'm not sure if there was ever a solution found for command-line message spam generated by zooming or panning in a locked viewport, i.e.,

 

 
         Viewport is view-locked. Switching to Paper space.
         Switching back to Model space.

 

I was unable to find one using an internet search. The following solution works for me. If you use this solution it is very important that you have defined an error function for your specific routine so that (SETVAR "NOMUTT" 1) is not left on if you have an error so put (SETVAR "NOMUTT" 0) early in your error routine. The solution is very simple. Just princ the required message and set "nomutt" to 1 before your code that requires a single response at the command line and follow it by setting nomutt to 0.

 

(PRINC "your function's message text")

(PRINC)

(SETVAR "NOMUTT" 1)

>>

(SETVAR "NOMUTT" 0)

 

Here is an example piece of autolisp I use:

 

 
         (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

I know I am :D

Posted

HaHa, I wrote a subroutine very similar to that a while back.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...