We have a batch processor that does a lot of really great stuff. The drawback is that it was originally created in R14 and modified for R2000 by adding SDI toggles. The way it it basically works is using the input from the form, it writes a script that runs when AutoCAD is opened using the 'acad.exe /b' switch. And it opens and closes AutoCAD for each drawing it processes. I'd like to change this so it opens acad once, then opens a drawing, runs the script, closes that drawing, opens the next drawing, runs the script, closes, etc - Multiple Document Interface. Could someone show me how to do this? I can't imaging it's that difficult. (famous last words from an optimistic newbie) Here's what we're using now: Temp = Shell("c:\Program Files\AutoCAD 2004\acad.exe /b c:\temp\DLPlot", vbMaximizedFocus) Thanks for any help!
Here is an example. It works from excel vba. Be sure to add reference to acad.tlb. ************************code*********************** Option Explicit Public Sub test() Dim acad As New AcadApplication Dim dwg As AcadDocument Dim strDwgs(3) As String Dim I As Integer strDwgs(0) = "c:\dwg\temp\aborder.dwg" strDwgs(1) = "c:\dwg\temp\bborder.dwg" strDwgs(2) = "c:\dwg\temp\cborder.dwg" strDwgs(3) = "c:\dwg\temp\dborder.dwg" For I = LBound(strDwgs) To UBound(strDwgs) Set dwg = acad.Documents.Open(strDwgs(I), False) dwg.SendCommand ("line 0,0 5,5 ") dwg.SendCommand ("circle 5,5 9 ") dwg.Save dwg.Close Next I acad.Quit Set acad = Nothing Set dwg = Nothing End Sub ************************code*********************** Tim Riley
I forgot that you wanted to run a script :/ Here is the revised code: *************************Code************************************* Option Explicit Public Sub test() Dim acad As New AcadApplication Dim dwg As AcadDocument Dim strDwgs(3) As String Dim I As Integer strDwgs(0) = "c:\dwg\temp\aborder.dwg" strDwgs(1) = "c:\dwg\temp\bborder.dwg" strDwgs(2) = "c:\dwg\temp\cborder.dwg" strDwgs(3) = "c:\dwg\temp\dborder.dwg" For I = LBound(strDwgs) To UBound(strDwgs) Set dwg = acad.Documents.Open(strDwgs(I), False) dwg.SetVariable "filedia", 0 dwg.SendCommand ("script c:\dwg\150.scr" & vbNewLine) dwg.SetVariable "filedia", 1 dwg.Save dwg.Close Next I acad.Quit Set acad = Nothing Set dwg = Nothing End Sub *************************Code************************************* Tim Riley
Thanks Tim! I have a couple questions if you have a couple minutes: 1) Dim strdwgs(3) As String - is the '3' a limiter? Can I pass it another variable like a 'Count' - our processor provide a complete list of drawings that it gets from an INI file exported from Excel. Each item in the list has a check box and the routine sees the checked items and adds them to the processing list. 2) If I wanted to just *open* the drawings and not run a script, I could do this: If chkOpenOnly.Value = Checked dwg.SetVariable "filedia", 0 End If Right? Thanks again for your help!!