Hallo Holger,
ich hab mir da mal ein paar Zeilen zusammen kopiert.
Beim Öffnen von ACAD krieg ich ne Fehlermeldung und die DocClose wird leider nicht aus geführt.
Was mach ich da falsch? kannst Du ein paar Verbesserungen vornehmen.
Gruß, Theo
Imports Autodesk.AutoCAD
Public Class Events
Private Shared pDocManager As Autodesk.AutoCAD.ApplicationServices.DocumentCollection = Nothing
Private Shared WithEvents pThisDrawing As Autodesk.AutoCAD.ApplicationServices.Document = Nothing
Public Class Events_Initialize
Implements Autodesk.AutoCAD.Runtime.IExtensionApplication
Public Sub Initialize() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Initialize
Try
Call setThisDrawing(pDocManager.MdiActiveDocument)
AddHandler pThisDrawing.BeginDocumentClose, AddressOf DocClose
Catch ex As Exception
Call MsgBox("Error initializing CADde_DocEvents", MsgBoxStyle.Critical, "CADde_DocEvents FEHLER")
End Try
End Sub
Public Sub Terminate() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Terminate
On Error Resume Next
End Sub
End Class
Private Shared Function setThisDrawing(ByRef Doc As ApplicationServices.Document) As Boolean
Dim tRetVal As Boolean = True
Try
If pThisDrawing IsNot Nothing Then pThisDrawing = Nothing
Catch ex As Exception
End Try
Try
If Doc IsNot Nothing Then pThisDrawing = Doc
Catch ex As Exception
tRetVal = False
End Try
Return tRetVal
End Function
Private Shared Sub DocClose(ByVal sender As Object, ByVal e As Autodesk.AutoCAD.ApplicationServices.DocumentBeginCloseEventArgs)
Dim i As Integer
Dim ii As Integer
Dim section As String
Dim Key As String
Dim Value As String
section = "Section Last open file"
For i = 50 To 2 Step -1
ii = i - 1
Key = "file " & ii
Value = ModINI.getonefromini(section, Key)
Key = "file " & i
ModINI.setonetoini(section, Key, Value)
Next i
Key = "file " & 1
ModINI.setonetoini(section, Key, sender.FullName)
End Sub
End Class
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP