Basically I'm building a Batch Script processor and my code loops through
file names in a listview. It all seems to work failry well but I've now
noticed that the dwg's open in read only mode. Very odd. My code is below.
Another question is can autocad accept multiple commands at once. Do I force
my app to wait for autocad to complete the commands I send before sending
more commands? i.e. I want to wait for the scripts to finish running before
my app tries to save the drawing.
TIA
Russ
CODE:::
For i As Integer = 0 To Me.ListView1.Items.Count - 1
'open the file
Me.sbpText.Text = "Opening file..."
file =
ApplicationServices.Application.DocumentManager.Open(Me.ListView1.Items.Item(i).Text,
False)
'process the script
Me.sbpText.Text = "Running script..."
'set filedia to 0
ApplicationServices.Application.SetSystemVariable("filedia", 0)
'file.SendStringToExecute("filedia ", True, False, True)
'file.SendStringToExecute("0 ", True, False, True)
'load the script
file.SendStringToExecute("script ", True, False, True)
file.SendStringToExecute("""" & Me.txtScript.Text & """" & vbCr,
True, False, True)
'set filedia to 1
ApplicationServices.Application.SetSystemVariable("filedia", 1)
'file.SendStringToExecute("filedia ", True, False, True)
'file.SendStringToExecute("1 ", True, False, True)
If file.IsReadOnly = True Then
MsgBox("file is readonly", MsgBoxStyle.Critical)
End If
'close the file
Me.sbpText.Text = "Saving & closing file..."
Try
file.CloseAndSave(Me.ListView1.Items.Item(i).Text)
Catch ex As Exception
MsgBox(ex.Source & " : " & ex.Message)
End Try
'advance the progress bar
spb.ProgressBar.Value = spb.ProgressBar.Value + 1
Next