部件一旦装配之后,UG会对部件进行封装,并生成新的tag,那我们如何去查找装配后的部件呢?
这里提供2种思路:
1、通过ufun函数获取;
2、通过NXOPEN遍历部件;
上代码:
/// <summary>
/// 通过ufun获取组件里的部件信息
/// </summary>
public static void GetBodyListFromComponet(ref List<Component> compList, ref List<Body> bodyList)
{
theSession = Session.GetSession();
theUFSession = UFSession.GetUFSession();
workPart = theSession.Parts.Work;
compList = new List<Component>();
bodyList = new List<Body>();
ComponentTool.GetComponentList(workPart, compList);
ComponentAssembly compAssembly = workPart.ComponentAssembly;
Component rootComponent = compAssembly.RootComponent;
foreach (Component c in compList)
{
SetWorkPart(c);