someoneslost Posted October 1, 2009 Posted October 1, 2009 Hey guys, Complete autocad newbie here. Well not completely, been using autocad 2007 for about 2 years now but just basically to plot dwg files and clean them off to be made into dxf files for machining. I tried playing with macros to automate my work a little bit, but alas no luck. What I'm looking to do is get some help on creating a proper macro for my use. Basically, after I plot the dwg files, I erase all the dimensions and part info on the dwg, and then I have to save the dxf file in a separate directory on our network. Can a macro be made to automate this process and keep the file's original filename, but saved as a dxf in the other directory? Thanks again for the help and patience. Quote
ReMark Posted October 1, 2009 Posted October 1, 2009 Is the information (dimensions and part info) on separate layers? Do you want to do this as a batch file (for multiple drawings) or on a single file basis (as needed)? Quote
someoneslost Posted October 1, 2009 Author Posted October 1, 2009 Is the information (dimensions and part info) on separate layers? Do you want to do this as a batch file (for multiple drawings) or on a single file basis (as needed)? On most dwg files I get, they are on separate layers. The layers don't really matter because I go through by hand and select them and then erase. I think I would like it to be for each single file, but I need it to save the file's filename from dwg to dxf automatically. Is that possible? Thanks again. Quote
ReMark Posted October 1, 2009 Posted October 1, 2009 Yes, I think it is doable. Although I do have another question. Are these layers, if they exist at all, always the same name? Ex. - Dimensions on layer Dim or Dimensions. Parts info on layer Parts. Quote
someoneslost Posted October 1, 2009 Author Posted October 1, 2009 No they are not always the same name. Some dwgs have more/less/different layers. Does this complicate things even more? Thanks again Quote
nukecad Posted October 1, 2009 Posted October 1, 2009 I would have thought that a DIESEL expression should take care of the .dwg/.dxf in a macro; (I have done something similar in the past); but not done it for a long time so not sure if Diesel is flexible enuf to change the pathname. Quote
ReMark Posted October 1, 2009 Posted October 1, 2009 It is often easier to write a macro when the steps to be taken are fairly consistent. I guess I was leaning more towards a script that could be applied to a group of drawings but a macro, with the right pauses for user input, could probably be written as well. Just how then do you envision using this macro? You would open the drawing, note the layers the information is on then start the macro adding your input as it goes along? Quote
fuccaro Posted October 2, 2009 Posted October 2, 2009 This should erase all your dims: (defun c:dimdel() (setq ss (ssget "X" (list (cons 0 "*DIMENSION")))) (repeat (setq i (sslength ss)) (entdel (ssname ss (setq i (1- i)))) ) ) Search in the forum if you are unfamiliar with Lisp routines -you will find a lot of entries. Quote
fuccaro Posted October 2, 2009 Posted October 2, 2009 I got some time to post again. After deleting the dimensions, you could insert in the code something like: (command "saveas" "dxf" "" (strcat "c:\\myfiles\\" (getvar "dwgname"))) this will save the drawing in dxf format. Ofcourse you will change the path c:\myfiles... and use double backslashes instead of backslashes. I did not test the code but it should work. Quote
someoneslost Posted October 2, 2009 Author Posted October 2, 2009 (command "saveas" "dxf" "" (strcat "k:\\dxf files\\" (getvar "dwgname"))) Okay, I figured out how lisp programs work and this one works beautifully, but one problem. its saving all the files as "filename.dwg.dxf" Any work around for this? Also, will I be able to apply this lisp command to a button on one of my toolbars? Thanks again for all the help Quote
fuccaro Posted October 2, 2009 Posted October 2, 2009 Oh, sorry for that! I wrote no lisps from some time now and it sounds like I can't write routines without testing. I will put together something today and I will post again after a few hours. I don't have AutoCAD right now and I will publish no untested code. Quote
NBC Posted October 2, 2009 Posted October 2, 2009 Is it just me, or does anyone else shiver in their boots when they see/hear anyone using the erase/delete command ? For things I think I might need today, I just put them on layers that I freeze off; as I have come to know that at some point in the future those things may be needed. Quote
fuccaro Posted October 2, 2009 Posted October 2, 2009 The original file remains as it is. Only the newly saved DXF file will be without dimensions. (defun c:deldim( / path name ss i) (setq path "c:\\myfolder\\") (setq name (getvar "dwgname") name (substr name 1 (- (strlen name) 4))) (setq ss (ssget "X" (list (cons 0 "*DIMENSION")))) (if ss (repeat (setq i (sslength ss)) (entdel (ssname ss (setq i (1- i)))) ) ) (command "_.saveas" "dxf" "" (strcat path name)) ) Edit the code in the second line to set the path properly. Yes, it is possible to create a button -the CUI interface is self-explanatory. Just because these days I rarely use AutoCAD, maybe someone else will jump to help you. Quote
someoneslost Posted October 2, 2009 Author Posted October 2, 2009 Okay, I tried that last one you posted and it did nothing for me. Didn't save, didn't erase the drawing info/dimensions. As it looks, nothing happened at all. When I had my .lisp program just set up with this: (command "saveas" "dxf" "" (strcat "k:\\dxf files\\" (getvar "dwgname"))) It does everything I want it to do, just saves the files as: "filename.dwg.dxf" I'm guessing the engineering team that drew these didn't set something up in these drawings for your more complex lisp program to function correctly? Thanks again for the help. Quote
ReMark Posted October 3, 2009 Posted October 3, 2009 I doubt that the failure of the LISP routine has anything to do with how the engineering team set the drawings up. Quote
fuccaro Posted October 3, 2009 Posted October 3, 2009 I just tested again the lisp and on my computer it works as expected. You are aware that the first code I sent names DIMDEL and the second one is DELDIM, right? To other lispers: please someone run the code above and post a feed-back! Quote
someoneslost Posted October 5, 2009 Author Posted October 5, 2009 Okay maybe I'm doing something wrong. Here's what I'm doing step for step: Open a dwg file go to tools menu then autolisp then visual lisp editor open up a new file paste in your latest code you posted here on the forums save as my filename.lsp then go back to tools menu autolisp load application select my .lsp I just created then it says filename.lsp sucessfully loaded. Finally, when I close the load application window, My command window will look like this: filename.lsp sucessfully loaded. Command: Command: And it does nothing. Sorry if this wasn't clear, I was just trying to see if I'm doing something wrong. Any ideas? Thanks again. Quote
chelsea1307 Posted October 5, 2009 Posted October 5, 2009 now you need to type DELDIM at the command line to start it running Quote
someoneslost Posted October 5, 2009 Author Posted October 5, 2009 now you need to type DELDIM at the command line to start it running Sweet, it works! It doesn't erase all of the stuff I need to, but it saves where I want it and with the correct filename.dxf setup. My company over the last 20 years has added different layers with different layer names to the dwg's. Is there a way to add more layers to be erased to this lisp program? Again, thanks a lot Quote
fuccaro Posted October 6, 2009 Posted October 6, 2009 What remains "unerased"? Also there is a way to batch process more files at a time -just search in the forum the older posts. Quote
Recommended Posts
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.