UG 二次开发(C#)提取字体中心线

static Body FindBodyByFeatureName(Part part, string featureName)       //遍历所有特征,通过名字获取BODY
{
    // 获取部件中的所有特征
   NXOpen.Features.Feature[] features = part.Features.ToArray();

    foreach (NXOpen.Features.Feature feature in features)
    {
        // 检查特征的名称
        if (feature.GetFeatureName() == featureName)
        {
            // 从特征中获取与之相关的主体
            // 注意:并非所有特征都有主体,您可能需要根据特征类型进行判断
            if (feature is NXOpen.Features.BodyFeature bodyFeature)
            {
                return bodyFeature.GetBodies()[0]; // 返回第一个相关的主体
            }
        }
    }

    return null; // 如果未找到,返回 null
}

   public static int Main(string[] args)
   {
       int retValue = 0;
       try
       {
           theProgram = new Program();

           //TODO: Add your application code here 

           NXOpen.Session theSession = NXOpen.Session.GetSession();
           NXOpen.Part workPart = theSession.Parts.Work;
           NXOpen.Part displayPart = theSession.Parts.Display;

           string message = "请选择一个或多个面";
           string title = "1面选择";
           TaggedObject[] selectedObjects = null;
           Selection.SelectionScope scope = Selection.SelectionScope.WorkPart;    //先取的范围
           NXOpen.Selection.SelectionAction action = Selection.SelectionAction.ClearAndEnableSpecific;
           bool includeFeatures = false;    //是否允许选择特性
           bool ke

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值