///<summary> method <c>GetDrawingDocBOMTable</c> ///从SolidWorks 的Drawing文档获取到其材料明细表,一般一个文档一个,多余不获取 ///</summary> public void GetDrawingDocBOMTable(ModelDoc2 modelDoc, out BomTableAnnotation swBOMTable, out string configName, out string topFileName) { Feature feature = modelDoc.IFirstFeature(); swBOMTable = null; configName = ""; topFileName = ""; BomFeature swBomFeat = null; while (feature != null) { Type type = feature.GetType(); if ("BomFeat" == feature.GetTypeName()) { //Console.WriteLine("******************************"); //Console.WriteLine("Feature Name : " + feature.Name); swBomFeat = (BomFeature)feature.GetSpecificFeature2(); break; } string name = feature.Name; feature = feature.IGetNextFeature(); } if (swBomFeat == null || swBomFeat.GetTableAnnotationCount() <= 0) { return; } Feature swFeat = (Feature)swBomFeat.GetFeature(); string featureName = swFeat.Name; swBOMTable = swBomFeat.IGetTableAnnotations(1);// default(TableAnnotation); topFileName = swBomFeat.GetReferencedModelName(); int configCount = swBomFeat.GetConfigurationCount(true); // //object[] vTableArr = (object[])swBomFeat.GetTableAnnotations(); //foreach (object vTable_loopVariable in vTableArr) //{ // object vTable = vTable_loopVariable; // TableAnnotation swTable = (TableAnnotation)vTable; // ProcessTableAnn(modelDoc, swTable); //} configName = ""; if (configCount > 0) { bool visibility = true; configName = swBomFeat.IGetConfigurations(true, 0, ref visibility); } //swBOMTable.Iget return; }
private void fill_table(BomFeature bom) { found_bom = bom; string itno = string.Empty; string ptno = string.Empty; _cols.Clear(); _prts.Clear(); swTable = (ITableAnnotation)bom.IGetTableAnnotations(1); part.ClearSelection2(true); _col_count = swTable.ColumnCount; find_part_column(); _row_count = swTable.RowCount; for (int i = 0; i < _col_count; i++) { _cols.Add(swTable.get_DisplayedText(0, i)); } object[] bomtaa = (object[])bom.GetTableAnnotations(); BomTableAnnotation bta = (BomTableAnnotation)bomtaa[0]; int prtcol = get_column_by_name(_part_column); for (int i = 0; i < _row_count; i++) { string prt_ = swTable.get_DisplayedText(i, prtcol); _prts.Add(prt_); string[] pathnames = (string[])bta.GetModelPathNames(i, out itno, out ptno); if (pathnames != null) { foreach (string pathname in pathnames) { FileInfo fi_ = new FileInfo(pathname); path_list.Add(fi_); if (!path_dict.ContainsKey(prt_.ToUpper())) { path_dict.Add(prt_.ToUpper(), fi_); } } } } initialated = true; }
private void fill_table(BomFeature bom) { _cols.Clear(); _prts.Clear(); swTable = (ITableAnnotation)bom.IGetTableAnnotations(1); part.ClearSelection2(true); _col_count = swTable.ColumnCount; _row_count = swTable.RowCount; for (int i = 0; i < _col_count; i++) { _cols.Add(swTable.get_DisplayedText(0, i)); } int prtcol = get_column_by_name(_part_column); for (int i = 0; i < _row_count; i++) { _prts.Add(swTable.get_DisplayedText(i, prtcol)); } initialated = true; }
///<summary> method <c>GetDrawingDocBOMTable</c> ///从SolidWorks 的Drawing文档获取到其材料明细表,一般一个文档一个,多余不获取 ///</summary> public void GetDrawingDocBOMTable(ModelDoc2 modelDoc, out BomTableAnnotation swBOMTable, out string configName, out string topFileName) { Feature feature = modelDoc.IFirstFeature(); swBOMTable = null; configName = ""; BomFeature swBomFeat = null; while (feature != null) { Type type = feature.GetType(); if ("BomFeat" == feature.GetTypeName()) { Console.WriteLine("******************************"); Console.WriteLine("Feature Name : " + feature.Name); swBomFeat = (BomFeature)feature.GetSpecificFeature2(); break; } string name = feature.Name; feature = feature.IGetNextFeature(); } if (swBomFeat == null || swBomFeat.GetTableAnnotationCount() <= 0) { return; } swBOMTable = swBomFeat.IGetTableAnnotations(1);// default(TableAnnotation); topFileName = swBomFeat.GetReferencedModelName(); configName = ""; if (configCount > 0) { bool visibility = true; configName = swBomFeat.IGetConfigurations(true, 0, ref visibility); } //swBOMTable.Iget return; }