# How to: Find a point on the surface of a model given a known window point

**URL:** <https://forum.techsoft3d.com/t/how-to-find-a-point-on-the-surface-of-a-model-given-a-known-window-point/1382>\
**Category:** HOOPS Visualize Desktop\
**Tags:** learn, knowledge-base, how-to\
**Created:** [October 1, 2021, 4:00am UTC](https://forum.techsoft3d.com/t/how-to-find-a-point-on-the-surface-of-a-model-given-a-known-window-point/1382 "2021-10-01T04:00:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabriel.peragine](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.techsoft3d.com/gabriel.peragine/32/1535_2.png) [@gabriel.peragine](https://forum.techsoft3d.com/u/gabriel.peragine)\
**Post date:** [October 1, 2021, 4:00am UTC](https://forum.techsoft3d.com/t/how-to-find-a-point-on-the-surface-of-a-model-given-a-known-window-point/1382/1 "2021-10-01T04:00:00Z")

</div>

As part of the `SelectionItem` class in HPS, there is the function `ShowSelectionPosition()`:  
[https://docs.techsoft3d.com/hps/latest/api\_ref/cs/class\_h\_p\_s\_1\_1\_selection\_item.html?highlight=showselectionposition#function-HPS.SelectionItem.ShowSelectionPosition](https://docs.techsoft3d.com/hps/latest/api_ref/cs/class_h_p_s_1_1_selection_item.html?highlight=showselectionposition#function-HPS.SelectionItem.ShowSelectionPosition)  
Depending on the variant of the function, it will return a `WindowPoint `or `WorldPoint`.

To demonstrate getting a `WorldPoint`, below is a code snippet that can be executed in the hps\_mfc\_sandbox Visual Studio project found in the directory:  
HOOPS\_Visualize\_202X\samples\mfc\_sandbox

```auto
void CHPSView::OnUserCode3()
{
	//First load model then run user code
	SegmentKey modelKey = _canvas.GetAttachedLayout().GetAttachedView().GetAttachedModel().GetSegmentKey();
	SegmentKey subsegmentKey = modelKey.Subsegment("sub");
	subsegmentKey.GetVisibilityControl().SetEverything(true);
	View view = _canvas.GetAttachedLayout().GetAttachedView();

	//Set a point in window space, for example, right in the center
	WindowPoint wp0(0, 0);

	SelectionOptionsKit selectionOptions;
	SelectionResults selectionResults;
	size_t numberOfSelectedItems;
	selectionOptions.SetLevel(Selection::Level::Entity).SetRelatedLimit(0).SetSorting(Selection::Sorting::ZSorting);
	numberOfSelectedItems = _canvas.GetWindowKey().GetSelectionControl().SelectByPoint(wp0, selectionOptions, selectionResults);

	SelectionResultsIterator it = selectionResults.GetIterator();
	WorldPoint selectionPosition;

	while (it.IsValid())
	{
		KeyPath selectionPath;
		SelectionItem selection = it.GetItem();

		//Get the position of the selection
		selection.ShowSelectionPosition(selectionPosition);

		it.Next();
	}

	//Insert marker in World space
	subsegmentKey.InsertMarker(selectionPosition);

	_canvas.UpdateWithNotifier().Wait();
}

```

A short video (with audio narration) demonstrating the code is also available:

[![](https://us1.discourse-cdn.com/flex020/uploads/techsoft3d/original/1X/9a862b377141500b36c178da35945ea4a2ca2c02.jpeg "How to: Find a point on the surface of a model given a known window point") ](https://www.youtube.com/watch?v=1uY2du8Szrc)
