Explorar el Código

Merge branch 'master' of https://git.dev.tencent.com/xuhuo1234/saga

xulisong hace 6 años
padre
commit
8a5c7b3d96

+ 14 - 0
MBI/Menu/MBITool.xml

@@ -172,6 +172,19 @@
       <MenuTab>MBITool_W</MenuTab>
       <Modules>MBITool</Modules>
     </Button>
+
+    <Button ButtonStyles="Stacked">
+      <ButtonName>SAGA.MBI.CopyLocalNameCurtainToPanelCommand</ButtonName>
+      <ButtonText>复制幕墙本地名称</ButtonText>
+      <ImageName>1、打开楼层模型</ImageName>
+      <DllName>..\OutputDll\SAGA.MBI.exe</DllName>
+      <ClassName>SAGA.MBI.CopyLocalNameCurtainToPanelCommand</ClassName>
+      <ToolTip>复制幕墙本地名称、本地编码值到幕墙嵌板中</ToolTip>
+      <LongDescription>复制幕墙本地名称</LongDescription>
+      <ToolTipImage></ToolTipImage>
+      <MenuTab>MBITool_W</MenuTab>
+      <Modules>MBITool</Modules>
+    </Button>
   </Panel>
  <Panel PanelName="功能扩展" GroupFlag="True" GroupImage="" RevitVer="R14,R15,R16,R17"  ButtonStyles="Large">   
     <Button ButtonStyles="Large">
@@ -198,6 +211,7 @@
       <MenuTab>MBITool_W</MenuTab>
       <Modules>MBITool</Modules>
     </Button>
+
 </Panel>
 </Menus>
 <!--名称里面换行-->

+ 3 - 3
MBI/Menu/Tool.xml

@@ -10,7 +10,7 @@
   </Tab>
   <Panel PanelName="工具" GroupFlag="True" GroupImage="" RevitVer="R14,R15,R16,R17"  ButtonStyles="Large">
 
-    <Button ButtonStyles="Stacked">
+    <Button ButtonStyles="Large">
       <ButtonName>ToolCommand.DeleteZeroSpaceCommand</ButtonName>
       <ButtonText>删除本层Zero空间</ButtonText>
       <ImageName>1、打开楼层模型</ImageName>
@@ -22,7 +22,7 @@
       <MenuTab>Tool_W</MenuTab>
       <Modules>Tool</Modules>
     </Button>
-    <Button ButtonStyles="Stacked">
+    <Button ButtonStyles="Large">
       <ButtonName>ToolCommand.ExportCategoriesCommand</ButtonName>
       <ButtonText>导出所有的设备类别</ButtonText>
       <ImageName>1、打开楼层模型</ImageName>
@@ -35,7 +35,7 @@
       <Modules>Tool</Modules>
     </Button>
 
-    <Button ButtonStyles="Stacked">
+    <Button ButtonStyles="Large">
       <ButtonName>ToolCommand.FocusLocationCommand</ButtonName>
       <ButtonText>浏览坐标</ButtonText>
       <ImageName>1、打开楼层模型</ImageName>

+ 16 - 6
MBI/SAGA.DotNetUtils/WPF/Converter/StringToImageConverter.cs

@@ -18,18 +18,28 @@ namespace SAGA.DotNetUtils.WPF.Converter
     /// <summary>
     /// StringToImageConverter
     /// </summary>
-    public class StringToImageConverter:IValueConverter
+    public class StringToImageConverter : IValueConverter
     {
         public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
         {
             BitmapImage img = new BitmapImage();
             if (value == null) return img;
             //若要原始文件的站点,可以调用 Application 类的 GetRemoteStream 方法,同时传递标识原始文件的所需站点的 pack URI。 GetRemoteStream 将返回一个 StreamResourceInfo 对象,该对象将原始文件的该站点作为 Stream 公开,并描述其内容类型。
-            StreamResourceInfo info = Application.GetRemoteStream(new Uri(value.ToString(), UriKind.Relative));
-            img.BeginInit();
-            //img.UriSource = new Uri(value.ToString(), UriKind.Relative);
-            img.StreamSource = info.Stream;
-            img.EndInit();
+            try
+            {
+                var uri = new Uri(value.ToString().Replace("%20", " "), UriKind.Relative);
+                StreamResourceInfo info = Application.GetRemoteStream(uri);
+                img.BeginInit();
+                //img.UriSource = new Uri(value.ToString(), UriKind.Relative);
+                img.StreamSource = info.Stream;
+                img.EndInit();
+            }
+            catch (Exception e)
+            {
+                Console.WriteLine(e);
+                img = null;
+            }
+
             return img;
         }
 

+ 2 - 1
MBI/SAGA.MBI/Extend/DocExtend.cs

@@ -110,6 +110,7 @@ namespace SAGA.MBI.Tools
         public static MFloor GetCurMFloor(this Document doc)
         {
             MFloor floor = null;
+            if (doc == null) return floor;
             string floorId = doc.PathName.GetFileName();
             TreeNodeItem tree = DalModeFileManange.GetFloorTreeById(floorId);
             if (tree != null)
@@ -150,7 +151,7 @@ namespace SAGA.MBI.Tools
         public static List<Element> GetMbiElements(this Document doc)
         {
             List<Element> elements=new List<Element>();
-            elements.AddRange(doc.GetElements(typeof(Wall)));
+            //elements.AddRange(doc.GetElements(typeof(Wall)));
             elements.AddRange(doc.GetElements(typeof(FamilyInstance)));
             return elements;
         }

+ 5 - 5
MBI/SAGA.MBI/Extend/ElementExtend.cs

@@ -35,12 +35,12 @@ namespace SAGA.MBI.Tools
         public static bool IsEquipment(this Element element)
         {
             bool result = false;
-            if (element is Wall wall)
-            {//添加幕墙识别
-                result = wall.WallType.Kind == WallKind.Curtain;
+            //if (element is Wall wall)
+            //{//添加幕墙识别
+            //    result = wall.WallType.Kind == WallKind.Curtain;
 
-            }
-            else
+            //}
+            //else
             if (element is FamilyInstance fi)
             {
                 var family = fi.GetFamilyName();

+ 2 - 0
MBI/SAGA.MBI/SAGA.MBI.csproj

@@ -327,6 +327,7 @@
     <Compile Include="RevitModelHandle\RevitParameterUpdate.cs" />
     <Compile Include="RevitReference\RVTNoModeDutyOperate.cs" />
     <Compile Include="Service\InputService.cs" />
+    <Compile Include="Test\CopyWallLocalName.cs" />
     <Compile Include="ToolsData\DataCheck\DutyModeCodeDiffCheck.cs" />
     <Compile Include="ToolsData\DataCheck\DutyModeCodeDiffCheckResult.cs" />
     <Compile Include="ToolsData\DataCheck\SpaceEquipFloorCheck.cs" />
@@ -353,6 +354,7 @@
     <Compile Include="ToolsData\DataCheck\WinDataCheckSetting.xaml.cs">
       <DependentUpon>WinDataCheckSetting.xaml</DependentUpon>
     </Compile>
+    <Compile Include="ToolsData\IDataCorrect.cs" />
     <Compile Include="ToolsData\ModeCheck\EquipReferSystemCheck.cs" />
     <Compile Include="ToolsData\ModeCheck\EquipReferSystemCheckResult.cs" />
     <Compile Include="ToolsData\ModeCheck\ParameterIntegrityCheck.cs" />

+ 118 - 0
MBI/SAGA.MBI/Test/CopyWallLocalName.cs

@@ -0,0 +1,118 @@
+/* ==============================================================================
+ * 功能描述:同步幕墙的本地名称、本地编码到幕墙嵌板中?
+ * 创 建 者:Garrett
+ * 创建日期:2018/7/11 14:34:26
+ * ==============================================================================*/
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using Autodesk.Revit.DB;
+using Microsoft.Win32;
+using NPOI.SS.UserModel;
+using NPOI.XSSF.UserModel;
+using SAGA.DotNetUtils.Data;
+using SAGA.DotNetUtils.Extend;
+using SAGA.DotNetUtils.Logger;
+using SAGA.DotNetUtils.Others;
+using SAGA.MBI.Calc;
+using SAGA.MBI.DataArrange;
+using SAGA.MBI.Model;
+using SAGA.MBI.Tools;
+using SAGA.MBI.ToolsData;
+using SAGA.MBI.WinView.Upload;
+using SAGA.Models;
+using SAGA.RevitUtils.Extends;
+using ICell = NPOI.SS.UserModel.ICell;
+using CellType = NPOI.SS.UserModel.CellType;
+
+namespace SAGA.MBI.Test
+{
+    /// <summary>
+    /// CheckEquipInSpace
+    /// </summary>
+    public class CopyWallLocalName : IDataCorrect
+    {
+
+        public string Execute(MFloor floor)
+        {
+            try
+            {
+                string fullPah = floor.FullPath;
+                Document doc = ExternalDataWrapper.Current.UiApp.Application.OpenDocumentFile(fullPah);
+                OperateFloor(doc);
+                doc.Save();
+            }
+            catch (Exception e)
+            {
+                MessageShowBase.Show(e);
+            }
+            return null;
+        }
+
+        public string ExecuteAll()
+        {
+            var floors = DalProjectTree.GetAllFloors(false);
+            List<CalcContext> contexts = new List<CalcContext>();
+            foreach (MFloor floor in floors)
+            {
+                Execute(floor);
+            }
+
+            return null;
+        }
+
+        private void OperateFloor(Document doc)
+        {
+            using (Transaction trans = new Transaction(doc, "复制属性"))
+            {
+                trans.Start();
+                var walls = doc.GetElements<Wall>().Where(t => IsCurtainWall(t));
+                foreach (Wall wall in walls)
+                {
+                    var panelIds = wall.CurtainGrid?.GetPanelIds();
+                    if (panelIds != null && panelIds.Any())
+                    {
+                        foreach (ElementId id in panelIds)
+                        {
+                            Element targetElement = doc.GetElement(id);
+                            if (targetElement != null)
+                                CopyPropertyValue(wall, targetElement);
+                        }
+
+                    }
+                }
+
+                trans.Commit();
+            }
+        }
+
+        private void CopyPropertyValue(Element originElement, Element targetElement)
+        {
+            List<string> propertyNames = new List<string>(){MBIBuiltInParameterName.EquipLocalName,
+                MBIBuiltInParameterName.EquipLocalID
+        };
+            foreach (string propertyName in propertyNames)
+            {
+                try
+                {
+                    targetElement.SetParameterValue(propertyName, originElement.GetParameterString(propertyName));
+                }
+                catch (Exception e)
+                {
+                }
+            }
+        }
+
+        public bool IsCurtainWall(Element element)
+        {
+            bool result = false;
+            if (element is Wall wall)
+            {//添加幕墙识别
+                result = wall.WallType.Kind == WallKind.Curtain;
+            }
+            return result;
+        }
+    }
+}

+ 68 - 32
MBI/SAGA.MBI/TestCommand.cs

@@ -7,6 +7,7 @@ using System.Text;
 using System.Text.RegularExpressions;
 using System.Threading;
 using System.Threading.Tasks;
+using System.Windows.Forms;
 using System.Windows.Media;
 using Autodesk.Revit.Attributes;
 using Autodesk.Revit.DB;
@@ -14,6 +15,7 @@ using Autodesk.Revit.DB.Plumbing;
 using Autodesk.Revit.UI;
 using Autodesk.Revit.UI.Selection;
 using SAGA.DotNetUtils;
+using SAGA.DotNetUtils.Data;
 using SAGA.DotNetUtils.Extend;
 using SAGA.DotNetUtils.Geometry;
 using SAGA.DotNetUtils.Logger;
@@ -22,8 +24,11 @@ using SAGA.MBI.Calc;
 using SAGA.MBI.DataArrange;
 using SAGA.MBI.Interaction;
 using SAGA.MBI.ModeInfoEdit;
+using SAGA.MBI.Model;
 using SAGA.MBI.RevitExport;
+using SAGA.MBI.Test;
 using SAGA.MBI.Tools;
+using SAGA.MBI.ToolsData;
 using SAGA.MBI.WinView.Login;
 using SAGA.MBI.WinView.Upload;
 using SAGA.RevitUtils;
@@ -119,7 +124,7 @@ namespace SAGA.MBI
                         double maxz = spaceVertex.Max(t => t.Z);
                         //if (z.IsBetween(minz, maxz))
                         {
-                            if(Geometry2D.InSidePolygon(spaceVertex.Select(t=>t.ToPointD()).ToArray(),point)!=2)
+                            if (Geometry2D.InSidePolygon(spaceVertex.Select(t => t.ToPointD()).ToArray(), point) != 2)
                             //if (xyz.PointInPolygonByRay(spaceVertex) != -1)
                             {
                                 gcount++;
@@ -171,7 +176,7 @@ namespace SAGA.MBI
                             {
                                 contexts.Add(new CalcContext(floor.MFloor));
                             }
-                            MBIModelInfoUpload.UpdateMbiInfo(contexts);                                                                  
+                            MBIModelInfoUpload.UpdateMbiInfo(contexts);
                             break;
                         }
                     case System.Windows.Forms.DialogResult.No:
@@ -181,7 +186,7 @@ namespace SAGA.MBI
                             MBIModelInfoUpload.UploadMbiInfo(floorId);
                             break;
                         }
-                }            
+                }
             }
             catch (Exception e)
             {
@@ -262,14 +267,14 @@ namespace SAGA.MBI
         {
             try
             {
-                var pickElement=ExternalDataWrapper.Current.UiApp.PickElement("请选择水管", new PipeFilter());
+                var pickElement = ExternalDataWrapper.Current.UiApp.PickElement("请选择水管", new PipeFilter());
                 if (pickElement == null)
                 {
-                       return Result.Succeeded;
+                    return Result.Succeeded;
                 }
 
-                using (Transaction tran = new Transaction(ExternalDataWrapper.Current.Doc,"连接"))
-                 
+                using (Transaction tran = new Transaction(ExternalDataWrapper.Current.Doc, "连接"))
+
                 {
                     try
                     {
@@ -289,7 +294,7 @@ namespace SAGA.MBI
                         MessageShow.Show(ex);
                         tran.RollBack();
                     }
-                }              
+                }
             }
             catch (Exception e)
             {
@@ -335,10 +340,10 @@ namespace SAGA.MBI
                         tran.Start();
                         var doc = ExternalDataWrapper.Current.Doc;
                         var s = pickElement.GetLocationPointMBIXYZ();
-                        DirectShape ds = DirectShape.CreateElement(doc,new ElementId(BuiltInCategory.OST_GenericModel));
+                        DirectShape ds = DirectShape.CreateElement(doc, new ElementId(BuiltInCategory.OST_GenericModel));
                         var solid = SolidUtil.CreateSphereAtPoint(s, 1);
                         ds.AppendShape(new List<GeometryObject>() { solid });
-                        SolidUtil.SetColor(ds,new Color(255, 0, 0));            
+                        SolidUtil.SetColor(ds, new Color(255, 0, 0));
                         tran.Commit();
                         ExternalDataWrapper.Current.UiApp.SetShowElements(new List<Element>() { ds });
                     }
@@ -358,7 +363,7 @@ namespace SAGA.MBI
         }
 
 
-      
+
         public class EquipmentFilter : ISelectionFilter
         {
             public bool AllowElement(Element elem)
@@ -390,11 +395,11 @@ namespace SAGA.MBI
                 var doc = ExternalDataWrapper.Current.App.OpenDocumentFile(floor.FullPath);
                 var eles = doc.GetAllElements();
 
-                string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory),$"{floor}_{System.DateTime.Now.Millisecond}.txt");
+                string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), $"{floor}_{System.DateTime.Now.Millisecond}.txt");
                 //File.Create(path);
                 foreach (Element element in eles)
                 {
-                    File.AppendAllText(path,$"{element.Id}:{element.Name}\r\n");
+                    File.AppendAllText(path, $"{element.Id}:{element.Name}\r\n");
                 }
             }
             catch (Exception e)
@@ -446,7 +451,7 @@ namespace SAGA.MBI
                         var tempRefs = connector.GetReferenceConnectors();
                         foreach (var tempRef in tempRefs)
                         {
-                            if (ConnectorType.Physical.HasFlag(tempRef.ConnectorType)&& tempRef.IsConnectedTo(connector))
+                            if (ConnectorType.Physical.HasFlag(tempRef.ConnectorType) && tempRef.IsConnectedTo(connector))
                             {
                                 connector.DisconnectFrom(tempRef);
 
@@ -469,7 +474,7 @@ namespace SAGA.MBI
                         foreach (var connector in connectors)
                         {
                             var newLength = refCon.Origin.Subtract(connector.Origin).GetLength();
-                            if (newLength < maxLength&&!connector.IsConnected)
+                            if (newLength < maxLength && !connector.IsConnected)
                             {
                                 maxLength = newLength;
                                 bConnector = connector;
@@ -491,7 +496,7 @@ namespace SAGA.MBI
                     return Result.Cancelled;
                 }
             }
-               
+
             return Result.Succeeded;
         }
 
@@ -509,18 +514,18 @@ namespace SAGA.MBI
     public class UpdateLevelNameCommand : ExternalCommand
     {
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
-        {        
+        {
             var result = System.Windows.Forms.DialogResult.No;//MessageShow.Question2("是修改整个项目(【是】整个项目;【否】当前打开模型)");
             switch (result)
             {
                 case System.Windows.Forms.DialogResult.Yes:
-                {
-                    var floors = DalUploadFloor.GetHasFileFloors();
-                    List<CalcContext> contexts = new List<CalcContext>();
-                    foreach (UploadFloor floor in floors)
                     {
-                        contexts.Add(new CalcContext(floor.MFloor));
-                    }
+                        var floors = DalUploadFloor.GetHasFileFloors();
+                        List<CalcContext> contexts = new List<CalcContext>();
+                        foreach (UploadFloor floor in floors)
+                        {
+                            contexts.Add(new CalcContext(floor.MFloor));
+                        }
 
                         #region 修改所有项目文件
                         foreach (var context in contexts)
@@ -543,15 +548,15 @@ namespace SAGA.MBI
 
                         #endregion
                         break;
-                }
+                    }
                 case System.Windows.Forms.DialogResult.No:
-                {
-                    MbiElementManager.ExecuteExport(ExternalDataWrapper.Current.Doc);
-                    UpdateLevleName(ExternalDataWrapper.Current.Doc);
-                    break;
-                }
+                    {
+                        MbiElementManager.ExecuteExport(ExternalDataWrapper.Current.Doc);
+                        UpdateLevleName(ExternalDataWrapper.Current.Doc);
+                        break;
+                    }
             }
-           
+
             return Result.Succeeded;
         }
 
@@ -604,13 +609,44 @@ namespace SAGA.MBI
                 catch (Exception e)
                 {
                     tran.RollBack();
-                    MessageShow.Infomation(string.Format("{0}:失败",document.PathName));
+                    MessageShow.Infomation(string.Format("{0}:失败", document.PathName));
                 }
             }
 
         }
 
     }
+    /// <summary>
+    /// 同步幕墙的本地名称、本地编码到幕墙嵌板中?
+    /// </summary>
+    [Transaction(TransactionMode.Manual)]
+    [Regeneration(RegenerationOption.Manual)]
+    public class CopyLocalNameCurtainToPanelCommand : ExternalCommand
+    {
+        public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
+        {
+            try
+            {
+                //var tip = MessageShow.Question2("确定要执行同步幕墙的本地名称、本地编码到幕墙嵌板中?\r\n是:修正全部楼层\r\n否:修正当前楼层\r\n取消:取消修正。");
+                var tip = MessageShow.Question("确定要执行同步幕墙的本地名称、本地编码到幕墙嵌板中?\r\n是:修正当前楼层\r\n否:取消修正。");
+                switch (tip)
+                {
+                    case true:
+                        MFloor floor = ExternalDataWrapper.Current.Doc.GetCurMFloor();
+                        if (floor != null)
+                            SingleInstance<CopyWallLocalName>.Instance.Execute(floor);
+                        break;
+                    default:
+                        break;
+                }
+            }
+            catch (Exception e)
+            {
+                MessageShow.Show(e);
+                return Result.Cancelled;
+            }
+            return Result.Succeeded;
+        }
+    }
 
-   
 }

+ 16 - 0
MBI/SAGA.MBI/ToolsData/IDataCorrect.cs

@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using SAGA.MBI.Model;
+
+namespace SAGA.MBI.ToolsData
+{
+    interface IDataCorrect
+    {
+        string ExecuteAll();
+        string Execute(MFloor floor);
+
+    }
+}

+ 1 - 2
MBI/SAGA.RevitUtils/Extends/ParameterExtend.cs

@@ -292,8 +292,7 @@ namespace SAGA.RevitUtils.Extends
                     StorageType storageType = parameter.StorageType;
                     if (StorageType.String == storageType)
                     {
-                        parameter.SetValueString(value);
-                        flag = true;
+                        flag = parameter.Set(value);
                     }
                 }
             }

BIN
MBI/Updater/Update.exe


BIN
MBI/Updater/Update.pdb


+ 4 - 1
MBI/WPfPointInfo/WPfPointInfo.csproj

@@ -48,7 +48,10 @@
   <ItemGroup>
     <Reference Include="System" />
     <Reference Include="System.Data" />
-    <Reference Include="System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
+    <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\Dlls\FirmLibDll\System.Windows.Interactivity.dll</HintPath>
+    </Reference>
     <Reference Include="System.Xml" />
     <Reference Include="Microsoft.CSharp" />
     <Reference Include="System.Core" />