Ejemplo n.º 1
0
    static void setANTOrderAndSaveAllLevels(BasePart thePart)
    {
        NXOpen.Assemblies.Component root = thePart.ComponentAssembly.RootComponent;
        if (root == null)
        {
            return;
        }

        PartLoadStatus loadStatus;

        theSession.Parts.SetDisplay(thePart, false, true, out loadStatus);
        reportPartLoadStatus(loadStatus);

        NXOpen.Assemblies.ComponentOrder componentOrder1 =
            (NXOpen.Assemblies.ComponentOrder)
            thePart.ComponentAssembly.OrdersSet.FindObject("Alphabetic");
        componentOrder1.Activate();

        thePart.Save(BasePart.SaveComponents.False, BasePart.CloseAfterSave.False);

        foreach (NXOpen.Assemblies.Component kid in root.GetChildren())
        {
            setANTOrderAndSaveAllLevels((BasePart)kid.Prototype);
        }
    }
Ejemplo n.º 2
0
 /// <summary>
 /// 取得子Comp集合(遞迴搜尋)
 /// </summary>
 /// <param name="FatherComp"></param>
 /// <param name="ListChildrenComp"></param>
 /// <returns></returns>
 public static bool GetCompChildren(NXOpen.Assemblies.Component FatherComp, ref List <NXOpen.Assemblies.Component> ListChildrenComp)
 {
     try
     {
         NXOpen.Assemblies.Component[] ChildrenCompAry = FatherComp.GetChildren();
         ListChildrenComp.AddRange(ChildrenCompAry.ToArray());
         foreach (NXOpen.Assemblies.Component i in ChildrenCompAry)
         {
             GetCompChildren(i, ref ListChildrenComp);
         }
     }
     catch (System.Exception ex)
     {
         return(false);
     }
     return(true);
 }