PDA

View Full Version : 2012 Startup Switches



Darren Allen
2013-03-11, 01:15 PM
I have a startup switch to open out template (DWT), this works fine. I am looking for a switch that will ask the user to "save drawing as" a project as soon as it opens. Anyone know what to use for the switch? Please advise, Thanks.

cadtag
2013-03-11, 01:36 PM
If a statup switch is required, then /s to run a script that has one line in it,
SAVEAS

otherwise, it would make more sense to me to put a call in acaddoc.lsp to see if the drawing is named, and if not named, run SAVEAS, else do nothing.

BlackBox
2013-03-11, 02:52 PM
In this situation, I'd suggest you go with the Script route via /b switch, as this is executed last in the startup sequence... Calling this SaveAs Command via AcadDoc.lsp (while possible) may be problematic given there are other processes still taking place/loading... Won't know of limitations for sure until this is tested.

cadtag
2013-03-11, 05:20 PM
good catch, it's the /b that calls a script, not /s -- here I was getting lazy and not checking...:mrgreen:..

If you choose to run a script rather than working with acaddoc.lsp, you'll still need to check if the drawing has been named. It's quite feasible to start Acad by dragging a dwg file onto the desktop icon, and that's at least one case where you would not want to blindkly force a SaveAs.

I think then, that the simplest script would be (if (=(getvar "dwgtitled") 0)(command ".saveas" "" "~"))

BlackBox
2013-03-11, 05:27 PM
No worries; More on Startup Switches (http://usa.autodesk.com/adsk/servlet/ps/dl/item?siteID=123112&id=2894625&linkID=9240617)

... Note the update following 2013 SP1.1, and be sure to check for potential changes following the release of 2014 (and the myriad of hotfixes, and updates that ensue).

Darren Allen
2013-03-11, 07:57 PM
I think then, that the simplest script would be (if (=(getvar "dwgtitled") 0)(command ".saveas" "" "~"))

How and where do I add the script after I place the switch?

BlackBox
2013-03-11, 08:46 PM
How and where do I add the script after I place the switch?

... In the Script file (.scr) your /b switch specifies.

Pseudo application icon Target Property:



"YourFilePath\acad.exe" /p "YourProfile" /t "YourFilePath\YourFileName.dwt" /b "YourFilePath\YourFileName.scr"

Darren Allen
2013-03-12, 12:02 PM
... In the Script file (.scr) your /b switch specifies.

Thanks for that, but already I understood that portion. What I need to know is; do I copy and paste the script into note pad and save as a .scr and then save it where?

cadtag
2013-03-12, 12:43 PM
Yes, and save it wherever you want -- just make sure that the path and name of the .scr file is included in your desktop shortcut.

so, if the script is saved as mystart.scr, and saved in m:\common stuff\files\, then after the /b you would have:
"M:\COMMON STUFF\FILES\MYSTART.SCR"

Darren Allen
2013-03-12, 03:52 PM
that the simplest script would be (if (=(getvar "dwgtitled") 0)(command ".saveas" "" "~"))

When I use this script as written; I get "Invalid File Name" message. Am I supposed to replace anything in the script?

jaberwok
2013-03-12, 04:25 PM
When I use this script as written; I get "Invalid File Name" message. Am I supposed to replace anything in the script?

Set Notepad to display "all files" in the file/open box otherwise you will be saving your script file as filename.scr.txt; or just edit the file's name to remove the ".txt"

rkmcswain
2013-03-12, 04:25 PM
When I use this script as written; I get "Invalid File Name" message. Am I supposed to replace anything in the script?

Does this perform any differently..?
I'm guessing not, but both work here.



(if (zerop (getvar "dwgtitled"))(vl-cmdf "._qsave" "~"))

cadtag
2013-03-12, 04:42 PM
what hapens if you cut and paste RK's or my version into the acad commandline? try both, and post the responses from acad

Darren Allen
2013-03-12, 04:52 PM
When I use CadTag's Script (as a .scr and not a .txt), it shows up in the command line but then I have to press enter to invoke the command. What tag can be added to the script to get the script to invoke the command automatically?

Opie
2013-03-12, 05:07 PM
Add a space or blank line at the end of the script.

Darren Allen
2013-03-12, 05:42 PM
Add a space or blank line at the end of the script.

The blank Line (enter) did the trick Thanks you guys

While we are on the subject of saving as; is there a way to add this same kind of script to a .dwt when someone tries to open it directly from the location to ask to SaveAs once it opens?

BlackBox
2013-03-12, 07:48 PM
While we are on the subject of saving as; is there a way to add this same kind of script to a .dwt when someone tries to open it directly from the location to ask to SaveAs once it opens?

Bootstrap your template... Place an AcadDoc.lsp with it (your template) that calls the SaveAs Command just as your Script.

For more on 'bootstrapping', look for R. Robert Bell's course - CM427-1 - Bootstrap Your AutoCADĀ® Deployments - at Autodesk University.

BlackBox
2013-03-12, 08:03 PM
Also, in case you need to 'buckle' your 'bootstrap'... Translation, this also loads your regular AcadDoc.lsp file per your Profile's SFSP (in addition to your template's bootstraped AcadDoc.lsp) (no global variable residue):



(vl-load-com)

((lambda (supportPath / BBOX:Parser file)

(defun BBOX:Parser (char string / i segments segment)
;; BlackBox
;; Example: (BBOX:Parser "-" "dd-mm-yyyy")
;; Returns: ("dd" "mm" "yyyy")
(while (setq i (vl-string-search char string))
(setq
segments (cons (setq segment (substr string 1 i)) segments)
)
(setq string (substr string (+ 2 i)))
)
(reverse (cons string segments))
)

(foreach filePath (BBOX:Parser ";" supportPath)
(if (setq file (findfile (strcat filePath "\\acaddoc.lsp")))
(load file)
)
)
)
(getenv "ACAD")
)

Darren Allen
2013-03-14, 05:47 PM
Thanks you guys for all of your help with this thread. I have this one worked out.