Click the dwg then get the Infomation of Entity

Click the dwg then get the Infomation of Entity

Anonymous
Not applicable
457 Views
2 Replies
Message 1 of 3

Click the dwg then get the Infomation of Entity

Anonymous
Not applicable

 

when I clicke the entity in dwg, I want to get that entity infomation, like a image.

 

캡처.JPG

 

 

So, I was using the event in Editor.

 

 

Editor ed = doc.Editor;
ed.PromptedForSelection += edPromptForSelection;

        private void edPromptForSelection(object sender, PromptSelectionResultEventArgs e)
        {
            Editor ed = sender as Editor;
            PromptSelectionResult psr = e.Result;

            if (psr.Status != PromptStatus.OK) return;

            ObjectId[] objArr = psr.Value.GetObjectIds();

            // 레이어를 생성하고, 점만 출력한다.
            using (docLock = doc.LockDocument())
            {
                using (tr = db.TransactionManager.StartTransaction())
                {
                    foreach (ObjectId Id in objArr)
                    {
                        Entity ent = tr.GetObject(Id, OpenMode.ForRead) as Entity;

                    }
                }
            }

            ed.SetImpliedSelection(objArr);
        }


It was working what I thought but Called the Event many times.... maybe 4?

I just want to call one by one clicked.

so, To release or Clear the selection list,
I used the

ed.SetImpliedSelection(objArr);

But It cannot fix the problem.

 

 

 

0 Likes
Accepted solutions (1)
458 Views
2 Replies
Replies (2)
Message 2 of 3

norman.yuan
Mentor
Mentor
Accepted solution

You did not show whole picture of how your code is loaded into AutoCAD and how it would be triggered.

 

However, if your goal is that after your code is loaded/enabled, whenever user selects an Entity in AutoCAD editor, your form pops up (modal or modeless?), you may want to think again: when user works with AutoCAD, he/she would click on AutoCAD editor/entities very often (consciously or unconsciously) for any purpose, do you want to annoy the user by keeping showing up your form?

 

You'd be better off using custom context menu when user right-click an entity, or using custom double-click event handler to give user the chance to explicitly/consciously show the form.

 

To use custom context menu, look into these article:

 

http://through-the-interface.typepad.com/through_the_interface/2007/05/adding_a_contex.html

http://through-the-interface.typepad.com/through_the_interface/2008/11/displaying-a-co.html

 

For custom double-click handling, this could be of help:

 

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

 

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 3

Anonymous
Not applicable

Thanks, norman.yuan.
0 Likes