/// <summary> /// 静默模式打开隐藏文件 /// </summary> /// <param name="app"></param> /// <param name="filePath"></param> /// <returns></returns> public static ModelDoc2 OpenInvisibleDocClient(this SldWorks app, string filePath, bool Hidden = true) { int Errors = -1, Warning = -1; var type = app.FileType(filePath); try { if (Hidden) { app.DocumentVisible(false, (int)type); } ModelDoc2 doc = app.OpenDoc6(filePath, type.SWToInt(), swOpenDocOptions_e.swOpenDocOptions_Silent.SWToInt(), "", ref Errors, ref Warning) as ModelDoc2; if (doc == null) { throw new Exception(string.Format("errors:{0},warings{1}", Errors.CastObj <swFileLoadError_e>().ToString(), Warning.CastObj <swFileLoadWarning_e>().ToString())); } return(doc); } catch (Exception) { throw; } finally { app.DocumentVisible(true, (int)type); } }