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 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; string jgjNameRegx = CustomerSetting.Instance["jgjNameRegx"]; string standardNameRegx = CustomerSetting.Instance["standardNameRegx"]; string specialJgjRegx = CustomerSetting.Instance["specialJgjRegx"]; if (Regex.IsMatch(childName, jgjNameRegx)) { if (bom._drawInfo != null) { bom._drawInfo.HistoryData = NameUtil.IsHistoryDoc(childName); bom._drawInfo.isSpecial = Regex.IsMatch(childName, specialJgjRegx); } 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 jgjNameRegx = CustomerSetting.Instance["jgjNameRegx"]; string fileName = Path.GetFileNameWithoutExtension(doc.GetPathName()); return Regex.IsMatch(fileName, jgjNameRegx); } public bool IsJgj(ModelDoc2 doc) { string jgjNameRegx = CustomerSetting.Instance["jgjNameRegx"]; string fileName = Path.GetFileNameWithoutExtension(doc.GetPathName()); return Regex.IsMatch(fileName, jgjNameRegx); } public bool IsStandard(ModelDoc2 doc) { string fileName = doc.GetPathName(); string standardNameRegx = CustomerSetting.Instance["standardNameRegx"]; fileName = Path.GetFileNameWithoutExtension(fileName); return Regex.IsMatch(fileName, standardNameRegx); } } }