简介:
获得部件导航器中所有特征的名称及类型,并打印在信息窗口。
代码支持操作记录直接运行,代码如下:
using System;
using NXOpen;
using NXOpen.Features;
class Module1
{
public static void Main()
{
Session theSession = Session.GetSession();
if (ReferenceEquals(theSession.Parts.BaseWork, null))
{
return;
}
Part workPart = theSession.Parts.Work;
ListingWindow lw = theSession.ListingWindow;
lw.Open();
foreach (Feature partFeature in workPart.Features)
{
lw.WriteLine("feature name: " + partFeature.GetFeatureName());
lw.WriteLine("feature type: " + partFeature.GetType().ToString());
lw.WriteLine("");
}
lw.Close();
}
public static int GetUnloadOption(string dummy)
{
//Unloads the image immediately after execution within NX
return System.Convert.ToInt32(NXOpen.Session.LibraryUnloadOption.Immediately);
}
}