Distinguished Contributor
171 Posts
4 Kudos
Registered: ‎09-26-2008
Post 1 of 3

Fire BeginDoubleClick Event when Double Click On ATTBLOCKREF

264 Views, 2 Replies
06-25-2012 01:29 PM

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.

*Expert Elite*
1,569 Posts
171 Kudos
Registered: ‎10-08-2008
Post 2 of 3

Re: Fire BeginDoubleClick Event when Double Click On ATTBLOCKREF

06-25-2012 11:10 PM in reply to: HJohn1

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()
            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


            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 


                    ' check if you're working with attribute here



                    '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



Distinguished Contributor
171 Posts
4 Kudos
Registered: ‎09-26-2008
Post 3 of 3

Re: Fire BeginDoubleClick Event when Double Click On ATTBLOCKREF

06-26-2012 05:26 AM in reply to: Hallex

Thank you very much for your help.  I will take a look at it.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!