selecting blocks, entities

selecting blocks, entities

Anonymous
Not applicable
1,054 Views
4 Replies
Message 1 of 5

selecting blocks, entities

Anonymous
Not applicable

Hello,

 

I have some blocks which are placed with some routines in VB.net and are linked by a unique code to a external data file (XML-file). I want to try to created a kind of propertybox (in a toolpalette) which indicate some of this external data values. If one of these values are changed (by changing the values in the propertybox), some routines need to be executed.

So my question is, is it possible when a object is selected (not during a command), to run a piece of code (VB.NET). I have found some basic principles about "overruling" but I'm not sure this is the correct/possible way to solve the problem and I'm not there yet.

Can somebody help me with some sample code in VB.NET?


thx

 

Filip

0 Likes
Accepted solutions (2)
1,055 Views
4 Replies
Replies (4)
Message 2 of 5

_gile
Consultant
Consultant
Accepted solution

Hi,

 

You can handle the Document.ImpliedSelectionChanged event.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 5

_gile
Consultant
Consultant
Accepted solution

Here's a little sample.

 

C#

        [CommandMethod("On")]
        public void On()
        {
            Document doc = AcAp.DocumentManager.MdiActiveDocument;
            doc.ImpliedSelectionChanged += new EventHandler(doc_ImpliedSelectionChanged);
        }

        [CommandMethod("Off")]
        public void Off()
        {
            Document doc = AcAp.DocumentManager.MdiActiveDocument;
            doc.ImpliedSelectionChanged -= new EventHandler(doc_ImpliedSelectionChanged);
        }

        void doc_ImpliedSelectionChanged(object sender, EventArgs e)
        {
            Document doc = (Document)sender;
            Editor ed = doc.Editor;
            PromptSelectionResult psr = ed.SelectImplied();
            if (psr.Status == PromptStatus.OK)
                AcAp.ShowAlertDialog(string.Format("{0} selected entities", psr.Value.Count));
        }

 

VB

        <CommandMethod("On")> _
        Public Sub [On]()
            Dim doc As Document = Application.DocumentManager.MdiActiveDocument
            AddHandler doc.ImpliedSelectionChanged, AddressOf doc_ImpliedSelectionChanged
        End Sub

        <CommandMethod("Off")> _
        Public Sub Off()
            Dim doc As Document = Application.DocumentManager.MdiActiveDocument
            RemoveHandler doc.ImpliedSelectionChanged, AddressOf doc_ImpliedSelectionChanged
        End Sub

        Private Sub doc_ImpliedSelectionChanged(sender As Object, e As EventArgs)
            Dim doc As Document = DirectCast(sender, Document)
            Dim ed As Editor = doc.Editor
            Dim psr As PromptSelectionResult = ed.SelectImplied()
            If psr.Status = PromptStatus.OK Then
                Application.ShowAlertDialog(String.Format("{0} selected entities", psr.Value.Count))
            End If
        End Sub

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 4 of 5

_gile
Consultant
Consultant

You can also handle the DBObject.Modified event for you blocks.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 5 of 5

Anonymous
Not applicable

Hi Gilles,

 

thanks for your reply. Using your code/example I managed to reach my goal.

 

best

 

Filip

0 Likes