Message 1 of 1
C# WindowSelect not working

Not applicable
05-27-2020
02:28 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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):
Window selecting does not highlight anything or fire onselect handler:
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");
}
}