LISP To Change QNEW, make new DWG, then change QNEW back to previous

LISP To Change QNEW, make new DWG, then change QNEW back to previous

Papaweave
Contributor Contributor
1,217 Views
2 Replies
Message 1 of 3

LISP To Change QNEW, make new DWG, then change QNEW back to previous

Papaweave
Contributor
Contributor

I'm creating a lisp that allows users to start multiple drawings from different templates with a button. Ultimately, I want to change the new variable temporarily and back.

 

The below LISP works to change the qnew and start a new drawing (SET1), where I run into issues is then I try to set the qnew back to the original setting (SET2). 

 

If I remove set 2, the qnew changes and a new drawing from the rick-la-sht.dwt opens, but the qnew stays set to rick-la-sht.dwt. If I have set2 in the LISP a new dwg from _rec-ncs-with-styles-2018.dwt is created, so its like set 2 is overwriting set1. I want the qnew to be set back to _rec-ncs-with-styles-2018.dwt once the command is finished.

 

Anyone see what I'm doing wrong?

 

; DNew.lsp to Open New drawing with set default Template
(defun c:set1 (/ keystuff1)

; keystuff function to send command using vlisp to the command line
(defun keystuff1 (cmd-arg) (vl-load-com)(vla-Sendcommand(vla-Get-ActiveDocument(vlax-Get-Acad-Object))cmd-arg))

; set default dwg template for QNew command
(setenv "QnewTemplate" "c:\\rick\\projects\\rickstandards\\autodesk\\c3d_rick_ncs_2018\\templates\\landscape\\rick-la-sht.dwt")

; send QNew to command line
(keystuff1"_.QNEW\n")
(princ "This is set1")
)

(defun c:set2()
(setenv "QnewTemplate" "c:\\rick\\projects\\rickstandards\\autodesk\\c3d_rick_ncs_2018\\templates\\_rec-ncs-with-styles-2018.dwt")
(princ "This is set2")
)

(defun c:newlscapesht-new ()
(c:set1)
(C:set2)
)

 

0 Likes
1,218 Views
2 Replies
Replies (2)
Message 2 of 3

Sea-Haven
Mentor
Mentor

Not sure why your using qnew 

 

You can open a DWG but lisp stops.

You can open a DWG using script  lisp will continue

Using VL can open a dwg and switch back to the one you were in.

Sure there are a couple more options.

 

Please pick one.This could be your template dwgs.

screenshot83.png

 

0 Likes
Message 3 of 3

john.uhden
Mentor
Mentor

Couldn't you (command "_.undefine" "QNEW") and

(command "_.redefine" "QNEW") when you like?

Of course, if your users are smart, they could use the command .QNEW (see the period?).

John F. Uhden

0 Likes