using System;
using System.IO;
// SolidWorks 的命名空间们
using SolidWorks.Interop.swconst;
namespace PdmSwPlugin.Common.Util
{
///
/// 得到 SolidWorks 文档的后缀名
///
public static class FileExtentionChecker
{
///
/// 装配体的后缀名
///
public static string AssemblyExtentionInLowerCase = @".sldasm";
///
/// 零件的后缀名
///
public static string PartExtentionInLowerCase = @".sldprt";
///
/// 工程图的后缀名
///
public static string DrawingExtentionInLowerCase = @".slddrw";
///
/// 检查一个 SolidWorks 文件的类型
///
/// SolidWorks 文件
/// 返回原始的后缀名
/// 文件类型,当前仅支持装配体、零件和工程图三种
public static swDocumentTypes_e Check(string sldFullPath, out string originalExt)
{
originalExt = null;
if (string.IsNullOrEmpty(sldFullPath))
return swDocumentTypes_e.swDocNONE;
originalExt = Path.GetExtension(sldFullPath);
if (string.Compare(originalExt, AssemblyExtentionInLowerCase, true) == 0)
return swDocumentTypes_e.swDocASSEMBLY;
else if (string.Compare(originalExt, PartExtentionInLowerCase, true) == 0)
return swDocumentTypes_e.swDocPART;
else if (string.Compare(originalExt, DrawingExtentionInLowerCase, true) == 0)
return swDocumentTypes_e.swDocDRAWING;
else
return swDocumentTypes_e.swDocNONE;
}
}
}