How to report the feature name from more than one body in a part using NXOpen?
SolutionThis video will demonstrate how to use the body collection and feature collection in NXOpen to report the feature name of multiple bodies.
This should be a guide for reporting other information from bodies and features, please see the documentation for the body class and feature class for what types of information can be reported using these types of objects.
Body Class:
https://docs.sw.siemens.com/documentation/external/PL20220512394070742/en-US/nx_api/nx/2212/nx_api/en-US/nxopen_net/a35545.html
Feature class:
https://docs.sw.siemens.com/documentation/external/PL20220512394070742/en-US/nx_api/nx/2212/nx_api/en-US/nxopen_net/a51237.html
Code:
// report feature name for a single body:
Part workPart = theSession.Parts.Work;
Body[] body = workPart.Bodies.ToArray();
theSession.ListingWindow.Open();
theSession.ListingWindow.WriteFullline("The body tag is: " + body[0].Tag.ToString());
Feature[] feature = body[0].GetFeatures();
theSession.ListingWindow.WriteFullline("The Feature name is: " + feature[0].Name);
// report the feature name for one or more bodies:
foreach (Body body1 in workPart.Bodies)
{
theSession.ListingWindow.WriteFullline("The body tag is: " + body1.Tag.ToString());
foreach (Feature feat1 in body1.GetFeatures())
{
theSession.ListingWindow.WriteFullline(" The Feature Name is: " + feat1.Name );
}
}