Just thought I'd post this..
Arcticad gave me code to work out the right keywords to search for. The only google hit was a chinese website.
I added it to his/her code but didn't delete any of the existing handlers just in case.
Imports Autodesk.AutoCAD.Runtime Imports Autodesk.AutoCAD.DatabaseServices Imports Autodesk.AutoCAD.ApplicationServices Imports AcApp = Autodesk.AutoCAD.ApplicationServices.Application Imports Autodesk.AutoCAD.EditorInput <Assembly: ExtensionApplication(GetType(VbExtApp))> Public Class VbExtApp Implements Autodesk.AutoCAD.Runtime.IExtensionApplication Private DocMan As DocumentCollection 'Initialize sub Public Sub Initialize() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Initialize DocMan = AcApp.DocumentManager AddHandler DocMan.DocumentCreated, AddressOf callback_documentCreated AddHandler DocMan.DocumentActivated, AddressOf callback_documentActivated Dim doc As Document For Each doc In DocMan Dim db As Database = doc.Database AddHandler db.ObjectModified, AddressOf callback_ObjectModified AddHandler db.ObjectAppended, AddressOf callback_ObjectAppended AddHandler db.ObjectErased, AddressOf callback_ObjectErased AddHandler Application.BeginDoubleClick, AddressOf callback_BeginDoubleClick Next End Sub 'BeginDoubleClick Public Sub callback_BeginDoubleClick(ByVal sender As System.Object, ByVal e As Autodesk.AutoCAD.ApplicationServices.BeginDoubleClickEventArgs) MsgBox("Double Click") Dim doc As Document = Application.DocumentManager.MdiActiveDocument Dim ed As Editor = doc.Editor Dim res As PromptSelectionResult = ed.SelectImplied() Dim ss As SelectionSet = res.Value If ss IsNot Nothing Then If ss.Count = 1 Then Using tr As Transaction = doc.TransactionManager.StartTransaction() Dim br As BlockReference = DirectCast(tr.GetObject(ss(0).ObjectId, OpenMode.ForRead), BlockReference) If br IsNot Nothing Then DoubleClickBlock(br.ObjectId) End If End Using End If End If End Sub 'Terminate sub Public Sub Terminate() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Terminate RemoveHandler DocMan.DocumentCreated, AddressOf callback_documentCreated End Sub Public Shared Sub callback_ObjectModified(ByVal sender As System.Object, ByVal e As Autodesk.AutoCAD.DatabaseServices.ObjectEventArgs) 'MsgBox("Something was modified") ID = e.DBObject.ObjectId ObjectModified(ID) End Sub Public Shared Sub callback_ObjectAppended(ByVal sender As System.Object, ByVal e As Autodesk.AutoCAD.DatabaseServices.ObjectEventArgs) 'MsgBox("Something was Appended") End Sub Public Shared Sub callback_ObjectErased(ByVal sender As System.Object, ByVal e As Autodesk.AutoCAD.DatabaseServices.ObjectErasedEventArgs) 'MsgBox("Something was Erased") ID = e.DBObject.ObjectId ObjectErased(ID) End Sub Private Sub callback_documentCreated(ByVal sender As Object, ByVal e As DocumentCollectionEventArgs) If e.Document = Nothing Then Exit Sub Else ' MsgBox("Document Created") End If End Sub Private Sub callback_documentActivated(ByVal sender As Object, ByVal e As DocumentCollectionEventArgs) If e.Document = Nothing Then Exit Sub Else ' MsgBox("Document Active") End If End Sub End Class
Just at the quick glance...
- - you have to add reference:
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common
and also there is no Autodesk.AutoCAD.ApplicationServices.BeginDoubleClickEventArgs
this event is of AcadApplication, anyway I didn't see it in Intellisence drop-down
-- after adding references I showed above use simple BeginDoubleClickEventArgs instead
-- ID is not declared , the same with any subs:
ObjectErased(ID) &etc
Hi Hallex,
I am a newb so bear with me.
Took a while to find this but it does seem to kick off the event and return an ID without the need for interop references
Interop connects with 'old style' compentry? I don't know what interop means 😞
You have to add reference (References --> COM tab)
-- AutoCAD 2XXX Type Library
-- AutoCAD/ObjectDBX Common 1X.X Type Library
Thanks for info, Jeff,
I'm in A2009 yet
Can you provide the same way for 2010
(for one of friends of mine 🙂
Regards,
Oleg
Thanks Hallex,
I probably should use your suggestion from the sounds of things. Some computers in our office do have pre 2010 installations.
Can't find what you're looking for? Ask the community or share your knowledge.