Author Topic: Lisp acting strangly  (Read 2056 times)

0 Members and 1 Guest are viewing this topic.

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Lisp acting strangly
« on: May 19, 2006, 12:45:38 PM »

I have a question, hopefully someone can shed some light on the weird situation.

I have a lisp routine that i can paste at the command prompt after opening up a drawing. I initiate the command and the routine does not do what it is programmed to do but if I manually type in say "zoom" "extents" first before initiating the command then the routine works flawlessly. What could/can be causing this?

Code: [Select]
(defun c:CreateVP ()
(command "zoom" "extents")
(if (null (tblsearch "layer" "G-ANNO-TTLB-NOTE"))
     (command "-layer" "new" "G-ANNO-TTLB-NOTE" ""))
(command "-layer" "thaw" "G-ANNO-TTLB-NOTE" "")
(command ".layer" "s" "G-ANNO-TTLB-NOTE" "")
(command "-layer" "ltype" "continuous" "G-ANNO-TTLB-NOTE" "")
(command "-layer" "color" "151" "G-ANNO-TTLB-NOTE" "")
(setq lineweightunits (getvar "LWUNITS"))
(setvar "LWUNITS" 1)
(command "-layer" "lw" "0.25" "G-ANNO-TTLB-NOTE" "")
(setvar "LWUNITS" lineweightunits)
(command "-style"
         "ROMANS" ;Enter name of text style or [?]
         "romans.shx" ;Specify full font name or font filename (TTF or SHX) <txt>:
         "10" ;Specify height of text <0.0000>:
         "1" ;Specify width factor <1.0000>:
         "0" ;Specify obliquing angle <0>:
         "N" ;Display text backwards? [Yes/No] <N>:
         "N" ;Display text upside-down? [Yes/No] <N>:
         "N" ;Vertical? <N>
)
(command "regen")
(command ".delay" "1000")
(setvar "tilemode" 1)
;(setvar "TEXTSTYLE" "ROMANS")
(command "zoom" "extents")
(if (setq set1 (ssget "X" '((-4 . "<AND") (0 . "TEXT")(8 . "G-ANNO-TTLB-NOTE") (-4 . "AND>"))))
  (command "erase" set1 "")
)
(command ".delay" "1000")
(getdate)
(command "regen")
(command "text" "justify" "mc" "0,0,0" "0" labeltext)
(command ".layer" "s" "0" "")
(setvar "tilemode" 0)
(mkvp)
)
(defun getdate ()
  (setq
    D   (rtos (getvar "CDATE") 2 6)
    YR  (substr D 3 2)
    MO  (substr D 5 2)
    DAY (substr D 7 2)
  ) ; end of setq
  (setq P_DATE (strcat MO "/" DAY "/" YR))
  (setq
    D  (rtos (getvar "CDATE") 2 6)
    MT (substr D 10 2)
    MT (atoi MT)
  ) ; end of setq
  (if (> MT 12)
    (setq HR (- MT 12))
    (setq HR MT)
  )
  (if (>= MT 12)
    (setq TOD " PM")
    (setq TOD " AM")
  )
  (setq HR (rtos HR 2 0))
  (setq
    M  (substr D 12 2)
    S  (substr D 14 2)
  ) ; end of setq
  (setq P_TIME (strcat HR ":" M ":" S TOD))
  (setq labeltext (strcat "LABEL UPDATED: " p_date " " P_time))
)
(defun mkvp ()
(setvar "visretain" 1)
(setvar "tilemode" 0)
(command "pspace")
(if (null (tblsearch "layer" "G-ANNO-TTLB-NOTE"))
     (command "-layer" "new" "G-ANNO-TTLB-NOTE" "")
)
(if (null (tblsearch "layer" "VIEWPORT"))
     (command "-layer" "new" "VIEWPORT" "")
)
(command "-layer" "thaw" "VIEWPORT" "")
(command "-layer" "on" "VIEWPORT" "")
(command "-layer" "ltype" "continuous" "VIEWPORT" "")
(command "-layer" "color" "7" "VIEWPORT" "")
(command "-layer" "plot" "no" "VIEWPORT" "")
(setq lineweightunits (getvar "LWUNITS"))
(setvar "LWUNITS" 1)
(command "-layer" "lw" "0.25" "VIEWPORT" "")
(setvar "LWUNITS" lineweightunits)
(command ".layer" "s" "VIEWPORT" "")
(setq lowerleft "1.7277,0.6556,0.0")
(setq upperright "7.7466,1.0102,0.0")
(command "zoom" "window" lowerleft upperright)
(command "zoom" ".9X")
(setvar "osmode" 0)
(if (setq set2 (ssget "X" '((-4 . "<AND") (0 . "VIEWPORT") (8 . "VIEWPORT") (-4 . "AND>"))))
(command "erase" set2 "")
)
(command "mview" lowerleft upperright)
(setq viewportname (entlast))
(command "mspace")
(command "-vports" "on" viewportname "")
(command "zoom" "c" "0,0,0" "19")
(command "pspace")
(command "vplayer" "freeze" "G-ANNO-TTLB-NOTE" "all" "" "")
(command "vplayer" "freeze" "*" "select" viewportname "" "")
(command "vplayer" "thaw" "G-ANNO-TTLB-NOTE" "select" viewportname "" "")
(setq counter 0)
(command ".layer" "s" "0" "")
(command "-layer" "freeze" "VIEWPORT" "")
(command "pspace")
(command "zoom" "extents")
)
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

XeroPhane

  • Guest
Re: Lisp acting strangly
« Reply #1 on: May 19, 2006, 02:07:31 PM »
Do you have additional programs installed to work within AutoCAD?  For example, I also have ProjectWise running on my system, which installs a DMS (document management system) into AutoCAD.  For some [stupid] reason, the last DMS utility doesn't start up until after I've intiated a command.  Which often causes me to have to re-enter the command.  I tried your routine on a vanilla autocad and everything seemed to work OK. :mrgreen: