C# WindowSelect not working

C# WindowSelect not working

Anonymous
Not applicable
266 Views
0 Replies
Message 1 of 1

C# WindowSelect not working

Anonymous
Not applicable

Hello,

I am working with a pointcloud object.

 

I am trying to select multiple PointCloudPoints through a windowselect with interactionevents. I have tried following/translating the sample given in the API to C#. My code works for selecting single points, but not for window-selecting multiple. (see photos)

 

What needs to change for the windowselect to work as intended?

 

Selecting a single point highlights and displays count message (fires onselect handler):

singleSelectionWorks.png

 

Window selecting does not highlight anything or fire onselect handler:

windowSelectionFails.png

 

The code:

class PCWindowSelector
    {
        private Application inv;
        private InteractionEvents interactEvents;
        private SelectEvents selectEvents;
        private bool bShowTooltip;

        public PCWindowSelector(Application _inv)
        {
            inv = _inv;

            interactEvents = inv.CommandManager.CreateInteractionEvents();
            interactEvents.InteractionDisabled = false;
            interactEvents.SelectionActive = true;
            interactEvents.Name = "PC Window Select Interaction";

            selectEvents = interactEvents.SelectEvents;

            
            selectEvents.OnPreSelect += new SelectEventsSink_OnPreSelectEventHandler(selectEvents_OnPreSelect);
            selectEvents.OnSelect += new SelectEventsSink_OnSelectEventHandler(selectEvents_OnSelect);
            interactEvents.OnTerminate += new InteractionEventsSink_OnTerminateEventHandler(InteractionEvents_OnTerminate);

            selectEvents.AddSelectionFilter(SelectionFilterEnum.kPointCloudPointFilter);
            
            selectEvents.WindowSelectEnabled = true;

            bShowTooltip = inv.GeneralOptions.ShowCommandPromptTooltips;
            inv.GeneralOptions.ShowCommandPromptTooltips = true;

            interactEvents.StatusBarText = "Window select. Esc to exit";
            
            System.Diagnostics.Debug.WriteLine("You are here 0");
            interactEvents.Start();

        }

        private void InteractionEvents_OnTerminate()
        {
            inv.GeneralOptions.ShowCommandPromptTooltips = bShowTooltip;

            selectEvents = null;
            interactEvents = null;
        }

        private void selectEvents_OnPreSelect(ref object preSelectEntity, out bool doHighlight, ref ObjectCollection morePreSelectEntity, SelectionDeviceEnum selectiondevice, Point modelPosition, Point2d viewPosition, View view)
        {
            doHighlight = true;
            //System.Diagnostics.Debug.WriteLine(morePreSelectEntity.Count);
        }

        private void selectEvents_OnSelect(ObjectsEnumerator selectedEntities, SelectionDeviceEnum selectiondevice, Point modelPosition, Point2d viewPosition, View view)
        {
            System.Diagnostics.Debug.WriteLine("You are here 2");
            System.Windows.Forms.MessageBox.Show(selectedEntities.Count.ToString() + " Points selected");
        }
    }

 

0 Likes
267 Views
0 Replies
Replies (0)