Jump to content

How to apply a task to multiple dwg's? (Batch..?)


MarcoW

Recommended Posts

Hi,

 

I have searched and found. But not understood... :oops: 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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...