From 31a636e735a0addc56e4f4527f500b7aa0874eb5 Mon Sep 17 00:00:00 2001 From: chr <chr@mailcom> Date: 星期五, 03 一月 2025 11:21:46 +0800 Subject: [PATCH] 改了一大堆; --- PdmSwPlugin.Common/Util/Pdm/BomTreeReader.cs | 38 +++++++++++++++++++++++++++++++++----- 1 files changed, 33 insertions(+), 5 deletions(-) diff --git a/PdmSwPlugin.Common/Util/Pdm/BomTreeReader.cs b/PdmSwPlugin.Common/Util/Pdm/BomTreeReader.cs index f8bba5f..d0d5981 100644 --- a/PdmSwPlugin.Common/Util/Pdm/BomTreeReader.cs +++ b/PdmSwPlugin.Common/Util/Pdm/BomTreeReader.cs @@ -41,6 +41,8 @@ private int bomOrder = 0; + public ConcurrentQueue<string> needSaveList { get; set; } = new ConcurrentQueue<string>(); + /// <summary> /// 澶氱嚎绋嬩粠鎵撳紑鐨勬牴鏂囨。涓鍙朆OM淇℃伅 /// </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)) { -- Gitblit v1.9.1