using PdmSwPlugin.Common.Entity.Pdm; using PdmSwPlugin.Common.Setting; using PdmSwPlugin.Common.Util; using SolidWorks.Interop.sldworks; using System.IO; using System.Text.RegularExpressions; namespace PdmSwPlugin.Common { public class YwtBomIniter : BomIniter { public static PluginSetting setting = PluginSetting.Instance; public string jgjNameRegx { get; private set; } = CustomerSetting.Instance["jgjNameRegx"]; public string standardNameRegx { get; private set; } = CustomerSetting.Instance["standardNameRegx"]; public void InitBom(PdmBom bom) { string childPath = bom.component.GetPathName(); string childName = Path.GetFileNameWithoutExtension(childPath); bom.BomInfo.name = childName; bom.BomInfo.partNo = childName; bom.BomInfo.partName = childName; bom.BomInfo.partModel = childName; bom.BomInfo.filePath = childPath; bom.xc = false; bom.mn = false; if (Regex.IsMatch(childName, jgjNameRegx)) { bom.historyData = NameUtil.IsHistoryDoc(childName); string docType = bom.properties.Get("文件格式"); if (string.IsNullOrEmpty(docType)) { bom.produceWay = "标准件"; } else { bom.produceWay = docType; } } else { bom.produceWay = "标准件"; } //if (bom.drawingType == (int)swDocumentTypes_e.swDocASSEMBLY) //{ // bom.produceWay = "装配体"; //} //else if (bom.drawingType == (int)swDocumentTypes_e.swDocPART) //{ // if (Regex.IsMatch(childName, jgjNameRegx)) // { // bom.produceWay = "加工件"; // } // else // { // bom.produceWay = "标准件"; // } //} } /// /// 判断一个零件体是否需要使用加工件的属性Panel /// /// /// public bool IsJgjPanel(ModelDoc2 doc) { string fileName = Path.GetFileNameWithoutExtension(doc.GetPathName()); return Regex.IsMatch(fileName, jgjNameRegx); } public bool IsJgj(ModelDoc2 doc) { string fileName = Path.GetFileNameWithoutExtension(doc.GetPathName()); return Regex.IsMatch(fileName, jgjNameRegx); } public bool IsStandard(ModelDoc2 doc) { string fileName = doc.GetPathName(); fileName = Path.GetFileNameWithoutExtension(fileName); return Regex.IsMatch(fileName, standardNameRegx); } } }