chr
2024-11-02 b5234c5ab1e9e6826b8d8fc1e95fa752aaa40b74
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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"];
 
            if (Regex.IsMatch(childName, jgjNameRegx))
            {
                if (bom._drawInfo != null)
                {
                    bom._drawInfo.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 = "标准件";
            //    }
            //}
        }
 
        /// <summary>
        /// 判断一个零件体是否需要使用加工件的属性Panel
        /// </summary>
        /// <param name="doc"></param>
        /// <returns></returns>
        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);
        }
    }
}