chr
2025-01-03 31a636e735a0addc56e4f4527f500b7aa0874eb5
PdmSwPlugin.Common/Util/Pdm/BomTreeReader.cs
@@ -41,6 +41,8 @@
        private int bomOrder = 0;
        public ConcurrentQueue<string> needSaveList { get; set; } = new ConcurrentQueue<string>();
        /// <summary>
        /// 多线程从打开的根文档中读取BOM信息
        /// </summary>
@@ -59,10 +61,22 @@
            {
                return;
            }
            CustomPropertyUtil.ClearAllCustomProperties(sldDoc);
            Component2 rootComponent = activeConfiguration.GetRootComponent3(false);
            string path = rootComponent.GetPathName();
            CustomPropertyUtil.ClearAllCustomProperties(sldDoc, out bool needSave);
            if (needSave)
            {
                int err = 0, warn = 0;
                if (sldDoc.Save3((int)swSaveAsOptions_e.swSaveAsOptions_AvoidRebuildOnSave, ref err, ref warn))
                {
                    needSaveList.Enqueue(path);
                }
                else
                {
                    needSaveList.Enqueue($"{path}自动保存失败,异常代码:{err}");
                }
            }
            BomInfo bomInfo = GetBomInfoFromDoc(rootComponent);
            PdmBom bom = ConcatCacheBom(bomInfo, 0, null, rootComponent);
@@ -123,9 +137,22 @@
                {
                    Component2 childComponent = child as Component2;
                    ModelDoc2 childDoc = childComponent.GetModelDoc2();
                    // 清楚格式不对的属性
                    CustomPropertyUtil.ClearAllCustomProperties(childDoc);
                    string childPath = childComponent.GetPathName();
                    // 清除格式不对的属性
                    CustomPropertyUtil.ClearAllCustomProperties(childDoc, out bool needSave);
                    if (needSave)
                    {
                        int err = 0, warn = 0;
                        if (childDoc.Save3((int)swSaveAsOptions_e.swSaveAsOptions_AvoidRebuildOnSave, ref err, ref warn))
                        {
                            needSaveList.Enqueue(childPath);
                        }
                        else
                        {
                            needSaveList.Enqueue($"{childPath}自动保存失败,异常代码:{err}");
                        }
                    }
                    PdmBom bom = null;
                    if (BomInfoCache.ContainsKey(childPath))
                    {
@@ -203,6 +230,7 @@
            CacheList = new ConcurrentQueue<PdmBom>();
            TreeList = new ConcurrentQueue<PdmBom>();
            BomInfoCache = new ConcurrentDictionary<string, BomInfo>();
            needSaveList = new ConcurrentQueue<string>();
            GetBomsFromDocAsync(doc);
            return TreeList.OrderBy(e => e.name).ToList(); ;
        }
@@ -216,7 +244,7 @@
            ModelDoc2 doc = component.GetModelDoc2();
            // 直接用文件名,以免 SolidWorks 因为有多个相同文件而把 Name2 加了 -N 的后缀名
            string childPath = component.GetPathName();
            string childName = Path.GetFileNameWithoutExtension(childPath);
            string childName = System.IO.Path.GetFileNameWithoutExtension(childPath);
            if (ModelUtil.Is_Mn(childName))
            {