06-26-2015, 12:30 PM
şöyle bişey var: http://through-the-interface.typepad.com...g-net.html
madem memorymappedfiles kullanamıyorsun, metodu çağırıp sonuçları diske dosya olarak yazıp değişiklikleri dinleyebilirsin.
Imports System
Imports System.Runtime.InteropServices
Imports Autodesk.AutoCAD.Interop
Dim path As String = "C:\Drawingx.dwt"
Dim ACAD As New Autodesk.AutoCAD.Interop.AcadApplication
Dim Status As String = "Run"
Do Until Status = "Stop"
Try
ACAD.Visible = True
Status = "Stop"
Catch ex As Exception
'MessageBox.Show(ex.Message)
System.Threading.Thread.Sleep(500)
End Try
Loop
ACAD.Application.WindowState = Common.AcWindowState.acMax
ACAD.ActiveDocument.Close()
ACAD.Application.Documents.Open(path)Alıntı:
Imports System
<div>Imports System.Runtime.InteropServices
Imports Autodesk.AutoCAD.Interop
Public Class Form1
Private Sub btnLaunchAutoCAD_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLaunchAutoCAD.Click
Me.Cursor = Cursors.WaitCursor
Dim path As String = "C:\textchange.dwt"
MessageFilter.Register()
Dim ACAD As Autodesk.AutoCAD.Interop.AcadApplication
ACAD = New Autodesk.AutoCAD.Interop.AcadApplication
ACAD.Visible = True
ACAD.Application.WindowState = Common.AcWindowState.acMax
ACAD.ActiveDocument.Close()
ACAD.Application.Documents.Add(path) 'Opens a .dwt template as DrawingN.dwg
MessageFilter.Revoke()
Me.Cursor = Cursors.Default
End
End Sub
End Class
</div>
Imports System.Runtime.InteropServices
' Reference Microsoft Development Environment 8.0 for this class
<ComImport(), Guid("00000016-0000-0000-C000-000000000046"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)>Public Interface IOleMessageFilter
<PreserveSig()> Function HandleInComingCall(ByVal dwCallType As Integer, ByVal hTaskCaller As IntPtr, ByVal dwTickCount As Integer,ByVal lpInterfaceInfo As IntPtr) As Integer
<PreserveSig()> Function RetryRejectedCall(ByVal hTaskCallee As IntPtr, ByVal dwTickCount As Integer,ByVal dwRejectType As Integer) As Integer
<PreserveSig()> Function MessagePending(ByVal hTaskCallee As IntPtr, ByVal dwTickCount As Integer,ByVal dwPendingType As Integer) As Integer
End Interface
Public Class MessageFilter
Implements IOleMessageFilter
<DllImport("Ole32.dll")>Private Shared Function CoRegisterMessageFilter(ByVal newFilter As IOleMessageFilter, ByRef oldFilter As IOleMessageFilter) As Integer
End Function
Public Shared Sub Register()
Dim newFilter As IOleMessageFilter = New MessageFilter()
Dim oldFilter As IOleMessageFilter = Nothing
CoRegisterMessageFilter(newFilter, oldFilter)
End Sub
Public Shared Sub Revoke()
Dim oldFilter As IOleMessageFilter = Nothing
CoRegisterMessageFilter(Nothing, oldFilter)
End Sub
Public Function HandleInComingCall(ByVal dwCallType As Integer, ByVal hTaskCaller As System.IntPtr, ByVal dwTickCount As Integer, ByVal lpInterfaceInfo As System.IntPtr) As Integer Implements IOleMessageFilter.HandleInComingCall
Return 0
End Function
Public Function MessagePending(ByVal hTaskCallee As System.IntPtr, ByVal dwTickCount As Integer, ByVal dwPendingType As Integer) As Integer Implements IOleMessageFilter.MessagePending
Return 2
End Function
Public Function RetryRejectedCall(ByVal hTaskCallee As System.IntPtr, ByVal dwTickCount As Integer, ByVal dwRejectType As Integer) As Integer Implements IOleMessageFilter.RetryRejectedCall
If (dwRejectType = 2) Then
Return 99
'Value >=0 and <100: the call is to be retried immediately
'Value >=100: COM will wait for this many milliseconds and then retry the call
'Value -1: the call should be canceled. COM the Returns RPC_E_CALL_REJECTED for the original method call
Else
Return -1
End If
End Function
End Class