我想检查一下我在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();
}
}
}发布于 2022-02-04 02:53:22
body.GetType()返回主体的类型,例如,薄板或实体。"Sphere“不是一种身体类型。
相反,您可以使用body.GetFeatures()获取与该主体关联的特性列表。然后选择第一个返回的特性,并尝试将其转换为NXOpen.Features.Sphere。如果那可行的话,你的身体就是一个球体。如果石膏不起作用,你就有了球体以外的东西。
https://stackoverflow.com/questions/70543505
复制相似问题