You need first to subscribe to the Design.SelectionChanged
event, then cast selectedItem to SelectedFace
as in the sample code below:
const double deviation = 0.01;
design1.SelectionChanged += (sender, args) = { SelectedItem selItem = args.AddedItems.FirstOrDefault(); if (selItem == null) return; if (selItem.Item is Brep brep && selItem is SelectedFace selFace) { Brep.Face sf = brep.Faces[selFace.Index]; if (sf.Parametric == null) // parametric not available { brep.Rebuild(0, true); } double totalArea = 0; foreach (Surface surface in sf.Parametric) { if (surface.Vertices == null) // parametric tessellation not available { surface.Regen(deviation); } totalArea += surface.GetArea(out _); } MessageBox.Show($"Selected face area is {totalArea:g6} mm²"); } };
Comments
Please sign in to leave a comment.