本文是帮助里面的一个例子,
首先打开一个三维模型和对应的工程图,保持三维模型为当前激活窗口,在三维模型里面选中一个面或者一个边,然后运行下面的代码,
会将工程图里面的第一视图里面对应的投影元素的线型的宽度改成4
main( ) { SldWorks App = new SldWorks(); App.Visible = true; ModelDoc2 swModel = App.ActiveDoc; SelectionMgr swSelMgr = swModel.SelectionManager; object swEnt = swSelMgr.GetSelectedObject5(1) as Face2; int lErrorActivatingDoc = 0; string path = @"C:UsersAdministratorDesktop零件2.SLDDRW"; DrawingDoc swDrawing = App.ActivateDoc2(path, false, ref lErrorActivatingDoc) as DrawingDoc; SolidWorks.Interop.sldworks.View firstView = swDrawing.GetFirstView(); firstView = firstView.GetNextView(); Face2 face = swEnt as Face2; var edges = face.GetEdges(); foreach (Edge ee in edges) { bool bRet = firstView.SelectEntity(ee, false); swDrawing.SetLineWidth(4); } }