From 2f51521aa13f0350ebccd5665cd0fc7dad38234b Mon Sep 17 00:00:00 2001 From: GG Z <903524121@qq.com> Date: Fri, 28 Jan 2022 08:53:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ExecuteCmd/CreatePalanarViewAnnotation.cs | 42 ++++++++++++-- .../Finishes/ExecuteCmd/PlaceWallFinishes.cs | 41 +++++++------ .../ParcelAreaModule/ExecuteCmd/PlaceLamps.cs | 8 ++- RookieStation/Properties/AssemblyInfo.cs | 4 +- RookieStation/Utils/RsRevitUtils.cs | 9 +-- RookieStationSetup/RookieStationSetup.vdproj | 6 +- TestTools/TestCmd.cs | 58 ++++++++++--------- 7 files changed, 105 insertions(+), 63 deletions(-) diff --git a/RookieStation/Drawing/ExecuteCmd/CreatePalanarViewAnnotation.cs b/RookieStation/Drawing/ExecuteCmd/CreatePalanarViewAnnotation.cs index 8ca8cb0..e61fed9 100644 --- a/RookieStation/Drawing/ExecuteCmd/CreatePalanarViewAnnotation.cs +++ b/RookieStation/Drawing/ExecuteCmd/CreatePalanarViewAnnotation.cs @@ -28,9 +28,9 @@ namespace RookieStation.Drawing.ExecuteCmd ModelCurveArray modelCurveArray = null; doc.InvokeGroup(tg => { + Room room = default; try { - Room room = default; var singleWallsToDim = new List(); Dictionary dics = new Dictionary(); IList segments = new List(); @@ -103,7 +103,7 @@ namespace RookieStation.Drawing.ExecuteCmd }, "创建梁和柱标注"); doc.Invoke(ts => { - CreateInstanceTags(doc, segments, false, BuiltInCategory.OST_Doors, BuiltInCategory.OST_Windows, BuiltInCategory.OST_ElectricalFixtures, BuiltInCategory.OST_CommunicationDevices, BuiltInCategory.OST_FurnitureSystems, BuiltInCategory.OST_Furniture, BuiltInCategory.OST_LightingDevices, BuiltInCategory.OST_LightingFixtures); + CreateInstanceTags(doc, segments, false, BuiltInCategory.OST_Doors, BuiltInCategory.OST_Windows, BuiltInCategory.OST_ElectricalFixtures, BuiltInCategory.OST_CommunicationDevices, BuiltInCategory.OST_FurnitureSystems, BuiltInCategory.OST_Furniture, BuiltInCategory.OST_LightingDevices, BuiltInCategory.OST_LightingFixtures, BuiltInCategory.OST_SpecialityEquipment); //CreateBuiltInInstance() CreateLightAnnotations(doc); CreateShelvesDimensions(doc); @@ -145,18 +145,50 @@ namespace RookieStation.Drawing.ExecuteCmd var independentTags = new FilteredElementCollector(doc, doc.ActiveView.Id).OfClass(typeof(IndependentTag)).Cast().Where(tag => tag.TagText == "" || tag.TagText == null).ToList(); foreach (var item in independentTags) { - doc.Delete(item.Id); + if (item.Id != ElementId.InvalidElementId) + { + doc.Delete(item.Id); + } + } + if (room.Id != ElementId.InvalidElementId) + { + doc.Delete(room.Id); } - doc.Delete(room.Id); doc.Regenerate(); foreach (ModelCurve curve in modelCurveArray) { - doc.Delete(curve.Id); + if (curve.Id != ElementId.InvalidElementId) + { + doc.Delete(curve.Id); + } } }, "删除临时房间,空标注"); } catch (Exception ex) { + doc.Invoke(ts => + { + var independentTags = new FilteredElementCollector(doc, doc.ActiveView.Id).OfClass(typeof(IndependentTag)).Cast().Where(tag => tag.TagText == "" || tag.TagText == null).ToList(); + foreach (var item in independentTags) + { + if (item.Id != ElementId.InvalidElementId) + { + doc.Delete(item.Id); + } + } + if (room.Id != ElementId.InvalidElementId) + { + doc.Delete(room.Id); + } + doc.Regenerate(); + foreach (ModelCurve curve in modelCurveArray) + { + if (curve.Id != ElementId.InvalidElementId) + { + doc.Delete(curve.Id); + } + } + }, "删除临时房间,空标注"); Log.WriteLog(ex.Message); //throw; } diff --git a/RookieStation/Finishes/ExecuteCmd/PlaceWallFinishes.cs b/RookieStation/Finishes/ExecuteCmd/PlaceWallFinishes.cs index 1f8306a..3c95fc2 100644 --- a/RookieStation/Finishes/ExecuteCmd/PlaceWallFinishes.cs +++ b/RookieStation/Finishes/ExecuteCmd/PlaceWallFinishes.cs @@ -276,25 +276,28 @@ namespace RookieStation.Finishes.ExecuteCmd var wallCreated = Wall.Create(doc, curve, wallType.Id, baselevel.Id, wallHeight / 304.8, wallBaseOffest / 304.8, false, false); doc.Regenerate(); - try - { - if (wallCreated.WallType.Kind == WallKind.Stacked) - { - foreach (var wallid in wallCreated.GetStackedWallMemberIds()) - { - Wall stackedwall = doc.GetElement(wallid) as Wall; - JoinGeometryUtils.JoinGeometry(doc, wall, stackedwall); - } - } - else - { - JoinGeometryUtils.JoinGeometry(doc, wall, wallCreated); - } - } - catch (Exception ex) - { - Log.WriteLog(ex.Message); - } + + WallUtils.DisallowWallJoinAtEnd(wallCreated, 0); + WallUtils.DisallowWallJoinAtEnd(wallCreated, 1); + //try + //{ + // if (wallCreated.WallType.Kind == WallKind.Stacked) + // { + // foreach (var wallid in wallCreated.GetStackedWallMemberIds()) + // { + // Wall stackedwall = doc.GetElement(wallid) as Wall; + // JoinGeometryUtils.JoinGeometry(doc, wall, stackedwall); + // } + // } + // else + // { + // JoinGeometryUtils.JoinGeometry(doc, wall, wallCreated); + // } + //} + //catch (Exception ex) + //{ + // Log.WriteLog(ex.Message); + //} }, "创建墙面饰面"); } } diff --git a/RookieStation/ParcelAreaModule/ExecuteCmd/PlaceLamps.cs b/RookieStation/ParcelAreaModule/ExecuteCmd/PlaceLamps.cs index 2a3a4bc..4505866 100644 --- a/RookieStation/ParcelAreaModule/ExecuteCmd/PlaceLamps.cs +++ b/RookieStation/ParcelAreaModule/ExecuteCmd/PlaceLamps.cs @@ -48,10 +48,9 @@ namespace RookieStation.ParcelAreaModule.ExecuteCmd return doc.InvokeGroup(tg => { + List modelCurveIds = new List(); try { - List modelCurveIds = new List(); - //var v = new FilteredElementCollector(doc).OfClass(typeof(View)) // .Cast() // .FirstOrDefault(x => x.ViewType == ViewType.FloorPlan && x.GenLevel.Elevation == 0); @@ -228,6 +227,11 @@ namespace RookieStation.ParcelAreaModule.ExecuteCmd } catch (Autodesk.Revit.Exceptions.OperationCanceledException) { + doc.Invoke(ts => + { + //删除模型线 + doc.Delete(modelCurveIds); + }, "删除模型线"); //if (tg.GetStatus() == TransactionStatus.Started) //{ // tg.RollBack(); diff --git a/RookieStation/Properties/AssemblyInfo.cs b/RookieStation/Properties/AssemblyInfo.cs index 866d256..b5ffe7b 100644 --- a/RookieStation/Properties/AssemblyInfo.cs +++ b/RookieStation/Properties/AssemblyInfo.cs @@ -33,6 +33,6 @@ using System.Runtime.InteropServices; //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //通过使用 "*",如下所示: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.0.2.0")] +[assembly: AssemblyFileVersion("1.0.2.0")] [assembly: NeutralResourcesLanguage("zh")] diff --git a/RookieStation/Utils/RsRevitUtils.cs b/RookieStation/Utils/RsRevitUtils.cs index 7de74e1..601d4b6 100644 --- a/RookieStation/Utils/RsRevitUtils.cs +++ b/RookieStation/Utils/RsRevitUtils.cs @@ -9,6 +9,7 @@ using System.Text; using static System.Net.WebRequestMethods; using Autodesk.Revit.UI; using HandyControl.Controls; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; namespace RookieStation.Utils { @@ -871,7 +872,7 @@ namespace RookieStation.Utils var x = baseTag.TagHeadPosition.X - tag.TagHeadPosition.X; var y = baseTag.TagHeadPosition.Y - tag.TagHeadPosition.Y; tag.TagHeadPosition += x * XYZ.BasisX + (y + distance * i) * XYZ.BasisY; - if (Math.Abs(tag.LeaderEnd.X - baseTag.LeaderEnd.X) < 20 / 304.8)//引线端线水平距离小于20 + if (Math.Abs(tag.LeaderEnd.X - baseTag.LeaderEnd.X) < 50 / 304.8)//引线端线水平距离小于50 { tag.LeaderElbow = baseTag.LeaderElbow + (tag.TagHeadPosition.Y - baseTag.TagHeadPosition.Y) * XYZ.BasisY; tag.LeaderEnd += (baseTag.LeaderEnd.X - tag.LeaderEnd.X) * XYZ.BasisX; @@ -883,7 +884,7 @@ namespace RookieStation.Utils } tag.LeaderEndCondition = LeaderEndCondition.Attached; } - if (baseTag.LeaderEndCondition == LeaderEndCondition.Free) + if (baseTag.LeaderEndCondition == LeaderEndCondition.Free && baseTag.CanLeaderEndConditionBeAssigned(LeaderEndCondition.Attached)) { baseTag.LeaderEndCondition = LeaderEndCondition.Attached; } @@ -973,7 +974,7 @@ namespace RookieStation.Utils ////端点之间的直线距离 //var v1 = baseTag.LeaderEnd - tag.LeaderEnd; //var d1 = v1.DotProduct(moveUnitVector); - if (Math.Abs(dd) < 20 / 304.8) + if (Math.Abs(dd) < 50 / 304.8) { tag.LeaderElbow = baseTag.LeaderElbow + (tag.TagHeadPosition.Z - baseTag.TagHeadPosition.Z) * XYZ.BasisZ; @@ -990,7 +991,7 @@ namespace RookieStation.Utils } } - if (baseTag.LeaderEndCondition == LeaderEndCondition.Free) + if (baseTag.LeaderEndCondition == LeaderEndCondition.Free && baseTag.CanLeaderEndConditionBeAssigned(LeaderEndCondition.Attached)) { baseTag.LeaderEndCondition = LeaderEndCondition.Attached; } diff --git a/RookieStationSetup/RookieStationSetup.vdproj b/RookieStationSetup/RookieStationSetup.vdproj index bf9ad43..2ee3855 100644 --- a/RookieStationSetup/RookieStationSetup.vdproj +++ b/RookieStationSetup/RookieStationSetup.vdproj @@ -2402,15 +2402,15 @@ { "Name" = "8:Microsoft Visual Studio" "ProductName" = "8:菜鸟驿站工具集" - "ProductCode" = "8:{34472669-5555-4677-BDCA-76AE92FB33A0}" - "PackageCode" = "8:{68A99B7F-1AC0-4D64-932E-9E4C9549813D}" + "ProductCode" = "8:{97514960-6B8E-4C20-BAEA-4A56F44828EF}" + "PackageCode" = "8:{4FB3F3D3-C7F1-4150-AA6A-82B35C26DE20}" "UpgradeCode" = "8:{127EC3EC-7539-468B-84EA-E1ECDD6204E6}" "AspNetVersion" = "8:2.0.50727.0" "RestartWWWService" = "11:FALSE" "RemovePreviousVersions" = "11:TRUE" "DetectNewerInstalledVersion" = "11:TRUE" "InstallAllUsers" = "11:TRUE" - "ProductVersion" = "8:1.0.1" + "ProductVersion" = "8:1.0.2" "Manufacturer" = "8:YTX Engineering" "ARPHELPTELEPHONE" = "8:" "ARPHELPLINK" = "8:" diff --git a/TestTools/TestCmd.cs b/TestTools/TestCmd.cs index 0dcddb1..3126ebd 100644 --- a/TestTools/TestCmd.cs +++ b/TestTools/TestCmd.cs @@ -1,4 +1,5 @@ using Autodesk.Revit.DB; +using Autodesk.Revit.DB.Architecture; using Autodesk.Revit.UI; using Autodesk.Revit.UI.Selection; using System; @@ -21,37 +22,38 @@ namespace TestTools Document doc = uidoc.Document; DocumentSet docset = uiapp.Application.Documents; - Reference refer = uidoc.Selection.PickObject(ObjectType.Element, "请选择XXX"); - Element e = uidoc.Document.GetElement(refer); - Options options = new Options() - { - ComputeReferences = true, - DetailLevel = ViewDetailLevel.Fine, - }; - var eleIds = e.GetGeneratingElementIds(e.get_Geometry(options)); - uidoc.Selection.SetElementIds(eleIds); + //Reference refer = uidoc.Selection.PickObject(ObjectType.Element, "请选择XXX"); + //Element e = uidoc.Document.GetElement(refer); + //Options options = new Options() + //{ + // ComputeReferences = true, + // DetailLevel = ViewDetailLevel.Fine, + //}; + //var eleIds = e.GetGeneratingElementIds(e.get_Geometry(options)); + //uidoc.Selection.SetElementIds(eleIds); #region FilterExecute - //var walls = new FilteredElementCollector(doc).OfClass(typeof(Wall)).ToElements(); - //using (Transaction trans = new Transaction(doc, "default")) - //{ - // try - // { - // trans.Start(); - // //Do Something. - // trans.Commit(); - // } - // catch (Exception ex) - // { - // message = ex.Message; - // if (trans.GetStatus() == TransactionStatus.Started) - // { - // trans.RollBack(); - // } - // return Result.Failed; - // } - //} + var walls = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).ToElements(); + using (Transaction trans = new Transaction(doc, "default")) + { + try + { + trans.Start(); + var rooms = walls.Where(wall => wall.Name.Contains("房间")).Select(wall => wall.Id).ToList(); + doc.Delete(rooms); + trans.Commit(); + } + catch (Exception ex) + { + message = ex.Message; + if (trans.GetStatus() == TransactionStatus.Started) + { + trans.RollBack(); + } + return Result.Failed; + } + } #endregion FilterExecute