Hi Tim,
You can definitely run batch processes via VBA, but there are some things
you have to be careful with.
1) You can definitely create and process more than one drawing. Here's a
simple loop example to get you started:
Public Sub TestBatchProcess()
Dim oDwg As AcadDocument
Dim I As Integer
For I = 0 To 3
On Error Resume Next
'Check to see if the drawing is already open
Set oDwg = Application.Documents.Open("C:\Temp\Drawing " & I & ".dwg")
'If not, then create it
If oDwg Is Nothing Then
Set oDwg = Application.Documents.Add("Drawing " & I)
End If
With oDwg
'---------------------------------
'...do some batch processing here
'Use oDwg in place of ThisDrawing
'---------------------------------
'Close the drawing and save (full file name only required if you're
creating/saving for the first time
'if the drawing already existed, you could just use
'.Close True
.Close True, "C:\Temp\Drawing " & I & ".dwg"
End With
Next I
Set oDwg = Nothing
End Sub
2) Probably not a good idea to leave drawings open after you finish
processing...what if your batch involves dozens or hundreds of drawings?
Eventually you'll consume all memory and Autocad will crash.
3) Running a script or Autolisp program from VBA is problematic, at best.
The problem is that you have to use a SendCommand which runs asynchronously
from VBA--this means that while the script may start, VBA doesn't wait for
it to finish before going to the next instruction. You'll have to
experiment, but my guess is that your script may need to be rewritten as a
VBA app.
"Tim Barbour" wrote in message
news:23828940.1084836764513.JavaMail.jive@jiveforum2.autodesk.com...
> I am fairly new to AutoCAD VBA and learning as I go. I need to create
thousands of small 3d meshes. I use an AutoCAD macro to run 3dmesh commands
to create meshes, one at a time or in a large group.
>
> I may have gotten into the details and missed some of the introduction,
but I have a simple question.
>
> Can I create more than one drawing (ThisDrawing plus others) in any single
AutoCAD VBA project? If so, how?
>
> Can I repeatedly create new drawings (repeat open, modify, and close),
using a batch process, from a single VBA project?
>
> Basically the VBA sub would - open a new drawing, run a script file to
create a mesh, and then close the drawing file (or leave open until all
meshes have been created) - in a loop. Pointers to example code?
>
> Thanks for your feedback on this.
>
> Tim Barbour
> tgbarbour@comcast.net