/// <summary> /// 生成零件号 /// </summary> private void CreatePartNumber() { ModelDoc2 swModel = (ModelDoc2)AllData.iSwApp.ActiveDoc; if (swModel == null) { return; } DrawingDoc swDraw = (DrawingDoc)swModel; if (swDraw == null) { return; } //序号为零件属性,还是项目号, 还是文字 int iTextContent = -1; string strText = ""; if (this.rdoTemp1.Checked) { iTextContent = (int)swBalloonTextContent_e.swBalloonTextItemNumber; strText = ""; } else if (this.rdoTemp2.Checked) { iTextContent = (int)swBalloonTextContent_e.swBalloonTextCustomProperties; strText = Interop.Office.Core.Properties.Settings.Default.CreateNbr_PPtName; //"序号"; } else if (this.rdoTemp3.Checked) { iTextContent = (int)swBalloonTextContent_e.swBalloonTextCustom; strText = "0"; } else if (this.rdoTemp4.Checked) { iTextContent = (int)swBalloonTextContent_e.swBalloonTextQuantity; strText = "0"; } //以正方形分布 int iLayout = (int)swBalloonLayoutType_e.swDetailingBalloonLayout_Square; //下划线 int iStyle = (int)swBalloonStyle_e.swBS_Underline; //下划线长度 int iSize = (int)swBalloonFit_e.swBF_Tightest; //如果用户没有选中一个视图,就选中所有的视图 SolidWorks.Interop.sldworks.View swView = (SolidWorks.Interop.sldworks.View)swDraw.ActiveDrawingView; if (swView == null)//对所有的视图进行重排序 { swModel.ClearSelection2(true); swView = (SolidWorks.Interop.sldworks.View)swDraw.GetFirstView(); while (swView != null) { swModel.Extension.SelectByID2(swView.Name, "DRAWINGVIEW", 0, 0, 0, true, 0, null, 0); swView = (SolidWorks.Interop.sldworks.View)swView.GetNextView(); } } //自动添加序号 swDraw.AutoBalloon3(iLayout, true, iStyle, iSize, iTextContent, strText, iTextContent, strText, ""); //Notes = Part.AutoBalloon3(1, True, 10, 2, 1, "", 2, "", "-无-") //swDraw.AutoBalloon3(iLayout, true, iStyle, -1, iTextContent, "xh", iTextContent, "xh", ""); //swDraw.AutoBalloon3(1, true, 10, 2, 1, "", 2, "", "-无-"); //.AutoBalloon3(1, True, 10, 2, 1, "", 2, "", "-无-") ////SolidWorks2006 //swDraw.AutoBalloon2((int)swBalloonLayoutType_e.swDetailingBalloonLayout_Top, true); }