Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Macro to SaveAS DXF writes wrong file extension

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
mclosson
982 Views, 3 Replies

Macro to SaveAS DXF writes wrong file extension

I have a simple AutoLISP macro I've used for years that does a SAVEAS DXF to a specific network location for our waterjet programmer.

The weird thing is it works 9 times out of 10. That 10th time, the filename has an extension of .$$$.

I can just rename the file and edit .$$$ to .dxf and the file is usable.

I just drew a simple rectangle and ran the macro 4 times. The first three times it worked as expected, the fourth time I got .$$$.

The macro is assigned to a button so I know I run the same macro everytime.

All this macro does is explode any polylines and opens the SavesAS dialog box with defaults set to the waterjet drawings folder and "Save as Type" set to dxf.

There I type a unique filename and hit Save.

The image below shows the contents in the waterjet folder.

When the programmer tries to open a file, his system doesn't "see" the file with the dollar signs.

Any ideas why it randomly saves incorrectly?

Capture.JPG

 

;;; This routine will save the current drawing in an AutoCAD R12
;;; .dxf format and default to the J:\ drive

(defun c:wj (/ xpl n index pln dname num name newprefix newfile)
  (setvar "cmdecho" 0)
  (setvar "filedia" 0)
  (command "zoom" "e")
  (setq xpl (ssget "x" '((-4 . "<OR") (0 . "LWPOLYLINE") (0 . "POLYLINE") (0 . "INSERT") (-4 . "OR>"))))
  (if xpl
    (progn
      (setq n (sslength xpl))
      (setq index 0)
      (repeat n
 (setq pln (ssname xpl index))
 (command "EXPLODE" pln)
 (setq index (1+ index))
      );repeat
    );progn
  );if
  (setq dname (getvar "dwgname"))
  (setq num (- (strlen dname) 4))
  (setq name (substr dname 1 num))
  (setq so (substr name 1 5))
  (setq newprefix (strcat "J:/")) 
  (setq newfile (strcat newprefix name))
  (setq dxffile (getfiled "Create Drawing File" newfile "dxf" 1))
  (command "dxfout" dxffile "v" "R12" "16")
  (setvar "filedia" 1)
  (setvar "cmdecho" 1)
  (setq message (strcat "\nDrawing saved as R12 in " dxffile))
  (princ message)
  (princ)
);defun

 

3 REPLIES 3
Message 2 of 4
Balaji_Ram
in reply to: mclosson

Hi,

 

When saving as an R12 version of the DXF, I do see an AutoCAD Emergency backup drawing with .$$$ extension getting created which seems to get deleted just before the dxf file is created. I am not sure when this file would get left behind. I have tried your code several times and the .$$$ file was created each time but was deleted automatically and only the dxf file remained.

 

while saving to any other version of DXF, the backup drawing does not get created. As R12 is quite a old format, there could be some incompatibility with the dxf data that newer versions is trying to save which is causing the backup drawing to get created. I have logged this behavior in our internal database for our engineering team to analyze the behavior.

 

Can you please try saving as any other version of DXF ?  

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

Message 3 of 4
mclosson
in reply to: Balaji_Ram

Balaji_Ram

 

I tweaked the code to save as dxf version 2000. Since the .$$$ appeared randomly, I'll run the macro like this for a while and see if it still happens.

Might be a while before I use it again. Thanks.

Message 4 of 4
mclosson
in reply to: mclosson

After tweaking the code to save as v2000 dxf file format, I've sent 10 test files with no failures.

Seems that may be the solution.

Thanks again.

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

Post to forums  

Autodesk Design & Make Report

”Boost