I usually extract DXF's from my Inventor Enviroment and edit them in AutoCAD 2016 to tidy them up. This happens quite often and when i wish to save the edit DXF, it prompts me with a save screen, I need to reselect DXF 2004 version and press enter and comfirm in wish to override the file.
To make my life a bit easier I created a button in the Customize User Interface called 'Save as DXF' with the following macro:
+Saveas (save the file as without prompting a pop-up screen)
F (save it as a DXF)
2004 (save it as a 2004 version)
thats as far as I've gotten, as it then prompts me with a screen anyway to the select the file name.
I wish to just keep the current filename and just press Enter basicly, then a last prompt comes to ask wether im sure I want to override the file, resulting with a Y for choosing Yes.
Is there a way to build these last 2 steps into the macro itself?
Solved! Go to Solution.
Solved by B_Bevelander. Go to Solution.
Solved by Moshe-A. Go to Solution.
Edit: You're not using LT, right? If you do, stop reading here.
Try this.
If the is no dxf yet, no prompt for you.
If the dxf exists, you're prompted for a name. If you confirm the same one, it will override it.
If you cancal the name dialog, or you give a new name that exists too... then you're sent to the dialog of the SaveAs.
Try and let know.
btw the closing is a little bit issue - seems to work but it's a bit forced...
(defun c:SaveAsDXF ( / *error* name-old name-new exist) (defun *error* (errmsg) (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end")) (princ (strcat "\nError: " errmsg))) (princ)) (setq name-old (vl-filename-base (getvar 'dwgname)) path (getvar 'dwgprefix)) (if (setq exist (findfile (strcat path name-old ".dxf"))) (setq name-new (lisped name-old))) (cond ((or (numberp name-new) (and exist (/= name-old name-new) (findfile (strcat path name-new ".dxf")))) (initdia) (command-s "_.saveas")) ((and exist (= name-old name-new)) (command "_.saveas" "dxf" "_version" "2004" 16 (strcat path name-new) "_Yes") (command "_.close") (command)) (T (command "_.saveas" "dxf" "_version" "2004" 16 (strcat path (cond (name-new) (name-old)))) (command "_.close") (command) )) (princ) )
Doesn't seem to work, when I run the command, it stops at the 4th line (5th if you count the empty one)
Not sure if this is effected by the version im running? 2016.
Not sure... try this.
(defun c:SaveAsDXF ( / *error* name-old name-new exist) (defun *error* (errmsg) (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end")) (princ (strcat "\nError: " errmsg))) (princ)) (setq name-old (substr (getvar 'dwgname) 1 (- (strlen (getvar 'dwgname)) 4)) path (getvar 'dwgprefix)) (if (setq exist (findfile (strcat path name-old ".dxf"))) (setq name-new (lisped name-old))) (cond ((or (numberp name-new) (and exist (/= name-old name-new) (findfile (strcat path name-new ".dxf")))) (initdia) (command-s "_.saveas")) ((and exist (= name-old name-new)) (command "_.saveas" "dxf" "_version" "2004" 16 (strcat path name-new) "_Yes") (command "_.close") (command)) (T (command "_.saveas" "dxf" "_version" "2004" 16 (strcat path (cond (name-new) (name-old)))) (command "_.close") (command) )) (princ) )
So there's no way to do this with a simple macro in a command like I initually tried?
That works only when I open a dwg to export it to DXF, yet when i open it as already being a DXF it gives me an error message:
EDIT: Ok with the help from previous post of @Moshe-A , changed my own code to: +Saveas F 2004 ;;; y
This seems to work for both DWG and DXF to save them as DXF in the same folder. If it already is a DXF, it overrides it, if its a DWG it creates a DXF.
Thanks for the help.
your are welcome
Notice (for next time) when closing a thread make sure you credit the right support guy 😀
(command "_.close") (command) you can use
(command "_.close" "n") instead for closing without saveing to dwg