1. 程式人生 > >SolidWorks二次開發——獲取工程圖關聯的零件路徑

SolidWorks二次開發——獲取工程圖關聯的零件路徑

獲取當前工程圖關聯的零件路徑:
c#

IModelDoc2 swModel;

IDrawingDoc swDraw;

swModel = swApp.ActiveDoc;

swDraw = (IDrawingDoc)swModel;

SolidWorks.Interop.sldworks.IView swView;  

string strPartPath="";

//根據工程圖配置得到其零件的路徑

swView = swDraw.GetFirstView();

while (swView == null||swView.GetReferencedModelName()==""
) { swView = swView.GetNextView(); } strPartPath = swView.GetReferencedModelName();