Insert Block Event

Insert Block Event

Anonymous
Not applicable
1,146 Views
7 Replies
Message 1 of 8

Insert Block Event

Anonymous
Not applicable

Someone help me get started here. 

 

I'd like to trigger a procedure to split a line upon a block being draged and dropped over it.

I drag a valve block onto a piping polyline and I'd eventually like it to autobreak by specificed amount. 

 

What's the event for a block being inserted into a drawing? 

 

Thanks, 

0 Likes
1,147 Views
7 Replies
Replies (7)
Message 2 of 8

Jeff_M
Consultant
Consultant

Database.InsertEnded Event should work.

Jeff_M, also a frequent Swamper
EESignature
Message 3 of 8

Anonymous
Not applicable

How do I tell what was just inserted or how do I get the objectid of the most recently inserted block? 

0 Likes
Message 4 of 8

arcticad
Advisor
Advisor

http://forums.autodesk.com/t5/NET/Get-Last-Entity/m-p/2752298/highlight/true#M20452

---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes
Message 5 of 8

Anonymous
Not applicable

Thanks. 

0 Likes
Message 6 of 8

Anonymous
Not applicable
    Private Sub callback_BlockInserted(ByVal Sender As Object, ByVal e As System.EventArgs)
    

        Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database
        Using trans As Transaction = db.TransactionManager.StartTransaction


            Dim objID As ObjectId = Autodesk.AutoCAD.Internal.Utils.EntLast()

            Dim btr As BlockTableRecord = trans.GetObject(objID, OpenMode.ForRead)
            MsgBox("Your Block Name Is " + btr.Name() + vbCrLf)


            'Next
        End Using


      

    End Sub

 

Okay here... Hmm.. I missing something.. cause it's not working. 

0 Likes
Message 7 of 8

Jeff_M
Consultant
Consultant

OK, false alarm, sorry.... Looks like the InsertEnded event only fires when adding a new Block to the Block table. Inserting a block already in the drawing doesn't trigger it. And, whe it does trigger, it fires before the Block is actually inserted, so the EntLast() method is returning the object added just prior to inserting the block. 

May need to use the ObjectAppended event. Wish I had time to look into this further....

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 8 of 8

jeff
Collaborator
Collaborator
0 Likes