Lisp to save 2017 Civil3D back to previous version - It works...almost

Lisp to save 2017 Civil3D back to previous version - It works...almost

Anonymous
Not applicable
1,279 Views
4 Replies
Message 1 of 5

Lisp to save 2017 Civil3D back to previous version - It works...almost

Anonymous
Not applicable

In the wake of upgrading to AutoCAD Civil3D 2017, we've learned the sad truth that 2017 can't save back to older releases, at least the files it creates cannot be saved with an older version. This seems to be tied to Civil3D objects that remain in the drawing after using etransmit and the like. Some of our clients insist on using software made back when cassette tapes were all the rage, so they need to be able to see our survey points, surfaces, etc. The workaround that we've found is to export to dxf 2007. When this process was presented to the CAD manager, they thought that others in the office might find it a little too overwhelming. So they rang the poor programmer tucked in the back corner of storage room B who still hasn't received his paycheck and asked him to write a lisp. So here I am...

 

I got it pretty far along, but I'd like to ultimately have it be a one step process. I came up with the code below. It does the following:

 

  1. Run first lisp that exports the dwg to dxf 2007.
  2. Close dwg file and quit 2017.
  3. Open 2014.
  4. User manually opens dxf file.
  5. Save as 2007 dwg file over top of original file.
  6. Delete the dxf file.

 

(sorry, I know it's choppy, but this is the end result of a lot of trial and error, so some parts may not be necessary...)

 

Right now it is two separate lisps and requires each user to have 2017 & 2014 installed. My goals are the following:

 

  1. Combine two steps into a single command.
  2. If possible, remove the need to have 2014 installed simply for this process.
  3. I would like to be able to start with my top level drawing and run this entire process on all attached drawings.
  4. I also would like to write the etransmit process into it as well, but I know that etransmit is a command that can be forced to the command line so I can probably accomplish that on my own.

 

(defun c:BlowItUp (/ drwordrctl filelen file path newfile)
(prompt "\nThis will export current drawing to 2007 dxf format in the current directory.")
(prompt "\nIt will then close the drawing and open AutoCAD 2014.")
(initget "BlowItUp Quit")
(setq ans (getkword "\nPlease type BlowItUp to continue or Enter to quit [BlowItUp/Quit] <Quit>: "))
(if (not ans) (setq ans "Quit"))
(cond ((= ans "BlowItUp")
(setq drwordrctl (getvar "draworderctl")
filelen (strlen (getvar "dwgname"))
file (substr (getvar "dwgname") 1 (- filelen 4))
path (getvar "DWGPREFIX")
file (strcat path file)
newfile (strcat file "-CIVIL-3Dexport.dxf")
);setq
(command "tilemode" 1)
(command "filedia" 0)
(command "cmddia" 0)
(setvar "QAFLAGS" 1)
(setvar "draworderctl" 1)
(command "EXPORTTOAUTOCAD2007DXF" newfile)
(command "filedia" 1)
(command "cmddia" 1)
(setvar "QAFLAGS" 0)
(setvar "draworderctl" drwordrctl)
(command "close" "y")
);end BlowItUp
);cond
);defun


(defun c:DxftoDwg (/ drwordrctl filelen file path dxffile newfile svenv)
(setq drwordrctl (getvar "draworderctl")
filelen (strlen (getvar "dwgname"))
file (substr (getvar "dwgname") 1 (- filelen 19))
path (getvar "DWGPREFIX")
dxffile (strcat path file "-CIVIL-3Dexport.dxf")
file (strcat path file)
newfile (strcat file ".dwg")
svenv (getenv "DefaultFormatForSave")
);setq
(command "tilemode" 1)
(command "filedia" 0)
(command "cmddia" 0)
(setvar "QAFLAGS" 1)
(setvar "draworderctl" 1)
(setenv "DefaultFormatForSave" "36")
(command "saveas" 2007 newfile "y")
(command "filedia" 1)
(command "cmddia" 1)
(setvar "QAFLAGS" 0)
(setenv "DefaultFormatForSave" svenv)
(setvar "draworderctl" drwordrctl)
(vl-file-delete dxffile)
(command "quit")
);defun

 

Essentially, I'm trying to re-create the etransmit command to have it actually do what it says it will by saving back to an earlier version. Yes, I'm aware the almighty Autodesk in its infinite wisdom doesn't intend for us to have this functionality as has been mentioned elsewhere, but yes, we still need this functionality and this export process seems to do the trick. (Insert political rant about greedy software companies here).

 

I’m simply trying to uncomplicate this as much as possible for those in the office that are a little less...tech savvy... My sticking point is getting lisp to have 2017 instruct 2014 to open a specified file. (I can get it to open 2014, but when I try to use GETFILED to specify the file, 2014 tells me that the file I've specified doesn't exist despite the fact that it does). Once I figure that out, my thought was to tie the two together by having the first lisp write an acaddoc.lsp in the file directory that instructs 2014 to run the second lisp on open (and then delete the acaddoc.lsp afterward), but because I'm having trouble getting it to open the file I've specified I'm kind of stymied. I'm hoping I'm close and someone can just nudge me in the right direction. Or tell me I'm over-complicating things and there's a way easier way...

 

Thanks in advance. -JK

0 Likes
1,280 Views
4 Replies
Replies (4)
Message 2 of 5

christopher.l.evans
Advocate
Advocate

Take a look at Autodesks DWG TrueView DWG convert.  Just modify your conversion setup package type to a folder you choose otherwise it will overwrite your source file with the converted file.

0 Likes
Message 3 of 5

Anonymous
Not applicable

Thanks Christopher, I appreciate your suggestion. But unless I'm misunderstanding the way that software works, it requires the end user (our client) to download/install an extra piece of software. That may work in a handful of instances, but they're used to exchanging dwg files that are modified both by us and them, with them using various flavors of AutoCAD (Vanilla, C3D, Architectural Desktop, etc) as well as other CAD programs used by architects. I'm trying to avoid asking my clients to do something extra simply because I updated my software and they don't want to. Thanks though. 

0 Likes
Message 4 of 5

christopher.l.evans
Advocate
Advocate

From your post I understood it as you would be taking your 2017 version and converting it to 2007 on your end to send to your clients.

0 Likes
Message 5 of 5

Anonymous
Not applicable

You understood correctly. I downloaded, installed and ran the DWG TrueView program, but none of the various options worked. I tried going back to 2007 & 2000, both with the "Explode AEC Objects" and "TrueView" options. All resulting files gave me the same error message when I opened the file in C3D 2014:

 

"This drawing was created with a newer version of Civil 3D. All entities created by Civil 3D within the drawing area are in a proxy state. Additionally, all commands, settings, and displays of Civil 3D are disabled for this drawing." If you proceed to attempt to save this dwg, you will get a very similar message informing you that you cannot save. This destroys the file exchange process with clients and sub consultants.

 

Previous to 2017, I had written a lisp that would manually explode all C3D objects then save back to 2000, which worked without fail. But that no longer works; the only way to get a file that works is to use export to dxf. The lisps I wrote work, I just want to see if I can combine them into one.

0 Likes