Jump to content
rcb007

Pre-Populate a Save As Name for a file

Recommended Posts

rcb007

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!

Share this post


Link to post
Share on other sites
BIGAL

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

 

Share this post


Link to post
Share on other sites
rcb007

Could I ask, would I be able to browse to a location with the pre populated name? This is great stuff!!! Thank you.

Share this post


Link to post
Share on other sites
Steven P

Always take a look at Lee MAcs website... something like this? http://www.lee-mac.com/directorydialog.html

Share this post


Link to post
Share on other sites
BIGAL

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.

 

Share this post


Link to post
Share on other sites
rcb007

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.

Share this post


Link to post
Share on other sites
pBe

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?

 

Share this post


Link to post
Share on other sites
rcb007

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

Share this post


Link to post
Share on other sites
pBe

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

Share this post


Link to post
Share on other sites
rcb007

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

 

Share this post


Link to post
Share on other sites
pBe

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

Share this post


Link to post
Share on other sites
rcb007

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

Share this post


Link to post
Share on other sites
pBe

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

Share this post


Link to post
Share on other sites
rcb007

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.

Share this post


Link to post
Share on other sites
pBe
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.

 

Share this post


Link to post
Share on other sites
Steven P
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)

Share this post


Link to post
Share on other sites
pBe

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.

 

 

 

Share this post


Link to post
Share on other sites
rcb007

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.

Share this post


Link to post
Share on other sites
BIGAL

You can set where your templates are saved so when you type New it opens that directory and lists dwt files to choose from.

 

image.png.b906e3606b3b51296a7477ba81a2636d.png

 

 

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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