Author Topic: ; error: too few arguments QSAVE  (Read 4442 times)

0 Members and 1 Guest are viewing this topic.

ronjonp

  • Needs a day job
  • Posts: 7529
; error: too few arguments QSAVE
« on: April 28, 2005, 11:36:10 AM »
I threw this together to copy a dwg to a backup directory each time the user does a save.....but when the qsave command is called I keep getting this:

; error: too few arguments

What have I done wrong here?




Code: [Select]
(vl-load-com)
(vlr-command-reactor nil '((:vlr-commandEnded . copydwg)))
(defun copydwg (calling-reactor endcommandInfo / destdir dwgdir t-o-d)
  (setq thecommandend (nth 0 endcommandInfo))
  (cond
    (= thecommandend "CIRCLE")
    (= thecommandend "QSAVE")
  )

  (progn

    (if (not (wcmatch (getvar 'DWGNAME) "Drawing*.dwg"))
      (progn

(defun t-o-d (/ cdate stime)
 (setq cdate (rtos (fix (getvar 'cdate)) 2 0)
stime (strcat
(substr cdate 5 2)
"-"
(substr cdate 7 2)
"-"
(substr cdate 1 4)
     )
 )
)

;Makes C:\AutoCAD-BAK\currentdate\ if it doesn't already exist

(if (not
     (vl-file-directory-p (strcat "C:/AutoCAD-BAK/" (t-o-d)))
   )
 (vl-mkdir (strcat "C:/AutoCAD-BAK/" (t-o-d)))
)

;For some reason the files get huge if not deleted then saved on top of

(if (findfile
     (strcat "C:/AutoCAD-BAK/" (t-o-d) "/" (getvar 'dwgname))
   )
 (vl-file-delete
   (strcat "C:/AutoCAD-BAK/" (t-o-d) "/" (getvar 'dwgname))
 )
)

(setq destdir (strcat "C:/AutoCAD-BAK/"
     (t-o-d)
     "/"
     (getvar 'dwgname)
     )
     dwgdir  (strcat (getvar 'dwgprefix) (getvar 'dwgname))
)
(vl-file-copy dwgdir destdir T)
      )
    )
  )
)


Thanks,

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
; error: too few arguments QSAVE
« Reply #1 on: April 28, 2005, 11:53:26 AM »
Couple general things I quickly note --

(1) The cond structure while executable appears logically flawed to me (it will always return "CIRCLE" IINM).
(2) What purpose is served by the first progn?

Define this before running -- (defun *error* (x) (vl-bt))

Subsequent error messages should be a little more telling.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
; error: too few arguments QSAVE
« Reply #2 on: April 28, 2005, 11:58:49 AM »
Add this little bit of code to the copydwg defun and then share what it spews when run ...

Code: [Select]
(defun copydwg ( calling-reactor endcommandInfo / destdir dwgdir t-o-d )

    (setq thecommandend (nth 0 endcommandInfo))
   
    ;;  <this is new>
    (princ "[ ")
    (princ thecommandend)
    (princ " ]\n\n")
    ;;  </this is new>
 
    ...

)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

ronjonp

  • Needs a day job
  • Posts: 7529
; error: too few arguments QSAVE
« Reply #3 on: April 28, 2005, 02:35:23 PM »
MP,

This is what it returned:

Code: [Select]
Command: qsave
; error: too few arguments
[ QSAVE ]

[ QSAVE ]

[ QSAVE ]

[ QSAVE ]


Command: circle
Specify center point for circle or [3P/2P/Ttr (tan tan radius)]:
Specify radius of circle or [Diameter] <2.86261>:
[ CIRCLE ]

[ CIRCLE ]

[ CIRCLE ]

[ CIRCLE ]


Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
; error: too few arguments QSAVE
« Reply #4 on: April 28, 2005, 02:37:08 PM »
Did you define this first --

(defun *error* (x) (vl-bt))

Guessing not.

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

ronjonp

  • Needs a day job
  • Posts: 7529
; error: too few arguments QSAVE
« Reply #5 on: April 28, 2005, 02:45:48 PM »
OOPS! :oops:

Code: [Select]
Command: qsave
Updating Indexes for block *Model_Space
Done.
Backtrace:
[0.39] (VL-BT)
[1.35] (*ERROR* "too few arguments")
[2.30] (_call-err-hook #<SUBR @0693db54 *ERROR*> "too few arguments")
[3.24] (sys-error "too few arguments")
:ERROR-BREAK.19 "too few arguments"
[4.16] (COPYDWG)
[5.12] (ENDCOMMAND #<VLR-Command-Reactor> ("QSAVE"))
:CALLBACK-ENTRY.6 (:CALLBACK-ENTRY)
:REACTOR-CALLBACK.3 :REACTOR-CALLBACK
[ QSAVE ]

[ QSAVE ]

[ QSAVE ]

[ QSAVE ]


Command: circle
Specify center point for circle or [3P/2P/Ttr (tan tan radius)]:
Specify radius of circle or [Diameter] <0.58085>: [ CIRCLE ]

[ CIRCLE ]

[ CIRCLE ]

[ CIRCLE ]

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
; error: too few arguments QSAVE
« Reply #6 on: April 28, 2005, 03:14:27 PM »
Hmmm ... you know, what you're posting as a response does not gel with the code above, insomuch as no matter what command you execute it should run what's in the second progn structure if the drawing is not named drawing*.dwg.

What you indicate above is that it is differentiating between circle and qsave, and it clearly shouldn't.

Are you running exactly what you're posting?

<confused.mpg>
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

ronjonp

  • Needs a day job
  • Posts: 7529
; error: too few arguments QSAVE
« Reply #7 on: April 28, 2005, 03:18:32 PM »
This is what I just ran:

Code: [Select]
(vl-load-com)
(defun *error* (x) (vl-bt))
(vlr-command-reactor nil '((:vlr-commandEnded . copydwg)))
(defun copydwg ( calling-reactor endcommandInfo / destdir dwgdir t-o-d )

    (setq thecommandend (nth 0 endcommandInfo))
   
    ;;  <this is new>
    (princ "[ ")
    (princ thecommandend)
    (princ " ]\n\n")
    ;;  </this is new>
  (progn
    (if (not (wcmatch (getvar 'DWGNAME) "Drawing*.dwg"))
      (progn

   (defun t-o-d (/ cdate stime)
     (setq   cdate (rtos (fix (getvar 'cdate)) 2 0)
      stime (strcat
         (substr cdate 5 2)
         "-"
         (substr cdate 7 2)
         "-"
         (substr cdate 1 4)
            )
     )
   )

               ;Makes C:\AutoCAD-BAK\currentdate\ if it doesn't already exist

   (if (not
         (vl-file-directory-p (strcat "C:/AutoCAD-BAK/" (t-o-d)))
       )
     (vl-mkdir (strcat "C:/AutoCAD-BAK/" (t-o-d)))
   )

               ;For some reason the files get huge if not deleted then saved on top of

   (if (findfile
         (strcat "C:/AutoCAD-BAK/" (t-o-d) "/" (getvar 'dwgname))
       )
     (vl-file-delete
       (strcat "C:/AutoCAD-BAK/" (t-o-d) "/" (getvar 'dwgname))
     )
   )

   (setq destdir (strcat "C:/AutoCAD-BAK/"
               (t-o-d)
               "/"
               (getvar 'dwgname)
            )
         dwgdir  (strcat (getvar 'dwgprefix) (getvar 'dwgname))
   )
   (vl-file-copy dwgdir destdir T)
      )
    )
  )
)
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
; error: too few arguments QSAVE
« Reply #8 on: April 28, 2005, 03:24:05 PM »
That code doesn't crash on my machine, though you might want to lose the extra closing parenthesis.

I suggest starting with a new instance of AutoCAD and checking the behavior.

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

ronjonp

  • Needs a day job
  • Posts: 7529
; error: too few arguments QSAVE
« Reply #9 on: April 28, 2005, 03:52:39 PM »
It's working now  :D  not sure why but.....it's working.

Thanks for your help MP.

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
; error: too few arguments QSAVE
« Reply #10 on: April 28, 2005, 05:32:25 PM »
I didn't do anything Ron, so I can't accept your thanks. Glad you're on your way nonetheless.

(Thanks).

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst