public void GetParts(IComponent2 Comp) { try { if (Settings.Run) { bool Include = true; Object Children; //TreferencedDoc ActDoc = new TreferencedDoc(); if (!Comp.IsSuppressed())//Wenn Zeichnung nicht unterdrückt { Part part = new Part(); modeldoc = (ModelDoc2)Comp.GetModelDoc2(); if (modeldoc != null) { string FileName = Path.GetFileNameWithoutExtension(modeldoc.GetPathName()); part.Name = FileName.Substring(FileName.LastIndexOf("/") + 1); foreach (Part partfromList in Parts) { if (SWX.Settings.NotInBil && Comp.ExcludeFromBOM) { Include = false; break; } if (Settings.OnlyAssembly && modeldoc.GetType() != (int)swDocumentTypes_e.swDocASSEMBLY) { Include = false; break; } if (partfromList.Name == part.Name) { partfromList.Cnt++; Include = false; break; } } if (Include) { part.PathName = modeldoc.GetPathName(); part.RefConfig = Comp.ReferencedConfiguration; part.Released = modeldoc.GetCustomInfoValue("", "Status"); part.Beschreibung = modeldoc.GetCustomInfoValue("", "Description"); part.IsFastener = modeldoc.GetCustomInfoValue("", "isfastener"); if (modeldoc.GetCustomInfoValue("", "Medienberührend").ToUpper() == "JA") { part.Zertifikat = true; } part.Revision = modeldoc.GetCustomInfoValue(part.RefConfig, "Revision"); modelDocExtension = modeldoc.Extension; //int ret = modelDocExtension.ToolboxPartType; //if (ret != 0) //{ // part.IsToolBoxPart = true; //} } } else { part.PathName = modeldoc.GetPathName(); string TempName = Path.GetFileNameWithoutExtension(Comp.GetPathName()); part.Name = TempName.Substring(TempName.LastIndexOf("/") + 1); //KKS.KKS_Message.Show(ActDoc.Name); part.RefConfig = ""; part.Released = modeldoc.GetCustomInfoValue("", "Status"); part.Revision = modeldoc.GetCustomInfoValue(part.RefConfig, "Revision"); } if (Include) { Parts.Add(part); } } Children = Comp.GetChildren(); foreach (Object com in (Object[])Children) { Child = (IComponent2)com; GetParts(Child); } } } catch (Exception ex) { if (KKS.KKS_Message.Show("Folgender Fehler ist aufgetreten. Um den Vorgang weiter zu führen Klicke auf OK. /n" + ex.Message, "Fehler", true, "OK", "Abbrechen") == System.Windows.Forms.DialogResult.Cancel) { Settings.Run = false; } } }
//public Stopwatch t = new Stopwatch(); public int GetParts(IComponent2 Comp) { try { bool Include = true; Object Children; if (!Comp.IsSuppressed())//Wenn Zeichnung nicht unterdrückt { Part part = new Part(); modeldoc = (ModelDoc2)Comp.GetModelDoc2(); if (modeldoc != null) { //string FileName = Path.GetFileNameWithoutExtension(modeldoc.GetPathName()); part.Name = modeldoc.GetCustomInfoValue("", "DokID"); //t.Stop(); //Settings.LogAdd(t.Elapsed.Milliseconds.ToString(), Cnt.ToString(), part.Name); //t.Reset(); //t.Start(); foreach (Part partfromList in Parts) { if (SWX.Settings.NotInBil && Comp.ExcludeFromBOM) { Include = false; break; } if (partfromList.Name == part.Name) { partfromList.Cnt++; Include = false; break; } } if (Include) { if (modeldoc.GetCustomInfoValue("", "Medienberührend").ToUpper() == "JA") { part.Zertifikat = true; } part.ArtNr = modeldoc.GetCustomInfoValue("", "Artikelnummer"); part.Beschreibung = modeldoc.GetCustomInfoValue("", "Description"); Parts.Add(part); } } if (Include) { } } Children = Comp.GetChildren(); Cnt++; foreach (Object com in (Object[])Children) { Child = (IComponent2)com; GetParts(Child); } } catch (Exception ex) { if (KKS.KKS_Message.Show("Folgender Fehler ist aufgetreten. Um den Vorgang weiter zu führen Klicke auf OK. /n" + ex.Message, "Fehler", true, "OK", "Abbrechen") == System.Windows.Forms.DialogResult.Cancel) { } } return(Cnt); }