如何在NXOpen中使用AskAdjacentFacet函数?

发布于 2025-01-20 11:52:07 字数 1859 浏览 4 评论 0原文

我正在使用NX中的收敛刻面机构,并在Nxopen中使用C#。在此过程中,我使用 ufsession.facet.facet.askadjacentfacet 功能以获取每个方面的相邻方面。但是,在使用此特定命令时,nxopen会引发错误说明“ nxopen.nxexception:不支持此操作的facet对象” 。我浏览了nxopen文档中给出的示例( https://docs.plm.automation.siemens.com/data_services/Resources/nx/nx/10/nx_api/en_api/en_us/custom/custom/custom/custom/custom/ugopen_doc/uf_facet/uf_facet/uf_facet/uf_facet_eg2.c2.c )和二手类似的方法,但是此错误以任何方式显示出来。以下是我尝试的脚本。

''

    public static void Main(string[] args)
    {
        NXOpen.UF.UFFacet myFacet = UFSession.Facet;

        int facetID;
        int edgeID;
        int adjFacID;
        int edgeIDinAdjFac;

        int null_facet_ID = UFConstants.UF_FACET_NULL_FACET_ID;
        facetID = null_facet_ID;

        foreach (NXOpen.Facet.FacetedBody facetBody in workPart.FacetedBodies)
        {
            myFacet.CycleFacets(facetBody.Tag, ref facetID);  // initialise for cycling

            while (facetID != null_facet_ID)
            {
                List<int> Adj_fac_list = new List<int>();
                for (edgeID = 0; edgeID < 3; edgeID++)
                {
                    myFacet.AskAdjacentFacet(facetBody.Tag, facetID, edgeID, out adjFacID, out edgeIDinAdjFac);
                    if (adjFacID != UFConstants.UF_FACET_NULL_FACET_ID)
                    {
                        Adj_fac_list.Add(adjFacID);
                    }
                }
            }
        }
    }

注意:我可以在功能 ufsession.facet.facet.asknumvertsinfacet 中使用相同的模型标签和facet ID,并且该脚本正常。但是我不知道为什么Askadjacentfacet不起作用。谁能帮助我解决为什么有错误以及如何使此工作?

I am working with convergent facet bodies in NX and using C# in NXOpen. In the process, I am using UFSession.Facet.AskAdjacentFacet function to get the adjacent facets of each facet. But on using this particular command, the NXOpen throws error stating "NXOpen.NXException: The facet object is not supported for this operation". I went through the example given in NXOpen documentation (https://docs.plm.automation.siemens.com/data_services/resources/nx/10/nx_api/en_US/custom/ugopen_doc/uf_facet/uf_facet_eg2.c) and used similar approach, but this error shows up any way. Below is the script that I tried.

'''

    public static void Main(string[] args)
    {
        NXOpen.UF.UFFacet myFacet = UFSession.Facet;

        int facetID;
        int edgeID;
        int adjFacID;
        int edgeIDinAdjFac;

        int null_facet_ID = UFConstants.UF_FACET_NULL_FACET_ID;
        facetID = null_facet_ID;

        foreach (NXOpen.Facet.FacetedBody facetBody in workPart.FacetedBodies)
        {
            myFacet.CycleFacets(facetBody.Tag, ref facetID);  // initialise for cycling

            while (facetID != null_facet_ID)
            {
                List<int> Adj_fac_list = new List<int>();
                for (edgeID = 0; edgeID < 3; edgeID++)
                {
                    myFacet.AskAdjacentFacet(facetBody.Tag, facetID, edgeID, out adjFacID, out edgeIDinAdjFac);
                    if (adjFacID != UFConstants.UF_FACET_NULL_FACET_ID)
                    {
                        Adj_fac_list.Add(adjFacID);
                    }
                }
            }
        }
    }

Note: I could use the same model tag and facet id in the function UFSession.FACET.AskNumVertsInFacet and the script works fine. But I do not know why AskAdjacentFacet is not working. Can anyone help me on why there is an error and how to get this working?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

作业与我同在 2025-01-27 11:52:08

首先,我看到的问题是您尚未初始化变量myfacet,而是null。而且由于它是null,因此您无法调用其成员。

因此,将代码的一行更改

NXOpen.UF.UFFacet myFacet = UFSession.Facet;

NXOpen.UF.UFFacet myFacet = UFSession.GetUFSession().Facet;

On first glimpse, the problem I see is that you have not initialized the variable myFacet and it's null. And since it's null, you cannot call its members.

So change a single line of the code from

NXOpen.UF.UFFacet myFacet = UFSession.Facet;

To

NXOpen.UF.UFFacet myFacet = UFSession.GetUFSession().Facet;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文