rcb007 Posted October 23, 2020 Share Posted October 23, 2020 Just thought I would ask to see if it is possible within a routine to activate the save as command, and then in the dialog box (File Name: Drawing.dwg) can be changed to something else like Proposed Drawing Name.dwg. Thank you for the direction! Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 24, 2020 Share Posted October 24, 2020 You can write your own "saveas" function with a dwg name of your choice. Will leave that part up you. (defun c:mysaveas ( ) (setvar 'FILEDIA 0) (command "SAVEAS" "2018" "d:\\acadtemp\\test.dwg") (setvar 'FILEDIA 1) (princ) ) Quote Link to comment Share on other sites More sharing options...
rcb007 Posted October 24, 2020 Author Share Posted October 24, 2020 Could I ask, would I be able to browse to a location with the pre populated name? This is great stuff!!! Thank you. Quote Link to comment Share on other sites More sharing options...
Steven P Posted October 24, 2020 Share Posted October 24, 2020 Always take a look at Lee MAcs website... something like this? http://www.lee-mac.com/directorydialog.html Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 24, 2020 Share Posted October 24, 2020 If you just want to change current dwg name and save you can get that very simply (getvar 'dwgname) and (getvar 'dwgprefix) for location you could then add or change say a suffix like -1 -2 etc. If you provide more information about the dwg name required I am sure help will follow. Quote Link to comment Share on other sites More sharing options...
rcb007 Posted October 24, 2020 Author Share Posted October 24, 2020 Sounds great. I have the routine that will walk thru the user to save the file names with an Alert box. Again, it’s just the normal save as dialogue box with Drawing1.dwg. The file names I want are listed below, Survey.dwg PBase.dwg Existing Legend.dwg Border.dwg Pipes.dwg i hope this fills in more. Quote Link to comment Share on other sites More sharing options...
pBe Posted October 25, 2020 Share Posted October 25, 2020 I'm not getiting it, does that mean, it can only be one of these ? 5 hours ago, rcb007 said: Survey.dwg PBase.dwg Existing Legend.dwg Border.dwg Pipes.dwg And no option to save as any other name? or one ot those as a default name depending on the drawing filename? Quote Link to comment Share on other sites More sharing options...
rcb007 Posted October 25, 2020 Author Share Posted October 25, 2020 (edited) What it does, once the routine is activated. It will start with the first blank drawing to do a save as. In the case above, the user would be prompted to save the file as Survey.dwg; the into a folder of the user chooses. Once saved, it prompts the user to save as PBase.dwg and repeats until the last file is saved. In this case Pipes.dwg. I hope this is more clear. Edited October 25, 2020 by rcb007 Quote Link to comment Share on other sites More sharing options...
pBe Posted October 25, 2020 Share Posted October 25, 2020 (edited) The actual saving of the files is not included , this is NOT a working code, this is just a tribute (defun c:Demo () (foreach itm '("Survey.dwg" "PBase.dwg" "Existing Legend.dwg" "Border.dwg" "Pipes.dwg" ) (if (setq SAveASThisName (getfiled (strcat "Save file as " itm) (strcat (if SAveASThisName SAveASThisName (getvar 'Dwgprefix)) itm) "dwg" 1 ) ) ;; Do the save here ;; (progn (print (strcat "Do the file saving at " SAveASThisName)) ;; ;; (setq SAveASThisName (strcat (vl-filename-directory SAveASThisName) "\\")) ) ) ) (princ) ) Every prompt will have the name as default, the user can choose a folder, save the file with a givne name The next prompt will start with the last folder selected and showing the next name on the list. It will be better if you have a template per drawing, those are files that will be eventally saved as .dwg Edited October 25, 2020 by pBe Quote Link to comment Share on other sites More sharing options...
rcb007 Posted October 26, 2020 Author Share Posted October 26, 2020 Thank you for the reply. You hit it. That is what I was looking for. I have been playing with different variables to get the same as to work. Wouldn't the save as be as simple as a (command "save as" (SaveASThisName))? I am still trying different things. lol. (defun c:Demo () (foreach itm '("Survey.dwg" "PBase.dwg" "Existing Legend.dwg" "Border.dwg" "Pipes.dwg" ) (if (setq SAveASThisName (getfiled (strcat "Save file as " itm) (strcat (if SAveASThisName SAveASThisName (getvar 'Dwgprefix)) itm) "dwg" 1 ) ) ;; Do the save here ;; ;(COMMAND "_saveas" "" "~") ;(COMMAND "_saveas" "" (SAveASThisName) filename) ;;(command "SAVEAS" (strcat "K:\\" (SAveASThisName))) (progn (print (strcat "Do the file saving at " SAveASThisName)) ;; Do the save here ;; (setq SAveASThisName (strcat (vl-filename-directory SAveASThisName) "\\")) ) ) ) (princ)) Quote Link to comment Share on other sites More sharing options...
pBe Posted October 26, 2020 Share Posted October 26, 2020 (edited) Like i said , use a template [ that will have everything you need for the type of drawing ] < it can be dwg or dwt > This.. (defun c:Demo ( / TheName theTemplate) (foreach itm '( ("Survey.dwg" "D:\\TemplateLocation\\TML\\Survey.dwt") ("PBase.dwg" "D:\\TemplateLocation\\TML\\PBase.dwt") ("Existing Legend.dwg" "D:\\TemplateLocation\\TML\\Existing Legend.dwt") ("Border.dwg" "D:\\TemplateLocation\\TML\\Border.dwt") ("Pipes.dwg" "D:\\TemplateLocation\\TML\\Pipes Template.dwg") ) (setq TheName (Car itm) theTemplate (Cadr itm)) (if (And (findfile theTemplate) (setq SAveASThisName (getfiled (strcat "Save file as " (Car itm)) (strcat (if SAveASThisName SAveASThisName (getvar 'Dwgprefix)) (Car itm)) "dwg" 1 ) ) ) (progn (print (strcat "File is saved as " SAveASThisName)) (Vl-file-copy theTemplate SAveASThisName) (setq SAveASThisName (strcat (vl-filename-directory SAveASThisName) "\\")) ) ) ) (princ) ) HTH Edited October 26, 2020 by pBe Quote Link to comment Share on other sites More sharing options...
rcb007 Posted October 26, 2020 Author Share Posted October 26, 2020 lol. I did not see by using the template dwt, but it does make sense. Question, when I loaded this, I received an "; error: syntax error". I loaded this in VLIDE and it looks ok to me. Any idea? Quote Link to comment Share on other sites More sharing options...
pBe Posted October 26, 2020 Share Posted October 26, 2020 (edited) oops (setq TheName (Car itm) theTemplate (Cadr itm)) There you go Also, you need to change the tempalte location and filename OK? Edited October 26, 2020 by pBe Quote Link to comment Share on other sites More sharing options...
rcb007 Posted October 26, 2020 Author Share Posted October 26, 2020 Sorry for not getting back to you sooner. Everything worked out as you expected! This is crazy good. and thank you! I just could not figure out the error earlier. thanks for that piece again. Quote Link to comment Share on other sites More sharing options...
pBe Posted October 27, 2020 Share Posted October 27, 2020 11 hours ago, rcb007 said: Everything worked out as you expected! That is good to know, I was thinking about your requirement. if you have a conmsistent folder structure, you may only need to select the root folder once and create the files on its corresponding location with the supplied file name. Again via "copy" and using a template. Not sure if that works for you, Its something to think about. Quote Link to comment Share on other sites More sharing options...
Steven P Posted October 27, 2020 Share Posted October 27, 2020 5 minutes ago, pBe said: That is good to know, I was thinking about your requirement. if you have a conmsistent folder structure, you may only need to select the root folder once and create the files on its corresponding location with the supplied file name. Again via "copy" and using a template. Not sure if that works for you, Its something to think about. if that is the case, we have a folder set up containing all the blank files needed, and just copy the whole lot to the project folder when we set up a new project. I guess a lot quicker than a LISP setting it all up? Also copied are things like document transmittal excel files, and some project management files all in the correct file structure. Also this way a non-CAD person can set up the project (for example the project managers) Quote Link to comment Share on other sites More sharing options...
pBe Posted October 27, 2020 Share Posted October 27, 2020 That is true, but the thing here is I asked if there would be a time that the user might want to type in another name other than the default. Hence the prompt for every file. I was thinking of supplying a prefix or something for the eventuall file name. But that's just an idea. Quote Link to comment Share on other sites More sharing options...
rcb007 Posted October 27, 2020 Author Share Posted October 27, 2020 Could you elaborate alittle more on that? lol. I was just trying to get users to type in the names the right way. lol. I know from our expect, we do have the same file structure for our cad files. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 27, 2020 Share Posted October 27, 2020 You can set where your templates are saved so when you type New it opens that directory and lists dwt files to choose from. Quote Link to comment Share on other sites More sharing options...
rcb007 Posted March 24, 2021 Author Share Posted March 24, 2021 I wanted to share another method i found. https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-save-as-and-fill-in-file-name/td-p/2492955 Quote DaveThis might get you on your way.(setq dsve (getfiled "Save as" "" "dwg" 1))(command "saveas" "2000" dsve) ;place what version herehthSouthie I tested it and it also works! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.