internal static SwCutListItem[] GetCutLists(this SwFeatureManager featMgr) { var cutLists = new List <SwCutListItem>(); if (featMgr.Document.DocumentType == swDocumentTypes_e.swDocPART) { var part = featMgr.Document.Model as IPartDoc; if (part.IsWeldment() || (part.GetBodies2((int)swBodyType_e.swSolidBody, false) as object[] ?? new object[0]) .Any(b => ((IBody2)b).IsSheetMetal())) { foreach (ISwFeature feat in featMgr) { if (feat is SwCutListItem) { cutLists.Add(feat as SwCutListItem); } else if (feat.Feature.GetTypeName2() == "RefPlane") { break; } } } } return(cutLists.ToArray()); }
internal static IEnumerable <SwCutListItem> IterateCutLists(this SwFeatureManager featMgr, ISwDocument3D parent, ISwConfiguration refConf) { foreach (var feat in FeatureEnumerator.IterateFeatures(featMgr.GetFirstFeature(), false)) { if (feat.GetTypeName2() == "SolidBodyFolder") { foreach (var subFeat in FeatureEnumerator.IterateSubFeatures(feat, true)) { if (subFeat.GetTypeName2() == "CutListFolder") { var cutListFolder = (IBodyFolder)subFeat.GetSpecificFeature2(); if (cutListFolder.GetBodyCount() > 0)//no bodies for hidden cut-lists (not available in the specific configuration) { var cutList = featMgr.Document.CreateObjectFromDispatch <SwCutListItem>(subFeat); cutList.SetParent(parent, refConf); yield return(cutList); } } } break; } else if (feat.GetTypeName2() == "RefPlane") { break; } } yield break; }