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

Why [ double click event handler ] doesn't work for dynamic blocks ?

1 REPLY 1
Reply
Message 1 of 2
ButterFlyShame
565 Views, 1 Reply

Why [ double click event handler ] doesn't work for dynamic blocks ?

Hello, again me with question for experts.

Why doesn't  code below doesn't work for  " Dynamic Blocks " ? . 

 message box pops up  for every object  exept for dynamic blocks.

Thanks for your considerations .

 

 

 

 

 

Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.EditorInput
Imports AcApv = Autodesk.AutoCAD.ApplicationServices.Application
Imports AcOp = Autodesk.AutoCAD.Interop
Module DoubleClickModule
    Private AcDoc As AcOp.AcadDocument
    Public Sub doubleclickeventstart()
        If AcDoc Is Nothing Then
            AcDoc = CType(AcApv.DocumentManager.MdiActiveDocument.AcadDocument, Autodesk.AutoCAD.Interop.AcadDocument)
            AddHandler AcDoc.BeginDoubleClick, AddressOf acdoc_BeginDoubleClick
        End If
    End Sub
    Private Sub acdoc_BeginDoubleClick(ByVal PickPoint As Object)
        Dim MdiActiveDocument As Document = AcApv.DocumentManager.MdiActiveDocument
        Dim GetSelection As PromptSelectionResult = MdiActiveDocument.Editor.GetSelection()


        Using DocumentLock As DocumentLock = MdiActiveDocument.LockDocument()
            If GetSelection.Status <> PromptStatus.OK Then Return
            If GetSelection.Value.Count <> 1 Then Return

            Dim ObjectId As Autodesk.AutoCAD.DatabaseServices.ObjectId = GetSelection.Value(0).ObjectId


            Using Transaction As Autodesk.AutoCAD.DatabaseServices.Transaction = MdiActiveDocument.TransactionManager.StartTransaction()
                Dim DBObject As Autodesk.AutoCAD.DatabaseServices.DBObject = Transaction.GetObject(ObjectId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite)
                Dim Entity As Autodesk.AutoCAD.DatabaseServices.Entity = TryCast(DBObject, Autodesk.AutoCAD.DatabaseServices.Entity)


                MsgBox(Entity.ToString)
                MsgBox(Entity.ObjectId.ToString)

                If Entity Is Nothing Then
                    MsgBox("ENTITY IS NOTHING")
                    Return
                End If
                Transaction.Abort()
            End Using
        End Using

    End Sub
End Module

 

1 REPLY 1
Message 2 of 2
Artvegas
in reply to: ButterFlyShame

I tried it in AutoCAD 2012 and it worked for me with dynamic blocks. Got both the entity type and ObjectId message boxes. No idea why it's not working for you.

 

Also not sure why you are mixing COM and .NET here when it could all be done in .NET. Perhaps you are doing so for other reasons not explained here. Edit: Ahhh I see why you're using COM now, as .NET doesn't seem to have such an event! 🙂

 

Hope this helps.

 

Art

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