admin 发表于 2018-6-22 13:32:01

NX二次开发源码分享: 如何获取装配导航器上PMI的节点名称


NX二次开发源码分享: 如何获取装配导航器上PMI的节点名称

NX 目前没有想过方法,需要借助 KF 函数



// There is no direct way to get the name that is shown for the PMI object
    // in the Part Navigator.See ER 7961161.
    // This method uses a Check-Mate function then parses the output to format it
    // so that it matches what is shown there in most cases.
    private static string get_pmi_part_navigator_name(NXOpen.Annotations.Pmi thePmi)
    {
      string ruleName;
      theUFSession.Cfi.GetUniqueFilename(out ruleName);
      workPart.RuleManager.CreateDynamicRule("root:", ruleName,
            "Any", "mqc_askPMIObjectsInformation({" + thePmi.Tag + "});", "");
      string theValue = workPart.RuleManager.EvaluateAnyAsString(ruleName + ":");
      workPart.RuleManager.DeleteDynamicRule("root:", ruleName);


      string[] infos = theValue.Split(new Char[]{','});


      string theName = (infos.Trim().Trim(new Char[]{'"'}) +
            "(" + infos.Trim() + ")").Replace("PMI ", "");
      return theName;
    }

页: [1]
查看完整版本: NX二次开发源码分享: 如何获取装配导航器上PMI的节点名称