/// <summary> /// 根据模板创建文档 /// </summary> /// <param name="sldWorks"><see cref="ISldWorks"/></param> /// <param name="templatePath">模板路径 支持的文件类型为<para>.prtdot</para><para>.asmdot</para><para>.drwdot</para></param> /// <param name="hidden">是否对用户可见 默认为不可见</param> /// <returns><see cref="ModelDoc2"/></returns> public static ModelDoc2 CreateDocument (this ISldWorks sldWorks, string templatePath, bool hidden = true) { if (!File.Exists(templatePath)) { throw new FileNotFoundException(string.Format("未找到此种类型的模板文件")); } var type = SWPath.GetTemFileType(templatePath); try { if (hidden) { sldWorks.DocumentVisible(false, (int)type); } //TODO:设置替换字符串 var doc = (ModelDoc2)sldWorks.NewDocument(templatePath, (int)swDwgPaperSizes_e.swDwgPaperA4size, 1, 1); return(doc); } finally { if (hidden) { sldWorks.DocumentVisible (true, (int) type); } } }
/// <summary> /// /// </summary> /// <param name="filePath"></param> /// <returns></returns> public static bool IsPartOrAssembly(string filePath) { var type = SWPath.GetFileType(filePath); return((type == swDocumentTypes_e.swDocPART || type == swDocumentTypes_e.swDocASSEMBLY) ? true : false); }