.NET

Reply
Contributor
f.roels
Posts: 12
Registered: ‎09-23-2011
Message 1 of 5 (289 Views)
Accepted Solution

selecting blocks, entities

289 Views, 4 Replies
07-12-2013 07:35 AM

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

*Expert Elite*
_gile
Posts: 2,078
Registered: ‎04-29-2006
Message 2 of 5 (275 Views)

Re : selecting blocks, entities

07-12-2013 08:16 AM in reply to: f.roels

Hi,

 

You can handle the Document.ImpliedSelectionChanged event.

Gilles Chanteau
*Expert Elite*
_gile
Posts: 2,078
Registered: ‎04-29-2006
Message 3 of 5 (271 Views)

Re : selecting blocks, entities

07-12-2013 08:31 AM 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
*Expert Elite*
_gile
Posts: 2,078
Registered: ‎04-29-2006
Message 4 of 5 (265 Views)

Re : selecting blocks, entities

07-12-2013 09:03 AM in reply to: _gile

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

Gilles Chanteau
Contributor
f.roels
Posts: 12
Registered: ‎09-23-2011
Message 5 of 5 (177 Views)

Re : selecting blocks, entities

07-30-2013 08:13 AM in reply to: _gile

Hi Gilles,

 

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

 

best

 

Filip

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community