Message 1 of 2
start lisp-Command immediately after sendstringtoexecute
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hi !
i have a vb.net-programm to create a drawing and save automatically.
before the dwg will be saved a lisp should be loaded and run. (kind of postprocessing).
the following function will work without any mistake:
Public Function LoadAndStartLisp(ByVal LispFilePath As String, Optional LispCommand As String = "") Dim Status As Integer = 0 AcReInit() ' keine LISP-Datei angegeben If LispFilePath.Length = 0 Then Return -2 If System.IO.File.Exists(LispFilePath) = False Then Return -1 End If Dim acDoc As Autodesk.AutoCAD.ApplicationServices.Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument Using acTrans As Transaction = _Database.TransactionManager.StartTransaction() Using acDoc.LockDocument ' erfolgreich geladen -> 1 Status = 1 Try Dim LispCommand2Load As String = "(load " & Chr(34) & LispFilePath & Chr(34) & "\r)" _AcDocument.SendStringToExecute(LispCommand2Load, True, False, False) Catch ex As Exception _Editor.WriteMessage("Kann Lisp nicht laden!" & vbCrLf & ex.ToString) Return -2 ' Lisp nicht geladen End Try ' ausführen eines bestimmten Commandos If LispCommand.Length > 0 Then Try _AcDocument.SendStringToExecute(LispCommand, True, False, False) _Editor.WriteMessage("rufe Lisp-Befehl auf: " & LispCommand) Catch ex As Exception _Editor.WriteMessage("Fehler beim Ausführen des LISP Befehls " & LispCommand & "" & vbCrLf & ex.ToString) Return -3 ' Fehler beim Ausführen des LISP-Befehls End Try End If End Using 'acDoc End Using 'acTrans Return Status End Function
my little test-lisp Shows first a alert-message and then inserts a block into dwg.
after the vb.net Programm finished the block the message will not Show and no block will be insert.
but!!!
if i double-click the middle mouse-wheel the lisp-Programm will be run.
in my first thoughts i missed a RETURN in the LispCommand2Load-Variable - i add \r - but this was not the solution!
could someone help me ?
regards Jan