# Sample Code: Extract cutting plane geometry

**URL:** <https://forum.techsoft3d.com/t/sample-code-extract-cutting-plane-geometry/1408>\
**Category:** HOOPS Visualize Desktop\
**Tags:** code, sample, learn, knowledge-base, how-to\
**Created:** [November 2, 2022, 4:00am UTC](https://forum.techsoft3d.com/t/sample-code-extract-cutting-plane-geometry/1408 "2022-11-02T04: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:** [November 2, 2022, 4:00am UTC](https://forum.techsoft3d.com/t/sample-code-extract-cutting-plane-geometry/1408/1 "2022-11-02T04:00:00Z")

</div>

**Language: C++**

Sample code of extracting cutting plane geometry for mfc\_sandbox.  
[![](https://us1.discourse-cdn.com/flex020/uploads/techsoft3d/original/1X/4409f4c7ca9c566d033f2b4cca20f18e9a46498e.png)Cutting Sections — HOOPS Visualize HPS Documentation 2022.0.0 documentation](https://docs.techsoft3d.com/hps/latest/prog_guide/0212_cutting_sections.html?highlight=cutting%20sections#extracting-cutting-plane-geometry)

## 📘 Instructions

1. Open \samples\data\turbine.hsf
2. Run the user code below

```auto
void CHPSView::OnUserCode()
{
	HPS::SegmentKey mySegmentKey = GetCanvas().GetFrontView().GetSegmentKey();

	// enable visibility of cut geometry
	mySegmentKey.GetVisibilityControl().SetCutGeometry(true);

	// set the cutting depth for cutting section
	mySegmentKey.GetCuttingSectionAttributeControl()
		.SetCappingLevel(HPS::CuttingSection::CappingLevel::Segment)
		.SetCuttingLevel(HPS::CuttingSection::CuttingLevel::Global);

	// insert cutting section
	HPS::CuttingSectionKey cutterKey = mySegmentKey.InsertCuttingSection(HPS::Plane(HPS::Vector(1, 0, 0)));

	// Call update
	GetCanvas().GetFrontView().UpdateWithNotifier().Wait();

	// set gather depth
	HPS::CutGeometryGatheringOptionsKit opt;
	opt.SetLevel(CuttingSection::GatheringLevel::Segment);

	// build path
	HPS::SprocketPath sprocket_path(GetCanvas(), GetCanvas().GetAttachedLayout(), GetCanvas().GetFrontView(), GetCanvas().GetFrontView().GetAttachedModel());

	// put cut geometry into subsegment called "caps"
	sprocket_path.GetKeyPath().GatherCutGeometry(mySegmentKey.Subsegment("caps"), opt);

	// delete model to leave just the caps in place (optional)
	GetCanvas().GetFrontView().GetAttachedModel().Delete();

	GetCanvas().Update();
}

```

1. 

 ![image-20221117-025412](https://us1.discourse-cdn.com/flex020/uploads/techsoft3d/original/1X/2f22deeb3ff22a5418284c6f5b1663a8a05cbcd1.png)

**You need an update before gathering the cut geometry to get geometries.**
