|
@@ -1,153 +0,0 @@
|
|
|
-/* ==============================================================================
|
|
|
- * 功能描述:复制本地名称或本地编码的值
|
|
|
- * 创 建 者:Garrett
|
|
|
- * 创建日期:2018/7/12 14:25:17
|
|
|
- * ==============================================================================*/
|
|
|
-using System;
|
|
|
-using System.Collections.Generic;
|
|
|
-using System.Linq;
|
|
|
-using System.Text;
|
|
|
-using System.Threading.Tasks;
|
|
|
-using SAGA.DotNetUtils.Others;
|
|
|
-using SAGA.MBI.Calc;
|
|
|
-using SAGA.MBI.Model;
|
|
|
-using SAGA.MBI.RequestData;
|
|
|
-using SAGA.MBI.WinView.Upload;
|
|
|
-using Autodesk.Revit.DB;
|
|
|
-using Autodesk.Revit.DB.Mechanical;
|
|
|
-using SAGA.DotNetUtils;
|
|
|
-using SAGA.DotNetUtils.Logger;
|
|
|
-using SAGA.MBI.Common;
|
|
|
-using SAGA.MBI.DataArrange;
|
|
|
-using SAGA.MBI.Tools;
|
|
|
-using SAGA.RevitUtils.Extends;
|
|
|
-
|
|
|
-namespace SAGA.MBI.ToolsData
|
|
|
-{
|
|
|
- /// <summary>
|
|
|
- /// CheckEquipCategory
|
|
|
- /// </summary>
|
|
|
- public class CopyLocalNameValue
|
|
|
- {
|
|
|
- /// <summary>
|
|
|
- /// 检查并处理所有楼层
|
|
|
- /// </summary>
|
|
|
- public static int OperateAll()
|
|
|
- {
|
|
|
- int count = 0;
|
|
|
- var floors = DalUploadFloor.GetHasFileFloors();
|
|
|
- foreach (UploadFloor floor in floors)
|
|
|
- {
|
|
|
- count += Operate(floor.MFloor);
|
|
|
- }
|
|
|
- return count;
|
|
|
- }
|
|
|
- /// <summary>
|
|
|
- /// 只处理当前楼层
|
|
|
- /// </summary>
|
|
|
- public static int OperateCurFloor()
|
|
|
- {
|
|
|
- int count = 0;
|
|
|
- MFloor floor = ExternalDataWrapper.Current.Doc.GetCurMFloor();
|
|
|
- if (floor != null)
|
|
|
- count = Operate(floor);
|
|
|
- return count;
|
|
|
- }
|
|
|
- /// <summary>
|
|
|
- /// 检查并处理
|
|
|
- /// </summary>
|
|
|
- /// <param name="floor"></param>
|
|
|
- /// <returns>失败的个数</returns>
|
|
|
- private static int Operate(MFloor floor)
|
|
|
- {
|
|
|
- List<string> errorids = new List<string>();
|
|
|
- var context = new CalcContext(floor);
|
|
|
- try
|
|
|
- {
|
|
|
- context.OpenDocument();
|
|
|
- var doc = context.RevitDoc;
|
|
|
- using (Transaction trans = new Transaction(doc, "复制本地名称,本地编码的值"))
|
|
|
- {
|
|
|
- trans.Start();
|
|
|
- try
|
|
|
- {
|
|
|
- var fis = doc.GetMbiElements();
|
|
|
- foreach (var fi in fis)
|
|
|
- {
|
|
|
- if (fi.IsEquipment() || fi.IsEquipmentPart())
|
|
|
- if (!CopyProperty(fi))
|
|
|
- errorids.Add(fi.Id.ToString());
|
|
|
- }
|
|
|
- trans.Commit();
|
|
|
- }
|
|
|
- catch (Exception)
|
|
|
- {
|
|
|
- trans.RollBack();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- catch (Exception e)
|
|
|
- {
|
|
|
- MessageShowBase.Show(e);
|
|
|
- }
|
|
|
- finally
|
|
|
- {
|
|
|
- context.RevitDoc.CloseDoc();
|
|
|
- }
|
|
|
- //if (errorids.Count > 0)
|
|
|
- // MessageShowBase.Infomation($"楼层 {floor} 下列对象的参数复制失败,请检查!\r\n" + string.Join(",", errorids));
|
|
|
- return errorids.Count;
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 复制值:
|
|
|
- /// 从设备本地名称到设备本地名称2
|
|
|
- /// 从设备本地编码到设备本地编码2
|
|
|
- /// 从设备编号到设备本地编码
|
|
|
- /// </summary>
|
|
|
- /// <param name="fi"></param>
|
|
|
- /// <returns>True成功,False失败</returns>
|
|
|
- private static bool CopyProperty(Element fi, bool isBackupValue = false)
|
|
|
- {
|
|
|
- bool result = false;
|
|
|
- try
|
|
|
- {
|
|
|
- Parameter localIdParameter = fi.GetParameter(RevitBuiltInParameter.EquipLocalID);
|
|
|
- Parameter numParameter = fi.GetParameter("设备编号");
|
|
|
- if (localIdParameter != null)
|
|
|
- {
|
|
|
- if (isBackupValue)
|
|
|
- {
|
|
|
- Parameter localNameParameter = fi.GetParameter(RevitBuiltInParameter.EquipLocalName);
|
|
|
- Parameter localNameParameter2 = fi.GetParameter("设备本地名称2");
|
|
|
- Parameter localIdParameter2 = fi.GetParameter("设备本地编码2");
|
|
|
- if (localNameParameter != null)
|
|
|
- {
|
|
|
- if (localIdParameter2 != null && localNameParameter2 != null)
|
|
|
- {
|
|
|
- localIdParameter2.SetValueString(localIdParameter.GetParameterString());
|
|
|
- localNameParameter2.SetValueString(localNameParameter.GetParameterString());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (numParameter != null)
|
|
|
- {
|
|
|
- string originValue = localIdParameter.GetParameterString();
|
|
|
- string numvalue = numParameter.GetParameterString();
|
|
|
- if (originValue.IsNullOrEmpty()&& numvalue.IsNotNullEmpty())
|
|
|
- result = localIdParameter.Set(numvalue);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- catch (Exception e)
|
|
|
- {
|
|
|
- Console.WriteLine(e);
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- return result;
|
|
|
- }
|
|
|
- }
|
|
|
-}
|