Community
Can someone help me to modify the default double click behaviour for ATTBLOCKREF so that it doesn't start the
EATTEDIT command or anything else, so that the AcadDocument_BeginDoubleClick event can fire. It used to work fine in AutoCAD 2010 but I am having problems now with AutoCAD 2012. Thanks in advance.
Try this class, don't remember where I grab this code
Imports Autodesk.AutoCAD.ApplicationServices Imports Autodesk.AutoCAD.EditorInput Imports AcApp = Autodesk.AutoCAD.ApplicationServices.Application Imports AcOp = Autodesk.AutoCAD.Interop Imports Autodesk.AutoCAD.Runtime Public Class DblClickClass Public AcDoc As AcOp.AcadDocument <CommandMethod("DCLICK", CommandFlags.UsePickSet And CommandFlags.Redraw And CommandFlags.Modal)> _ Public Sub dblClickOtherWork() Try AcApp.SetSystemVariable("DBLCLKEDIT", 0) If AcDoc Is Nothing Then AcDoc = CType(AcApp.DocumentManager.MdiActiveDocument.AcadDocument, Autodesk.AutoCAD.Interop.AcadDocument) AddHandler AcDoc.BeginDoubleClick, AddressOf acdoc_BeginDoubleClick End If Catch ex As System.Exception Finally AcApv.SetSystemVariable("DBLCLKEDIT", 1) End Try End Sub Private Sub acdoc_BeginDoubleClick(ByVal PickPoint As Object) 'dont use variable name the same as object type - bad code practice,generally don't recommended (Andrew Troelsen, Petzold) Dim doc As Document = AcApp.DocumentManager.MdiActiveDocument Dim selObj As PromptSelectionResult = doc.Editor.GetSelection() Using docLoc As DocumentLock = doc.LockDocument() If selObj.Status <> PromptStatus.OK Then Return If selObj.Value.Count <> 1 Then Return Dim objID As Autodesk.AutoCAD.DatabaseServices.ObjectId = selObj.Value(0).ObjectId Using tr As Autodesk.AutoCAD.DatabaseServices.Transaction = doc.TransactionManager.StartTransaction() Dim dbObj As Autodesk.AutoCAD.DatabaseServices.DBObject = tr.GetObject(objID, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite) Dim entObj As Autodesk.AutoCAD.DatabaseServices.Entity = TryCast(dbObj, Autodesk.AutoCAD.DatabaseServices.Entity) If entObj Is Nothing Then Return Else ' check if you're working with attribute here ''__________________________________________'' tr.Commit() MsgBox(entObj.Handle.ToString) 'RemoveHandler AcDoc.BeginDoubleClick, AddressOf acdoc_BeginDoubleClick ' if you'll use this just once in program add this line End If End Using '<-- the point where transaction is disposed automatically End Using End Sub End Class
~'J'~