I am using VS2010 and AutoCAD 2014. I am writing a stand-alone exe form to automate running multiple different Lisp programs on hundreds of files at one time. I have written lots of scripts and Lisps, but this is my first try at VB.
I have two private subs that are called to perform modifications on selected files. The first "WriteScript" writes a custom .scr file to load the lisp and enter any user prompts the Lisp needs based on information the user entered previously into the form. The second "OpenDWG" opens the selected files and calls the previously written .scr file.
It runs and makes all the needed changes to the files, but the AutoCAD "Help Window" pops up every time as if I had clicked F1. I included the parts of my VB code that are used for this.
... If ckbxChgIssue.Checked = True Then Dim x As Integer = Val(lbActionCount.Text) Dim File2Open As String WriteScript() For i = 0 To x - 1 File2Open = (lbPath.Text & "\" & ListBox2.Items(i) & ".dwg") OpenDWG(File2Open) Next i MsgBox(cbChgIssue.Text & " - Drawings Issue Stamp Updated") End If ... Private Sub OpenDWG(ByVal File2Open As String) Dim acadApp As AcadApplication = GetObject(, "AutoCAD.Application") acadApp.Application.Visible = True Dim acadDoc As AcadDocument acadDoc = acadApp.Documents.Open(File2Open) acadDoc.SendCommand("(command " & Chr(34) & "._script" & Chr(34) & Chr(34) & "C:/temp/B_UWIZ.SCR" & Chr(34) & ") ") acadDoc.SendCommand("zoom e ") End Sub Private Sub WriteScript() Dim FILE_NAME As String = ("C:\temp\B_UWIZ.SCR") Dim nStamp As String = cbChgIssue.Text Dim nNote As String = DateChgIssue.Text Dim sPath As String = ("(load " & Chr(34) & "W:/Energy Services/Control/Team Corona/Team Corona/LSP/UDM_ISSUE_WIZ.lsp" & Chr(34) & ") ") 'If System.IO.File.Exists(FILE_NAME) = False Then Dim objWriter As New System.IO.StreamWriter(FILE_NAME, False) objWriter.WriteLine(sPath) objWriter.WriteLine("UBIW") objWriter.WriteLine(nStamp) Select Case nStamp Case "Manufacture" objWriter.WriteLine(nNote) Case "Construction" objWriter.WriteLine(nNote) End Select objWriter.Close() 'End If End Sub
Solved! Go to Solution.
Solved by owenwengerd. Go to Solution.
Try removing the space character from the end of your first script line.
If I remove that space, I get this error. I have previously tried removing many different spaces since it seems like there is an extra return, but then the program doesn't run at all. So far I am just living with the help window popping up since the rest of the program works well.
I think you misunderstood. I'm referring to the space at the end of the line that you're writing to the script file, not the space in the commands you're sending to the command line.
Worked! Thought I needed that space since the space was needed when sending to the command line. But regardless, the program works and the Help Window no longer pops up! Thanks!
The reason the space isn't needed in the script file is because WriteLine appends a carriage return, which performs the same function as the space.
Can't find what you're looking for? Ask the community or share your knowledge.