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?
Solved! Go to Solution.
Solved by norman.yuan. Go to Solution.
This has been discussed recently and Balaji Remamoorthy has posted a solution:
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.
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.?
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?
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...
If your's code is a command it must have CommandFlags.UsePickSet attribute in order to use ed.SelectImplied
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
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?
@Anonymous 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.
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
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?
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.
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
Norman Yuan
Norman,
I've just read your new post.
However I can't access the ed.SelectAtPickbox()
'SelectAtPickbox' is not a member of 'Autodesk.Autocad.Editorinput.Editor'
I'm using VB.net 2010 (because my C# isn't so good )
***EDIT
Looks like it was to early this morning, your solution was ok.
***END EDIT
Regards
Peter
Hi, Norman!
Great job! Criticism is accepted? Not tested but (IMHO):
1. You have to convert points to UCS because SelectCrossingPolygon method use points in UCS.
2. Maybe using method Editor.GetNestedEntity with PromptNestedEntityOptions.UseNonInteractivePickPoint == true instead of SelectCrossingPolygon will be useful.
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Alexander,
I've tried your solution, but the selected entity is the modelspace entity and not the selected block.
@all,
Normaly when a attribute block is DoubleClicked it sends the EATTEDIT command followed by the block location (point3d)
Because we've vetoed the EATTEDIT command I would like to supress the following line:
Command: 281.959074,252.067108,0.000000 Unknown command "959074,252.067108,0.000000". Press F1 for help.
@Anonymous wrote:
Alexander,
I've tried your solution, but the selected entity is the modelspace entity and not the selected block.
What is the solution? You're talking about using Editor.GetNestedEntity?
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
The solution is the ed.selectatpickbox method.
The method ed.getnestedentity returns the modelspace objectid so this is a no go for me.
@Anonymous wrote:
... The method ed.getnestedentity returns the modelspace objectid so this is a no go for me...
Try this code to identify selected BlockReference:
[CommandMethod("TestSel")] public static void TestSel() { Document doc = Application.DocumentManager.MdiActiveDocument; Editor ed = doc.Editor; PromptPointResult ppr = ed.GetPoint("\nPick Point on entity: "); if (ppr.Status != PromptStatus.OK) return; PromptNestedEntityOptions pneo = new PromptNestedEntityOptions(""); pneo.NonInteractivePickPoint = ppr.Value; pneo.UseNonInteractivePickPoint = true; PromptNestedEntityResult pner = ed.GetNestedEntity(pneo); if (pner.Status != PromptStatus.OK) return; ObjectId[] ids = pner.GetContainers(); using (Transaction tr = doc.TransactionManager.StartTransaction()) { Entity ent = tr.GetObject(pner.ObjectId, OpenMode.ForRead) as Entity; ed.WriteMessage("\nSelected entity of class {0} with objectId = {1}", ent.GetRXClass().Name, pner.ObjectId); if (ent is AttributeReference && ids.Length == 0) { AttributeReference attr = ent as AttributeReference; BlockReference bref = tr.GetObject(attr.OwnerId, OpenMode.ForRead) as BlockReference; BlockTableRecord btr = tr.GetObject(bref.BlockTableRecord, OpenMode.ForRead) as BlockTableRecord; ed.WriteMessage("\nin BlockReference of {0} with objectId = {1}", btr.Name, bref.ObjectId); } else if (ids.Length > 0) { BlockReference bref = tr.GetObject(ids[0], OpenMode.ForRead) as BlockReference; BlockTableRecord btr = tr.GetObject(bref.BlockTableRecord, OpenMode.ForRead) as BlockTableRecord; ed.WriteMessage("\nBlockReference of {0} with objectId = {1}", btr.Name, bref.ObjectId); } else { ed.WriteMessage("\nSelected not BlockReference!"); } tr.Commit(); } }
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
@Alexander,
Your code seems to work.
I've done it wrong I've stopped after setting the entity to pner.objectid and didn't go further to the bref and btr (and in my case a dbtr dynamicblocktablerecord to determine the real name)
Thank you Alexander. Yes, I should have take into UCS into account. I'll update if I can manage a bit time for it.
Norman Yuan
Hello
This runs fine with AutoCAD. With AutoCAD Mechanical, at least with Rel. 2012, the BeginDoubleClick event is only fired, if the double-click is run without any entity. Any idea?
Regards,
Martin
Can't find what you're looking for? Ask the community or share your knowledge.