Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Member
captjones
Posts: 3
Registered: ‎07-06-2009
Message 1 of 7 (466 Views)

.qsave in lisp error

466 Views, 6 Replies
07-06-2009 01:33 PM
Hello,
I've created a custom redefined qsave lisp to run load with acaddoc in ACA09. I've noticed the scrip will work, however on the .qsave command (default undefined) will not open a dialog box... instead it only provides a command line prompt for filename. When .qsave is manually entered immediately after , it will open with dialog box as expected. This happens in all drawings. Filedia is set to 1. Would appreciate any ideas. Lisp below. Thanks!


(command "undefine" "qsave")

(defun c:qsave ()
(command "zoom" "e")
(command ".qsave")
(princ)
)
Contributor
ktuning
Posts: 14
Registered: ‎09-06-2006
Message 2 of 7 (466 Views)

Re: .qsave in lisp error

07-06-2009 01:50 PM in reply to: captjones
Try this?

(command "undefine" "qsave")
(defun c:qsave ()
(command "zoom" "e")
(if (= 1 (getvar "dwgtitled"))
(command ".save" "") ;If already saved, just save it
(command ".save" "~") ;If new drawing, open dialog to save
)
(princ)
)
Member
captjones
Posts: 3
Registered: ‎07-06-2009
Message 3 of 7 (466 Views)

Re: .qsave in lisp error

07-06-2009 02:02 PM in reply to: captjones
Great! Thanks!!!
*Expert Elite*
Kent1Cooper
Posts: 5,879
Registered: ‎09-13-2004
Message 4 of 7 (466 Views)

Re: .qsave in lisp error

07-06-2009 02:06 PM in reply to: captjones
It should also work to simply add

(initdia)

just before the

(command ".qsave")

line.

--
Kent Cooper
Kent Cooper
*Expert Elite*
Kent1Cooper
Posts: 5,879
Registered: ‎09-13-2004
Message 5 of 7 (466 Views)

Re: .qsave in lisp error

07-06-2009 02:16 PM in reply to: captjones
I don't think you want the Save command here! It creates a *separate drawing file* [like SaveAs, except that it leaves you in the drawing you're in, instead of taking you into the new one]. It does *not* update the current drawing file. But it still counts as a form of saving, so if you then get out of the drawing you're in, that drawing file will not be updated to the current state of things, because it won't ask whether you want to save your changes!

Be careful about the difference between Qsave and Save and SaveAs. The File pull-down menu's so-called but mis-named "Save" item, and the diskette icon in the standard Toolbar, and Ctrl-S, all perform a Qsave, *not* a Save command, and that's what you should use here. [In a drawing that hasn't been saved/named yet, they all do the same thing by reverting to SaveAs, but not otherwise.]

--
Kent Cooper


ktuning wrote...
....
(command ".save" "") ;If already saved, just save it
(command ".save" "~") ;If new drawing, open dialog to save
....
Kent Cooper
Contributor
arul_kov
Posts: 11
Registered: ‎08-10-2012
Message 6 of 7 (277 Views)

Re: .qsave in lisp error

09-14-2012 01:00 AM in reply to: captjones

How can i set the new file name in the qsave window

 

My new file name is "newnumber" as per the below lisp

 

(command "undefine" "qsave")
(defun c:qsave ()
 
(setq num (car (entsel"\nSelect Existing File number:\n"  )))
 
(setq texl1 (vlax-ename->vla-object num))
(setq val1(vla-get-TextString texl1 ))

  (setq oldnumber1 (substr val1 3 6) )
  (setq newnumber (strcat "57" oldnumber1) )
  (Princ newnumber)

(command "zoom" "e")


 
(if (= 1 (getvar "dwgtitled"))

(command ".save" "") ;If already saved, just save it
(command ".save" "~" ) ;If new drawing, open dialog to save
)
(princ)
  )

*Expert Elite*
Kent1Cooper
Posts: 5,879
Registered: ‎09-13-2004
Message 7 of 7 (260 Views)

Re: .qsave in lisp error

09-14-2012 08:41 AM in reply to: arul_kov

arul_kov wrote:

How can i set the new file name in the qsave window

My new file name is "newnumber" as per the below lisp

....


Look at the (getfiled) function, with its 'default' argument.

Kent Cooper
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.