.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Fire BeginDoubleClick Event when Double Click On ATTBLOCKREF

2 REPLIES 2
Reply
Message 1 of 3
HJohn1
616 Views, 2 Replies

Fire BeginDoubleClick Event when Double Click On ATTBLOCKREF

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.

2 REPLIES 2
Message 2 of 3
Hallex
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
Message 3 of 3
HJohn1
in reply to: Hallex

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost