如何在NXOpen中使用AskAdjacentFacet函数?
我正在使用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,我看到的问题是您尚未初始化变量
myfacet
,而是null
。而且由于它是null
,因此您无法调用其成员。因此,将代码的一行更改
为
On first glimpse, the problem I see is that you have not initialized the variable
myFacet
and it'snull
. And since it'snull
, you cannot call its members.So change a single line of the code from
To