Jump to content

Pre-Populate a Save As Name for a file


rcb007

Recommended Posts

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!

Link to comment
Share on other sites

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)
)

 

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

 

Link to comment
Share on other sites

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 by rcb007
Link to comment
Share on other sites

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 by pBe
Link to comment
Share on other sites

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))

 

Link to comment
Share on other sites

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 by pBe
Link to comment
Share on other sites

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? 

Capture.JPG

Link to comment
Share on other sites

oops

(setq TheName (Car itm) theTemplate  (Cadr itm))

There you go

 

Also, you need to change the tempalte location and filename OK?

 

Edited by pBe
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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.

 

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 4 months later...

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

Dave

This might get you on your way.

(setq dsve (getfiled "Save as" "" "dwg" 1))
(command "saveas" "2000" dsve) ;place what version here

hth
Southie

 

I tested it and it also works!

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...