.NET

.NET

Reply
Distinguished Contributor
HJohn1
Posts: 170
Registered: ‎09-26-2008
Message 1 of 3 (246 Views)

Fire BeginDoubleClick Event when Double Click On ATTBLOCKREF

246 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*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 2 of 3 (224 Views)

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

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Distinguished Contributor
HJohn1
Posts: 170
Registered: ‎09-26-2008
Message 3 of 3 (217 Views)

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.

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.