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

selecting blocks, entities

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
f.roels
797 Views, 4 Replies

selecting blocks, entities

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

4 REPLIES 4
Message 2 of 5
_gile
in reply to: f.roels

Hi,

 

You can handle the Document.ImpliedSelectionChanged event.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 5
_gile
in reply to: f.roels

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

Message 4 of 5
_gile
in reply to: _gile

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



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 5 of 5
f.roels
in reply to: _gile

Hi Gilles,

 

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

 

best

 

Filip

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