【问题标题】:How to check if a body is a sphere如何检查物体是否为球体
【发布时间】:2021-12-31 15:08:03
【问题描述】:

我想在BodyCollection 中检查我正在使用的主体的主体类型(如果主体是Sphere)。

我该怎么写?

这是我尝试过的:

public void ChamferAll()
{
    int subtype = 1;
    string offset1 = "5", offset2 = "0", angle = "5";
    BodyCollection bodyCollection = theSession.Parts.Work.Bodies;
    List<Tag> edgeTags = new List<Tag>();
    foreach (Body body in bodyCollection)
    {
        
        if (body.GetType() == NXOpen.Features.Sphere)
            continue;
        else
        {
            Edge[] edges = body.GetEdges();
            foreach (Edge edge in edges)
            {
                edgeTags.Add(edge.Tag);
                theUFSession.Modl.CreateChamfer(subtype, offset1, offset2, angle, edgeTags.ToArray(), out Tag chamferTag);
            }

            edgeTags.Clear();
        }
        
    }
}

【问题讨论】:

    标签: c# siemens nxopen


    【解决方案1】:

    body.GetType() 返回实体的类型,例如,片材或实体。 “球体”不是体型。

    您可以改为使用body.GetFeatures() 来获取与该主体关联的功能列表。然后选择第一个返回的特征,并尝试将其转换为NXOpen.Features.Sphere。如果这行得通,那么你所拥有的身体就是一个球体。如果投射不起作用,则说明您拥有的不是球体。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-12-02
      • 1970-01-01
      • 1970-01-01
      • 2012-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多