.NET

Reply
Valued Contributor
RPeter
Posts: 91
Registered: ‎01-09-2009
Message 1 of 20 (749 Views)
Accepted Solution

Run command on double click block with specific name?

749 Views, 19 Replies
02-26-2013 08:00 AM

I wrote a couple of functions one of them creates a block with a Name let say "MyBlock".

I wrote a command "MyBlockEdit" where the selected block attribute data is displayed in a custom form to change some of the properties.

 

Now I want to add the folowing function:

When a block with the blockname "MyBlock" is doubleclicked the command "MyBlockEdit" is triggered in place of the attribute editor.

 

Can someone show me the way how to apply this?

I have finally found a bit time to work out an solution to the issue you have (or rather, the issue my posted solution has): Editor.SelectImplied() does not select a blockreference that has attributes. I would consider a bug.

 

My workaround is to drop using Editor.SelectImplied() in the Application_BeginDoubleClick event handler. I published a new article in my blog on the updated solution here:

 

http://drive-cad-with-code.blogspot.ca/2013/03/update-custom-double-click-action-using.html

 

 

*Expert Elite*
norman.yuan
Posts: 1,045
Registered: ‎04-27-2009
Message 2 of 20 (723 Views)

Re: Run command on double click block with specific name?

02-26-2013 10:08 AM in reply to: RPeter

This has been discussed recently and Balaji Remamoorthy has posted a solution:

 

http://forums.autodesk.com/t5/NET/How-to-capture-double-click-event-in-AutoCAD-using-VB-NET/td-p/371...

http://adndevblog.typepad.com/autocad/2012/12/customizing-double-click-on-block-reference.html

 

I also posted a solution in my blog, in which user do not have to modify DoubleClick action in CUI. see it here:

 

http://drive-cad-with-code.blogspot.ca/2012/12/custom-double-click-action-using.html

 

HTH.

 

 

 

Valued Contributor
RPeter
Posts: 91
Registered: ‎01-09-2009
Message 3 of 20 (687 Views)

Re: Run command on double click block with specific name?

02-27-2013 10:54 PM in reply to: norman.yuan

Norman, thanks to you I established to trigger the doubleclick command. However I'm strugling with the select.implied.

I've added temprorary a editor msg with the count of the selected objects. When I use select.implied it always return 0.

 

In my other command MyBlockEdit I also use the select.implied, this however doesn't seem to give any problem.

 

I think (not sure of it) that when I double click the selection gets lost and there is nothing selected anymore.?

*Expert Elite*
norman.yuan
Posts: 1,045
Registered: ‎04-27-2009
Message 4 of 20 (677 Views)

Re: Run command on double click block with specific name?

02-28-2013 06:43 AM in reply to: RPeter

Are you saying that in the Application.BeginDoubleClick event handler, the Editor.SelectImplied() always return 0 count of selected?

 

When you double-click on an entity, does it get highlighted? Or is the pickbox (cursor) too small and no entity is actually selected when you double-click?

 

Could you show your code in the event handler?

Valued Contributor
RPeter
Posts: 91
Registered: ‎01-09-2009
Message 5 of 20 (672 Views)

Re: Run command on double click block with specific name?

02-28-2013 07:50 AM in reply to: norman.yuan

Norman,

 

I'm out of office right now so can't copy the exact code, will do this first thing tomorrow.

The code looks like this:

Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
ed.WriteMessage(vbCrLf & "Custom Double-Click action started.")
Dim res As PromptSelectionResult = ed.SelectImplied
If res.Status = PromptStatus.OK Then
    ed.WriteMessage(vbCrLf & res.Value.Count & " object(s) selected.")
    'some more code to check if the selection is the right Dynamic Block...
End If

 

I get the message that the double-click action is started.

The return of the selected object count is always 0.

ed.selectprevious or ed.selectlast returns 1 (or more) but is never the correct selected entity...

Moderator
Alexander.Rivilis
Posts: 1,446
Registered: ‎04-09-2008
Message 6 of 20 (665 Views)

Re: Run command on double click block with specific name?

02-28-2013 09:56 AM in reply to: RPeter

If your's code is a command it must have CommandFlags.UsePickSet attribute in order to use ed.SelectImplied


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Valued Contributor
RPeter
Posts: 91
Registered: ‎01-09-2009
Message 7 of 20 (652 Views)

Re: Run command on double click block with specific name?

02-28-2013 10:16 PM in reply to: Alexander.Rivilis

Alexander,

 

It's not a command, its a Double-Click handler.

 

Norman,

 

Here is the code from my app:

Public Shared Sub MyDblClick(ByVal sender As Object, ByVal e As BeginDoubleClickEventArgs)
    Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
    ed.WriteMessage(vbCrLf & "Custom Double-Click action started.")
    Dim res As PromptSelectionResult = ed.SelectImplied
    If res.Status = PromptStatus.OK Then
        ed.WriteMessage(vbCrLf & res.Value.Count & " object(s) selected.")
        'some more code to check if the selection is the right Dynamic Block...
    End If
End Sub

 I've tested some more with the code from above:

Double-Clicking on a Polyine, Rectangle,... it will return the number of the selected items.

Double-Clicking on a block (without attributes) = result of selected items.

Double-Clicking on a block (with attributes) = no result of the selected items.

 

How can I pass this problem?

Moderator
Alexander.Rivilis
Posts: 1,446
Registered: ‎04-09-2008
Message 8 of 20 (644 Views)

Re: Run command on double click block with specific name?

02-28-2013 10:56 PM in reply to: RPeter

RPeter wrote:

Alexander,

 

Double-Clicking on a block (with attributes) = no result of the selected items.

 

How can I pass this problem?


It is look like a bug. But I think there is workaround: using PointMonitor event to monitor entity under cursor in moment of doubleclick.


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

*Expert Elite*
norman.yuan
Posts: 1,045
Registered: ‎04-27-2009
Message 9 of 20 (633 Views)

Re: Run command on double click block with specific name?

03-01-2013 07:15 AM in reply to: RPeter

OK, I verified with this code:

 

private void Application_BeginDoubleClick(object sender, BeginDoubleClickEventArgs e)
        {
            Document dwg = Application.DocumentManager.MdiActiveDocument;
            Editor ed = dwg.Editor;

            PromptSelectionResult res = ed.SelectImplied();
            if (res.Status == PromptStatus.OK)
            {
                ed.WriteMessage("{0} entit{1} selected.", res.Value.Count, res.Value.Count > 1 ? "ies" : "y");
            }
            else
            {
                ed.WriteMessage("\nCannot select implied selection set.");
            }
        }

The Editor.SelectImplied() work with line, circle, arc, block WITHOUT attribute (e.g) PromptSelectionResult.Status returns OK). However, if we double-click a block that has attribute, the returned status is PromptStatus.Error. So, I am not sure if it is by design (probably not, because the built-in doubleclick action defined by the CUI works). It could be a bug as Alexander suggested. If so, it is serious blow to my double-click solution, because calling up custom dialog box on double-click would likely be used more often on editing block with attribute. I'll have to find workaround and updte my blog post.

 

I currently only have access to Acad2012, and hope this has already been fixed in Acad 2013, or upcoming Acad2014?

Valued Contributor
RPeter
Posts: 91
Registered: ‎01-09-2009
Message 10 of 20 (623 Views)

Re: Run command on double click block with specific name?

03-01-2013 10:32 PM in reply to: norman.yuan

Norman,

 

The problem is still there in 2013 (+SP1), this is the version we use about 3 months now.

We have no plans to upgrade straight away to the 2014 when its available becouse where are in a Vault implementation process right now for all our Autodesk Software.

 

I'll try to search for a work arround, if I would find a solution I'll post it here.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!