public static int Main(string[] args)
{
int retValue = 0;
try
{
theProgram = new Program();
//TODO: Add your application code here
Session theSession = Session.GetSession();
Part worPart = theSession.Parts.Work;
Part displyPart = theSession.Parts.Display;
NXOpen.Features.ConeBuilder ConeBuilder1 = worPart.Features.CreateConeBuilder(null);//创建圆台
ConeBuilder1.BaseDiameter.RightHandSide = "50";
ConeBuilder1.TopDiameter.RightHandSide = "30";
ConeBuilder1.Height.RightHandSide = "50";
NXOpen.Features.Feature feature = ConeBuilder1.CommitFeature();//特征类来接收
ConeBuilder1.Destroy();
NXOpen.Features.BodyFeature bodyFeature = (NXOpen.Features.BodyFeature)feature;//将特征转换为BODY特征
NXOpen.Edge[] edges = bodyFeature.GetEdges();
double radius = 0;
NXOpen.Edge edge = null;
foreach (NXOpen.Edge e in bodyFeature.GetEdges())
{
System.IntPtr evaluator;
theUfSession.Eval.Initialize(e.Tag, out evaluator);//初始化
bool isArc;
theUfSession.Eval.IsArc(evaluator, out isArc);
if (isArc)//判读是不是圆弧
{
NXOpen.UF.UFEval.Arc arc;
theUfSession.Eval.AskArc(evaluator, out arc);
if (arc.radius > radius)
{
edge = e;
radius = arc.radius;
}
}
theUfSession.Eval.Free(evaluator);//释放资源
}
if (edge != null)
{
ScCollector scCollector1 = worPart.ScCollectors.CreateCollector();//创建特征收集器
SelectionIntentRule[] rules1 = new SelectionIntentRule[1];//创建体的边的规则父类对象
rules1[0] = worPart.ScRuleFactory.CreateRuleEdgeDumb(new NXOpen.Edge[] { edge });//将体的边规则放到父类对象数组中
scCollector1.ReplaceRules(rules1, false);//规则收集器
NXOpen.Features.EdgeBlendBuilder edgeBlendBuilder1 = worPart.Features.CreateEdgeBlendBuilder(null);
int csIndex1 = edgeBlendBuilder1.AddChainset(scCollector1, "10");//创建体的边倒圆
NXOpen.Features.Feature feature1 = edgeBlendBuilder1.CommitFeature();//委托
edgeBlendBuilder1.Destroy();
}