Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Saving over multiple DWGs

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
etilley327KA
417 Views, 8 Replies

Saving over multiple DWGs

Looking for help, im trying to make a quick way to save a dwg over multiple dwgs. What am I missing, its not saving?

 

(vl-load-com)
(defun c:test (/ *error* 1a)
  (defun *error* ( msg )
        (setvar "cmdecho" 1)
        (setvar "filedia" 1)
        (if (not (member msg '("Function cancelled" "quit / exit abort")))
            (princ (strcat "\nError: " msg))
        )
        (princ)
  )
(setvar "cmdecho" 0)
(setvar "filedia" 0)
(while
  (/= 1a "")
(setq 1a "")
(setq 1a (getstring "\nEnter job number or enter when done "))
  (if
    (/= "")
      (progn
      (vl-cmdf "_save"  1a  "Y")
      (princ (strcat "\nSaved [" 1a "]"))
      )
  )
)

(setvar "cmdecho" 1)
(setvar "filedia" 1)
(princ "\nDone")
(princ)
)
8 REPLIES 8
Message 2 of 9
Moshe-A
in reply to: etilley327KA

@etilley327KA  hi,

 

To achieve this, you have to move to ActiveX  (vla \ vlax) functions but before that try SAVEALL command 😀

 

Moshe

 

 

Message 3 of 9
Kent1Cooper
in reply to: etilley327KA

Should this:

(/= "")

be this instead?

(/= 1a "")
Kent Cooper, AIA
Message 4 of 9
pendean
in reply to: etilley327KA

What does "enter job number" do exactly? Is that for a new drawing you open but have yet to save? Do you really do that (just asking to understand, not criticizing).

How does SAVEALL command not work for your needs https://www.google.com/search?q=autocad+saveall+command


Message 5 of 9
Kent1Cooper
in reply to: etilley327KA

No, SAVEALL is clearly not what you're looking for.  If I understand correctly, you will supply text strings, and as long as they have some content [are not "" empty strings], each will be the name of a drawing that is a copy of the current drawing, under that name.  [The "Y" is the answer to the question of whether to replace it if it already exists.  If it doesn't, that question won't be asked, and an unknown-command message will go by, but it won't bother anything.]

 

You say it's not saving.  Is it getting as far as the prompt saying that it did?  You don't include a file path, so are you sure it's not saving?  Are you looking in the right place for the drawing(s) it saved?

Kent Cooper, AIA
Message 6 of 9
etilley327KA
in reply to: Kent1Cooper

It runs through the whole LISP but the drawing is unchanged. When I run the commands manually it saves. Once I get this to work, I was going to add an "if" to check if the job exist before running the "save" command, to have one with and without the "Y". Not sure what's going on here, I'm stumped.
Message 7 of 9
etilley327KA
in reply to: pendean

Im trying to save my current dwg over other dwgs without leaving my dwg.
Message 8 of 9
etilley327KA
in reply to: Kent1Cooper

Yeah, I missed that. Its still not saving though.
Message 9 of 9
paullimapa
in reply to: etilley327KA

I'm successful in running your lisp code. But you'll have to use \ or / to separate folder names and surround everything with "..." if there's a space in the folder or file name.

For example: I have a folder in my c drive called it 1 2 = c:\1 2 with a drawing named c.dwg under this folder.

I then ran your code and at the prompt if I attempt to enter with a space without surrounding with "..." then it'll fail

Also if I enter "c:\\1 2\\c" it'll fail.

But I'm successful when surround with "..." by entering "c:/1 2/c" & "c:\1 2\c"

paulli_apa_2-1672258279515.png

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report