e.Context.GetPickedEntities() not finding any entities

e.Context.GetPickedEntities() not finding any entities

Jeff_M
Consultant Consultant
877 Views
4 Replies
Message 1 of 5

e.Context.GetPickedEntities() not finding any entities

Jeff_M
Consultant
Consultant

I have a number of these PointMonitors in different tools which all work flawlessly. I have one tool that is never finding any entities in the PointMonitor Event. It's so basic that I just don't understand why it's doing this. In the below code it always exits due to paths being null or empty. The TransientGraphics that update do so as they should, so I know the PointMonitor is working. I checked my Aperture setting in case it got set to 0, but it's 10 as always.

 

Any ideas why it's not finding any entities?

 

        private void Editor_PointMonitor(object sender, PointMonitorEventArgs e)
        {
            _currentPoint = e.Context.RawPoint;
            UpdateTransGraphics(_currentPoint);
            
            FullSubentityPath[] paths = e.Context.GetPickedEntities();

            if (paths == null || paths.Length == 0)
                return;

            ObjectId[] ids = paths[0].GetObjectIds();

            if (ids == null || ids.Length == 0)
                return;

            ObjectId id = ids[0];
            if (id.ObjectClass.DxfName != RXClass.GetClass(typeof(CogoPoint)).DxfName)
                return;
            NextPtId = id;
        }

  

 

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Accepted solutions (1)
878 Views
4 Replies
Replies (4)
Message 2 of 5

norman.yuan
Mentor
Mentor
Accepted solution

@Jeff_M 

 

In what context the PointMonitor is handled? It looks like, it is used in a kind of "custom jig" style operation, such as the Editor is waiting for user input from mouse click (Ediotr.GetXxxx()), and when user moves mouse to mull where to pick, the PointMonitor handler generates moving ghost. If so, I believe when Editor is in this state, PointMonitorEventArgs.Context.GetPickedEntities() does not return entities at mouse cursor.

 

I mentioned this in my latest blog post (yesterday):

https://drive-cad-with-code.blogspot.com/2020/03/showing-helpful-information-as-tool-tip.html 

 

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 5

Jeff_M
Consultant
Consultant

Thank you, @norman.yuan ! Nice solution you created in the blog post. 

 

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 4 of 5

Alexander.Rivilis
Mentor
Mentor

Other solution (if I remember correctly)  is using Editor.TurnForcedPickOn/Editor.TurnForcedPickOff pair.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | 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
Expert Elite Member

0 Likes
Message 5 of 5

norman.yuan
Mentor
Mentor

Great suggestion, @Alexander.Rivilis , Thanks.

 

I never noticed/paid attention to this pair of methods. I went ahead to give it a try, and yes, it does forces the PointMonitorEventArgs.Context.GetPickedEntities() to return entities at/near mouse cursor when the Editor is waiting for user input(picking). So, while my original code in my article works, using this pair of methods seems a more elegant approach. 

 

I have updated the code in my article. Thank you again, @Alexander.Rivilis !

Norman Yuan

Drive CAD With Code

EESignature