MarcoW Posted May 16, 2010 Share Posted May 16, 2010 Hi, I have searched and found. But not understood... I mean there is a lot written but I seem to miss the point. If I would want to do a specific task, like in a lisp file, to multiple dwg's, how does this work? Only way I can think of is making a "main lisp" to run in the current AutoCAD file, create a list of all dwg's in a specific folder and then run the main lisp. Am I correct? Any help is appreciated, as allways! A little example might be a big help too. Tnx. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 16, 2010 Share Posted May 16, 2010 You could use a script, or possibly ObjectDBX (although this restricts what you can use in the way of LISP) - the topic has been covered many times. The easiest way would be to call your LISP from a script. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 16, 2010 Share Posted May 16, 2010 Read this thread. Quote Link to comment Share on other sites More sharing options...
MarcoW Posted May 16, 2010 Author Share Posted May 16, 2010 the topic has been covered many times I know that Lee, but as I said I do not get the point, how to do it. Only way I can think of is making a "main lisp" to run in the current AutoCAD file, create a list of all dwg's in a specific folder and then run the main lisp. Is that the way "it works" ?? Say I want to draw a line from 0,0 to 10,10 in drawing1.dwg and drawing2.dwg without doing it myself. This is the most easy one I can think of, how to approach this? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 16, 2010 Share Posted May 16, 2010 As I said - the easiest way would be to use a script. Either perform the whole operation from within the script: _.open C:/Users/MarcoW/Drawing.dwg" _.line _non 0,0 _non 10,10 _.save _.close Or create a LISP to draw the line and call it in the script: (defun c:drawline nil (command "_.line" "_non" '(0 0) "_non" '(10 10) "") (princ) ) _.open C:/Users/MarcoW/Drawing.dwg" (load "drawline.lsp" "load failed") (c:drawline) _.save _.close As I said, read the thread I provided a link for, it is all explained in there. Quote Link to comment Share on other sites More sharing options...
MarcoW Posted May 17, 2010 Author Share Posted May 17, 2010 Or create a LISP to draw the line and call it in the script: (defun c:drawline nil (command "_.line" "_non" '(0 0) "_non" '(10 10) "") (princ) ) _.open C:/Users/MarcoW/Drawing.dwg" (load "drawline.lsp" "load failed") (c:drawline) _.save _.close This is what I meant, the way to do... I will give it a shot! Thanks for the explain Lee. Quote Link to comment Share on other sites More sharing options...
MarcoW Posted May 17, 2010 Author Share Posted May 17, 2010 I made a script that works. How would I apply it to a list of dwg's? I have a routine that allows me to select all *.dwg's in a folder and that returns a list ie. "c:\drawing1.dwg" "c:\drawing2.dwg" etc... I tried scriptpro but my machine gets frozen every time I use. Short: how to apply a script to a folder full of dwg's? Thanks again. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 17, 2010 Share Posted May 17, 2010 The long way would be to write each line of the script for each drawing, i.e.: open "C:/MarcoW/Drawing1.dwg" line 0,0 10,10 save close open "C:/MarcoW/Drawing2.dwg" line 0,0 10,10 save close open "C:/MarcoW/Drawing3.dwg" line 0,0 10,10 save close ... The short way would be to use my Script Writer program (link in my sig), in which case you would only have to write the first line and the program writes the rest. Then just run the script when it is written. Lee Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 18, 2010 Share Posted May 18, 2010 Following on from lee you said above you have a program to create your list of dwg names so just write to a file and create a script file with what you want to do dont forget the scr "myscript.SCR" Just use write line something like (strcat "open" (nth x mylist) "line 0,0 10,10 save close") open "C:/MarcoW/Drawing1.dwg" line 0,0 10,10 save close open "C:/MarcoW/Drawing2.dwg" line 0,0 10,10 save close open "C:/MarcoW/Drawing3.dwg" line 0,0 10,10 save close then last line of your proram would be (command "script" myscript) it will then run automatically. Writing files is pretty easy check lisp help, this is a very easy way of doing changes to multiple drawings. Quote Link to comment Share on other sites More sharing options...
MarcoW Posted May 18, 2010 Author Share Posted May 18, 2010 Tnx guys I will have to dig in to this later today.... Quote Link to comment Share on other sites More sharing options...
VVA Posted May 18, 2010 Share Posted May 18, 2010 Read this (vla-sendcommand) and this (Execute commands on all open drawings) thread. OpenDwgsCmds posted here Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 18, 2010 Share Posted May 18, 2010 Almost forgot 1 bug with scripts if your file path or name has a space in it the script will not work I got round this with a bit of VBA code that opens the dwg let me know if you need it. Quote Link to comment Share on other sites More sharing options...
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.