diff --git a/RookieStation/CmdArrangeShelfCards.cs b/RookieStation/CmdArrangeShelfCards.cs index b966101..615628d 100644 --- a/RookieStation/CmdArrangeShelfCards.cs +++ b/RookieStation/CmdArrangeShelfCards.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Windows; +using System.Windows.Controls; namespace RookieStation.PackAreaModule { @@ -17,22 +18,21 @@ namespace RookieStation.PackAreaModule public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; - UIDocument uidoc = uiapp.ActiveUIDocument; - string addin_path = typeof(RsApp).Assembly.Location; - string assembly_directory = System.IO.Path.GetDirectoryName(addin_path); - AssemblyLoader loader = new AssemblyLoader(assembly_directory); + string addinPath = typeof(RsApp).Assembly.Location; + string assemblyDirectory = System.IO.Path.GetDirectoryName(addinPath); + AssemblyLoader loader = new AssemblyLoader(assemblyDirectory); try { loader.HookAssemblyResolve(); - WpfShelfCards cards_number = new WpfShelfCards(uiapp); + WpfShelfCards shelfCards = new WpfShelfCards(uiapp); - System.Windows.Interop.WindowInteropHelper mainUI = new System.Windows.Interop.WindowInteropHelper(cards_number) + System.Windows.Interop.WindowInteropHelper mainui = new System.Windows.Interop.WindowInteropHelper(shelfCards) { Owner = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle }; - cards_number.ShowDialog(); + shelfCards.ShowDialog(); } catch (Exception ex) { @@ -43,7 +43,16 @@ namespace RookieStation.PackAreaModule { loader.UnhookAssemblyResolve(); } + //if (shelfcards.IsPlace) + //{ + // PlaceCards(shelfcards, uidoc); + //} + //else + //{ + // NumberCards(shelfcards, uidoc); + //} return Result.Succeeded; + //if (IsVisible("端牌编号")) //{ // WinIntPtr.ShowAndActive("端牌编号"); diff --git a/RookieStation/CmdBrowserFamily.cs b/RookieStation/CmdBrowserFamily.cs index a41fa1a..f9e7415 100644 --- a/RookieStation/CmdBrowserFamily.cs +++ b/RookieStation/CmdBrowserFamily.cs @@ -15,11 +15,18 @@ namespace RookieStation.CommonTools { public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { - UIApplication uiapp = commandData.Application; - UIDocument uidoc = uiapp.ActiveUIDocument; //var dpid = new DockablePaneId(PaneIdentifiers.GetManagerPaneIdentifier()); - var library_directory = UserConstant.FamilyLibraryDirectory; - System.Diagnostics.Process.Start(library_directory); + try + { + var libraryDirectory = UserConstant.FamilyLibraryDirectory; + System.Diagnostics.Process.Start(libraryDirectory); + } + catch (Exception) + { + TaskDialog.Show("温馨提示", "路径不存在,无法浏览文件"); + return Result.Failed; + } + return Result.Succeeded; } } diff --git a/RookieStation/CmdNewDimension.cs b/RookieStation/CmdNewDimension.cs index 129edb9..85f93c2 100644 --- a/RookieStation/CmdNewDimension.cs +++ b/RookieStation/CmdNewDimension.cs @@ -28,7 +28,7 @@ namespace RookieStation List reffaces = new List(); var ins = instances.FirstOrDefault(); - var p = RsRevitUtils.GetXYZByElement(ins); + var p = RsRevitUtils.GetLocationPointByElement(ins); var v = ins.FacingOrientation; Line line = Line.CreateUnbound(p, v); //createoffest需要根据线的方向和参考方向进行叉乘 diff --git a/RookieStation/CmdPlaceEntranceGate.cs b/RookieStation/CmdPlaceEntranceGate.cs index c08590b..91a5c22 100644 --- a/RookieStation/CmdPlaceEntranceGate.cs +++ b/RookieStation/CmdPlaceEntranceGate.cs @@ -38,20 +38,19 @@ namespace RookieStation.PackAreaModule Document doc = uidoc.Document; revitWindow = uiapp.MainWindowHandle; - WpfEntranceGate entrancegateLayout = CommonUtils.GenerateWindow(); + WpfEntranceGate entranceGateLayout = CommonUtils.GenerateWindow(); + if (entranceGateLayout.DialogResult != true) + { + return Result.Cancelled; + } return doc.InvokeGroup(tg => { - if (entrancegateLayout.DialogResult != true) - { - return Result.Cancelled; - } - try { - FamilySymbol linesymbol = RsRevitUtils.GetGuideSymbol(doc); + FamilySymbol guideSymbol = RsRevitUtils.GetGuideSymbol(doc); eleIdsAdded.Clear(); uiapp.Application.DocumentChanged += Application_DocumentChanged; - uidoc.PromptForFamilyInstancePlacement(linesymbol); + uidoc.PromptForFamilyInstancePlacement(guideSymbol); uiapp.Application.DocumentChanged -= Application_DocumentChanged; } catch (Autodesk.Revit.Exceptions.OperationCanceledException) @@ -60,13 +59,13 @@ namespace RookieStation.PackAreaModule { return Result.Cancelled; } - Line refer_line = RsRevitUtils.GetGuideGeometryAndDeleteGuide(doc, eleIdsAdded); + Line line = RsRevitUtils.GetGuideGeometryAndDeleteGuide(doc, eleIdsAdded); uiapp.Application.DocumentChanged -= Application_DocumentChanged; - double interval = (330 + entrancegateLayout.passage_width) / 304.8; + double interval = (330 + entranceGateLayout.PassageWidth) / 304.8; double offest = 0.0; //布置闸机的数量 - List pts = GetInstancePointsByLine(refer_line, interval); + List pts = GetInstancePointsByLine(line, interval); List instances = new List(); doc.Invoke(ts => { @@ -74,43 +73,43 @@ namespace RookieStation.PackAreaModule }, "创建闸机位置"); doc.Invoke(ts => { - RsRevitUtils.AdjustInstances(doc, instances, refer_line, offest); + RsRevitUtils.AdjustInstances(doc, instances, line, offest); }, "调整闸机位置"); } return Result.Succeeded; }, "布置入口闸机"); } - private void CreateGates(UIDocument uidoc, List pts, out List fis, out double offest) + private void CreateGates(UIDocument uidoc, List points, out List fis, out double offest) { Document doc = uidoc.Document; fis = new List(); Level level = uidoc.ActiveView.GenLevel; - Family gate_family = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "Gate\\闸机.rfa"); - ElementId symbol_id = gate_family.GetFamilySymbolIds().FirstOrDefault(); - FamilySymbol gate_symbol = doc.GetElement(symbol_id) as FamilySymbol; - offest = gate_symbol.GetParameters("深度").FirstOrDefault().AsDouble() / 2; - gate_symbol.Activate(); - foreach (var pt in pts) + Family gateFamily = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "Gate\\闸机.rfa"); + ElementId symbolId = gateFamily.GetFamilySymbolIds().FirstOrDefault(); + FamilySymbol gateSymbol = doc.GetElement(symbolId) as FamilySymbol; + offest = gateSymbol.GetParameters("深度").FirstOrDefault().AsDouble() / 2; + gateSymbol.Activate(); + foreach (XYZ p in points) { - var instance = doc.Create.NewFamilyInstance(pt, gate_symbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); + var instance = doc.Create.NewFamilyInstance(p, gateSymbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); fis.Add(instance); } } - private List GetInstancePointsByLine(Line referline, double interval) + private List GetInstancePointsByLine(Line line, double interval) { int n = 50; List pts = new List(); for (int i = 0; i < n; i++) { double parameter = (i + 0.5) * interval; - if (!referline.IsInside(parameter + (interval / 2))) + if (!line.IsInside(parameter + (interval / 2))) { break; } - pts.Add(referline.Evaluate(parameter, false)); + pts.Add(line.Evaluate(parameter, false)); } return pts; diff --git a/RookieStation/CmdPlaceExitGate.cs b/RookieStation/CmdPlaceExitGate.cs index dcce812..1620f6a 100644 --- a/RookieStation/CmdPlaceExitGate.cs +++ b/RookieStation/CmdPlaceExitGate.cs @@ -44,18 +44,18 @@ namespace RookieStation.PackAreaModule Document doc = uidoc.Document; revitWindow = uiapp.MainWindowHandle; - WpfExitGate gate_layout = CommonUtils.GenerateWindow(); + WpfExitGate gateLayout = CommonUtils.GenerateWindow(); - if (gate_layout.DialogResult == true) + if (gateLayout.DialogResult == true) { - isPassageStart = gate_layout.isStartPassage; + isPassageStart = gateLayout.IsStartPassage; } else { return Result.Cancelled; } - double interval = (2 * (1030 + gate_layout.passage_width) + 100) / 304.8; - double gate_front_offest = 1630 / 304.8; + double interval = (2 * (1030 + gateLayout.PassageWidth) + 100) / 304.8; + double gateFrontOffest = 1630 / 304.8; List instances = new List(); using (TransactionGroup tg = new TransactionGroup(doc, "布置出口收检台")) @@ -63,11 +63,11 @@ namespace RookieStation.PackAreaModule tg.Start(); try { - FamilySymbol line_symbol = RsRevitUtils.GetGuideSymbol(doc); ; + FamilySymbol guideSymbol = RsRevitUtils.GetGuideSymbol(doc); ; eleIdsAdded.Clear(); uiapp.Application.DocumentChanged += Application_DocumentChanged; - uidoc.PromptForFamilyInstancePlacement(line_symbol); + uidoc.PromptForFamilyInstancePlacement(guideSymbol); uiapp.Application.DocumentChanged -= Application_DocumentChanged; } catch (Autodesk.Revit.Exceptions.OperationCanceledException) @@ -77,7 +77,7 @@ namespace RookieStation.PackAreaModule return Result.Cancelled; } //直线向量 - Line refer_line = RsRevitUtils.GetGuideGeometryAndDeleteGuide(doc, eleIdsAdded); + Line referline = RsRevitUtils.GetGuideGeometryAndDeleteGuide(doc, eleIdsAdded); uiapp.Application.DocumentChanged -= Application_DocumentChanged; int orders = UserConstant.Orders; @@ -89,46 +89,46 @@ namespace RookieStation.PackAreaModule } int m = isPassageStart - ? (int)Math.Floor((refer_line.Length * 304.8 / 1630) + 0.5) - : (int)Math.Floor(((refer_line.Length * 304.8) - 200) / 1630 + 0.5); + ? (int)Math.Floor((referline.Length * 304.8 / 1630) + 0.5) + : (int)Math.Floor(((referline.Length * 304.8) - 200) / 1630 + 0.5); if (m < n) { n = m; } - List pts = new List(); + List locationPoint = new List(); doc.Invoke(ts => { - Family gate_family = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "Gate\\L型收检台.rfa"); - IEnumerable left_symbolId = from id in gate_family.GetFamilySymbolIds() - where doc.GetElement(id).Name == "左" + Family gateFamily = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "Gate\\L型收检台.rfa"); + IEnumerable leftSymbolId = from id in gateFamily.GetFamilySymbolIds() + where doc.GetElement(id).Name == "左" + select id; + IEnumerable rightSymbolId = from id in gateFamily.GetFamilySymbolIds() + where doc.GetElement(id).Name == "右" select id; - IEnumerable right_symbolId = from id in gate_family.GetFamilySymbolIds() - where doc.GetElement(id).Name == "右" - select id; - FamilySymbol right_symbol = doc.GetElement(right_symbolId.FirstOrDefault()) as FamilySymbol; + FamilySymbol rightSymbol = doc.GetElement(rightSymbolId.FirstOrDefault()) as FamilySymbol; //ElementId symbolId = family.GetFamilySymbolIds().FirstOrDefault(); - FamilySymbol left_symbol = doc.GetElement(left_symbolId.FirstOrDefault()) as FamilySymbol; + FamilySymbol leftSymbol = doc.GetElement(leftSymbolId.FirstOrDefault()) as FamilySymbol; Level level = uidoc.ActiveView.GenLevel; if (isPassageStart)//起始是通道 { for (int i = 0; i < n; i++) { - XYZ p = refer_line.Evaluate(i * interval, false); - pts.Add(p); + XYZ p = referline.Evaluate(i * interval, false); + locationPoint.Add(p); } - foreach (XYZ location_XYZ in pts) + foreach (XYZ point in locationPoint) { - left_symbol.Activate(); - FamilyInstance left_instance = doc.Create.NewFamilyInstance(location_XYZ, left_symbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); - instances.Add(left_instance); + leftSymbol.Activate(); + FamilyInstance leftInstance = doc.Create.NewFamilyInstance(point, leftSymbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); + instances.Add(leftInstance); if (instances.Count() == n + 1) { break; } - right_symbol.Activate(); - FamilyInstance right_instance = doc.Create.NewFamilyInstance(location_XYZ, right_symbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); - instances.Add(right_instance); + rightSymbol.Activate(); + FamilyInstance rightInstance = doc.Create.NewFamilyInstance(point, rightSymbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); + instances.Add(rightInstance); if (instances.Count() == n + 1) { break; @@ -144,25 +144,25 @@ namespace RookieStation.PackAreaModule { for (int i = 0; i < n; i++) { - XYZ p = refer_line.Evaluate((i * interval) + 1830 / 304.8, false); + XYZ p = referline.Evaluate((i * interval) + 1830 / 304.8, false); - pts.Add(p); + locationPoint.Add(p); } - foreach (var pt in pts) + foreach (var pt in locationPoint) { - left_symbol.Activate(); - var left_instance = doc.Create.NewFamilyInstance(pt, left_symbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); + leftSymbol.Activate(); + var leftInstance = doc.Create.NewFamilyInstance(pt, leftSymbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); //offest = symbol.GetParameters("深度").FirstOrDefault().AsDouble() / 2; - instances.Add(left_instance); + instances.Add(leftInstance); if (instances.Count() == n) { break; } - right_symbol.Activate(); - var right_instance = doc.Create.NewFamilyInstance(pt, right_symbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); - instances.Add(right_instance); + rightSymbol.Activate(); + var rightInstance = doc.Create.NewFamilyInstance(pt, rightSymbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); + instances.Add(rightInstance); if (instances.Count() == n) { break; @@ -172,7 +172,7 @@ namespace RookieStation.PackAreaModule }, "加载并创建收检台"); doc.Invoke(ts => { - RsRevitUtils.AdjustInstances(doc, instances, refer_line, gate_front_offest); + RsRevitUtils.AdjustInstances(doc, instances, referline, gateFrontOffest); }, "调整收检台位置"); //if (tg.GetStatus() == TransactionStatus.Started) //{ diff --git a/RookieStation/CmdPlaceFloorFinishes.cs b/RookieStation/CmdPlaceFloorFinishes.cs index cb5690d..e4cfd4b 100644 --- a/RookieStation/CmdPlaceFloorFinishes.cs +++ b/RookieStation/CmdPlaceFloorFinishes.cs @@ -39,485 +39,457 @@ namespace RookieStation.Finishes if (floorCovering.DialogResult == true) { - length = floorCovering.cLength / 304.8; - width = floorCovering.cWidth / 304.8; - gap = floorCovering.cGap / 304.8; + length = floorCovering.PavementLength / 304.8; + width = floorCovering.PavementWidth / 304.8; + gap = floorCovering.PavementGap / 304.8; } else { return Result.Cancelled; } - using (TransactionGroup tg = new TransactionGroup(doc, "地面铺装")) - { - try - { - var v = new FilteredElementCollector(doc).OfClass(typeof(View)) - .Cast() - .FirstOrDefault(x => x.ViewType == ViewType.FloorPlan && x.GenLevel.Elevation == 0); + return doc.InvokeGroup(tg => + { + try + { + //var v = new FilteredElementCollector(doc).OfClass(typeof(View)) + // .Cast() + // .FirstOrDefault(x => x.ViewType == ViewType.FloorPlan && x.GenLevel.Elevation == 0); - var baselevel = new FilteredElementCollector(doc) - .OfClass(typeof(Level)) - .Cast() - .FirstOrDefault(x => x.Elevation == 0); + //if (uidoc.ActiveView.ViewType != ViewType.FloorPlan) + //{ + // uidoc.RequestViewChange(v); + //} + var baseLevel = doc.ActiveView.GenLevel; + List modelCurveIds = new List(); - List modelCurveIds = new List(); - tg.Start(); - if (uidoc.ActiveView.ViewType != ViewType.FloorPlan) - { - uidoc.RequestViewChange(v); - } + SelectFilter roomFilter = new SelectFilter(); + Reference roomReference = uidoc.Selection.PickObject(ObjectType.Element, roomFilter, "请选择房间"); + Room room = doc.GetElement(roomReference) as Room; - SelectFilter selfilter = new SelectFilter(); - Reference roomrefer = uidoc.Selection.PickObject(ObjectType.Element, selfilter, "请选择房间"); - Room room = doc.GetElement(roomrefer) as Room; + var roompoint = RsRevitUtils.GetLocationPointByElement(room); + var segments = room.GetBoundarySegments(new SpatialElementBoundaryOptions()).FirstOrDefault(); - var roompoint = RsRevitUtils.GetXYZByElement(room); - var segments = room.GetBoundarySegments(new SpatialElementBoundaryOptions()).FirstOrDefault(); + doc.Invoke(ts => + { + foreach (var seg in segments) + { + Curve cur = seg.GetCurve(); + Plane plane = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, new XYZ()); + var mc = doc.Create.NewModelCurve(cur, SketchPlane.Create(doc, plane)); + modelCurveIds.Add(mc.Id); + } + }, "模型线创建"); - doc.Invoke(ts => - { - foreach (var seg in segments) - { - Curve cur = seg.GetCurve(); - Plane plane = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, new XYZ()); - var mc = doc.Create.NewModelCurve(cur, SketchPlane.Create(doc, plane)); - modelCurveIds.Add(mc.Id); - } - }, "模型线创建"); + //Reference edge = uidoc.Selection.PickObject(ObjectType.Edge, "请选择边界"); + SelectFilter mlFilter = new SelectFilter(); + Reference refline = uidoc.Selection.PickObject(ObjectType.Element, mlFilter, "请选择基准边线"); + //模型线选取 + var ml = doc.GetElement(refline) as ModelLine; + Line referline = ml.GeometryCurve as Line; + Line longestLine = RsRevitUtils.GetLongestSegmentLine(segments, referline); + XYZ basePoint = uidoc.Selection.PickPoint(UserConstant.SnapAll, "请选择基准点(位于基准线上)"); + double lengthCount = basePoint.DistanceTo(referline.GetEndPoint(0)) + basePoint.DistanceTo(referline.GetEndPoint(1)); + if (referline.Length - lengthCount > 0.001) + { + MessageBox.Show("请选择基准线上的点", "温馨提示"); + return Result.Cancelled; + } + //if (basepoint.IsAlmostEqualTo(ml.GeometryCurve.GetEndPoint(0)) || basepoint.IsAlmostEqualTo(ml.GeometryCurve.GetEndPoint(1))) + //{ + //} + //基准线端点 + var endpoint1 = referline.GetEndPoint(0); + var endpoint2 = referline.GetEndPoint(1); + //基准点向端点的向量 + XYZ v1 = endpoint1 - basePoint; + XYZ v2 = endpoint2 - basePoint; + //用于确认布置方向 + var v0 = roompoint - basePoint; + List curves = new List(); + List instances = new List(); + //Curve currefer = null; + //Curve currefer1 = null; - //Reference edge = uidoc.Selection.PickObject(ObjectType.Edge, "请选择边界"); - SelectFilter mlfilter = new SelectFilter(); - Reference refline = uidoc.Selection.PickObject(ObjectType.Element, mlfilter, "请选择基准边线"); - //模型线选取 - var ml = doc.GetElement(refline) as ModelLine; - Line line = ml.GeometryCurve as Line; - Line line1 = RsRevitUtils.GetLongestSegmentLine(segments, line); - XYZ basepoint = uidoc.Selection.PickPoint(UserConstant.SnapAll, "请选择基准点(位于基准线上)"); - double alength = basepoint.DistanceTo(line.GetEndPoint(0)) + basepoint.DistanceTo(line.GetEndPoint(1)); - if (line.Length - alength > 0.001) - { - MessageBox.Show("请选择基准线上的点", "温馨提示"); - return Result.Cancelled; - } - //if (basepoint.IsAlmostEqualTo(ml.GeometryCurve.GetEndPoint(0)) || basepoint.IsAlmostEqualTo(ml.GeometryCurve.GetEndPoint(1))) - //{ - //} - //基准线端点 - var endp1 = line.GetEndPoint(0); - var endp2 = line.GetEndPoint(1); - //基准点向端点的向量 - XYZ v1 = endp1 - basepoint; - XYZ v2 = endp2 - basepoint; - //用于确认布置方向 - var v0 = roompoint - basepoint; - List curves = new List(); - List instances = new List(); - //Curve currefer = null; - //Curve currefer1 = null; + double interval = length + gap; + List pts = new List(); + List lastpoints = new List(); + XYZ zdir1 = null; + XYZ zdir2 = null; + XYZ offestVector = null; + double d1 = 0.0; + double d2 = 0.0; + //切分基准线后,两侧向量不为0 + if (!v1.IsAlmostEqualTo(XYZ.Zero)) + { + if (endpoint1.DistanceTo(basePoint) < length) + { + System.Windows.MessageBox.Show("基准点与基准线端点距离太近"); + return Result.Cancelled; + } + zdir1 = v1.CrossProduct(v0).Normalize(); + //偏移的方向,直线的侧方向 + offestVector = zdir1.CrossProduct(v1).Normalize(); + Line l1 = Line.CreateBound(basePoint, ml.GeometryCurve.GetEndPoint(0)); - double interval = length + gap; - List pts = new List(); - List lastps = new List(); - XYZ zdir1 = null; - XYZ zdir2 = null; - XYZ offestvector = null; - double d1 = 0.0; - double d2 = 0.0; - //切分基准线后,两侧向量不为0 - if (!v1.IsAlmostEqualTo(XYZ.Zero)) - { - if (endp1.DistanceTo(basepoint) < length) - { - System.Windows.MessageBox.Show("基准点与基准线端点距离太近"); - return Result.Cancelled; - } - zdir1 = v1.CrossProduct(v0).Normalize(); - //偏移的方向,直线的侧方向 - offestvector = zdir1.CrossProduct(v1).Normalize(); - Line l1 = Line.CreateBound(basepoint, ml.GeometryCurve.GetEndPoint(0)); + for (int i = 0; i < 10000; i++) + { + var parameter = i * interval; + if (!l1.IsInside(parameter + interval - gap / 2)) + { + var lastp1 = pts.Last() - offestVector * width / 2; - for (int i = 0; i < 10000; i++) - { - var parameter = i * interval; - if (!l1.IsInside(parameter + interval - gap / 2)) - { - var lastp1 = pts.Last() - offestvector * width / 2; + d1 = lastp1.DistanceTo(endpoint1) - length / 2 - gap; - d1 = lastp1.DistanceTo(endp1) - length / 2 - gap; + var lastfinalpoint = lastp1 + (l1.Direction * (d1 / 2 + length / 2 + gap)) + (offestVector * width / 2); - var lastfinalpoint = lastp1 + (l1.Direction * (d1 / 2 + length / 2 + gap)) + (offestvector * width / 2); + lastpoints.Add(lastfinalpoint); + break; + } + XYZ p = l1.Evaluate(parameter, false); + XYZ finalPoint = p + (l1.Direction * interval / 2) + (offestVector * width / 2); + //当选择的基准点为端点时 + if (v2.IsAlmostEqualTo(XYZ.Zero)) + { + finalPoint = p + (l1.Direction * (interval - gap) / 2) + (offestVector * width / 2); + } - lastps.Add(lastfinalpoint); - break; - } - XYZ p = l1.Evaluate(parameter, false); - XYZ finalpoint = p + (l1.Direction * interval / 2) + (offestvector * width / 2); - //当选择的基准点为端点时 - if (v2.IsAlmostEqualTo(XYZ.Zero)) - { - finalpoint = p + (l1.Direction * (interval - gap) / 2) + (offestvector * width / 2); - } + pts.Add(finalPoint); + } + } - pts.Add(finalpoint); - } - } + if (!v2.IsAlmostEqualTo(XYZ.Zero)) + { + if (endpoint2.DistanceTo(basePoint) < length) + { + System.Windows.MessageBox.Show("基准点与基准线端点距离太近"); + return Result.Cancelled; + } + zdir2 = v2.CrossProduct(v0).Normalize(); + offestVector = zdir2.CrossProduct(v2).Normalize(); + Line l2 = Line.CreateBound(basePoint, ml.GeometryCurve.GetEndPoint(1)); - if (!v2.IsAlmostEqualTo(XYZ.Zero)) - { - if (endp2.DistanceTo(basepoint) < length) - { - System.Windows.MessageBox.Show("基准点与基准线端点距离太近"); - return Result.Cancelled; - } - zdir2 = v2.CrossProduct(v0).Normalize(); - offestvector = zdir2.CrossProduct(v2).Normalize(); - Line l2 = Line.CreateBound(basepoint, ml.GeometryCurve.GetEndPoint(1)); + for (int i = 0; i < 10000; i++) + { + var parameter = i * interval; + if (!l2.IsInside(parameter + interval - gap / 2)) + { + //var lastdistance = pts.Last().DistanceTo(endp1) - interval / 2 - gap / 2; - for (int i = 0; i < 10000; i++) - { - var parameter = i * interval; - if (!l2.IsInside(parameter + interval - gap / 2)) - { - //var lastdistance = pts.Last().DistanceTo(endp1) - interval / 2 - gap / 2; + var lastp2 = pts.Last() - offestVector * width / 2; - var lastp2 = pts.Last() - offestvector * width / 2; + d2 = lastp2.DistanceTo(endpoint2) - length / 2 - gap; - d2 = lastp2.DistanceTo(endp2) - length / 2 - gap; + var lastFinalPoint = lastp2 + (l2.Direction * (d2 / 2 + length / 2 + gap)) + (offestVector * width / 2); - var lastfinalpoint = lastp2 + (l2.Direction * (d2 / 2 + length / 2 + gap)) + (offestvector * width / 2); + lastpoints.Add(lastFinalPoint); + break; + } + XYZ p = l2.Evaluate(parameter, false); + //附加的基准线的水平垂直偏移距离 + var finalpoint = p + (l2.Direction * interval / 2) + (offestVector * width / 2); + if (v1.IsAlmostEqualTo(XYZ.Zero)) + { + finalpoint = p + (l2.Direction * (interval - gap) / 2) + (offestVector * width / 2); + } - lastps.Add(lastfinalpoint); - break; - } - XYZ p = l2.Evaluate(parameter, false); - //附加的基准线的水平垂直偏移距离 - var finalpoint = p + (l2.Direction * interval / 2) + (offestvector * width / 2); - if (v1.IsAlmostEqualTo(XYZ.Zero)) - { - finalpoint = p + (l2.Direction * (interval - gap) / 2) + (offestvector * width / 2); - } + pts.Add(finalpoint); + } + //var lastl2 = pts.Last().DistanceTo(endp2); + } + doc.Invoke(ts => + { + //删除模型线 + doc.Delete(modelCurveIds); + family = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "FloorFinish\\地砖.rfa"); + ElementId symbolId = family.GetFamilySymbolIds().FirstOrDefault(); + symbol = doc.GetElement(symbolId) as FamilySymbol; + symbol.Activate(); + foreach (var p in pts) + { + var fi = doc.Create + .NewFamilyInstance(p, symbol, baseLevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); + instances.Add(fi); + } + foreach (var p in lastpoints) + { + var fi = doc.Create + .NewFamilyInstance(p, symbol, baseLevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); + instances.Add(fi); + } + }, "地面铺装"); - pts.Add(finalpoint); - } - //var lastl2 = pts.Last().DistanceTo(endp2); - } + doc.Invoke(ts => + { + XYZ veroffestdir = null; + if (zdir1 != null) + { + veroffestdir = zdir1.CrossProduct(referline.Direction).Normalize(); + } + if (zdir2 != null) + { + veroffestdir = zdir2.CrossProduct(referline.Direction).Normalize(); + } + //旋转角度 + double angle = XYZ.BasisY.AngleTo(veroffestdir); + //判断相对于Y轴是正向角度(逆时针)还是逆向角度(顺时针) + var z = veroffestdir.CrossProduct(XYZ.BasisY).Normalize(); + if (z.IsAlmostEqualTo(XYZ.BasisZ)) + { + //逆向旋转,角度取负值 + angle = -angle; + } + //单行调整地砖数量 + int n = 0; + if (v2.IsAlmostEqualTo(XYZ.Zero) || v1.IsAlmostEqualTo(XYZ.Zero)) + { + n = 1; + } + else + { + n = 2; + } + for (int i = 0; i < instances.Count; i++) + { + FamilyInstance fi = instances[i]; - using (Transaction trans = new Transaction(doc, "地面铺装")) - { - trans.Start(); - //删除模型线 - doc.Delete(modelCurveIds); - family = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "FloorFinish\\地砖.rfa"); - ElementId symbolId = family.GetFamilySymbolIds().FirstOrDefault(); - symbol = doc.GetElement(symbolId) as FamilySymbol; - symbol.Activate(); - foreach (var p in pts) - { - var fi = doc.Create - .NewFamilyInstance(p, symbol, baselevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); - instances.Add(fi); - } - foreach (var p in lastps) - { - var fi = doc.Create - .NewFamilyInstance(p, symbol, baselevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); - instances.Add(fi); - } - trans.Commit(); - } - using (Transaction trans = new Transaction(doc, "调整地砖")) - { - trans.Start(); - XYZ veroffestdir = null; - if (zdir1 != null) - { - veroffestdir = zdir1.CrossProduct(line.Direction).Normalize(); - } - if (zdir2 != null) - { - veroffestdir = zdir2.CrossProduct(line.Direction).Normalize(); - } - //旋转角度 - double angle = XYZ.BasisY.AngleTo(veroffestdir); - //判断相对于Y轴是正向角度(逆时针)还是逆向角度(顺时针) - var z = veroffestdir.CrossProduct(XYZ.BasisY).Normalize(); - if (z.IsAlmostEqualTo(XYZ.BasisZ)) - { - //逆向旋转,角度取负值 - angle = -angle; - } - //单行调整地砖数量 - int n = 0; - if (v2.IsAlmostEqualTo(XYZ.Zero) || v1.IsAlmostEqualTo(XYZ.Zero)) - { - n = 1; - } - else - { - n = 2; - } - for (int i = 0; i < instances.Count; i++) - { - FamilyInstance fi = instances[i]; + var filp = RsRevitUtils.GetLocationPointByElement(fi); + Line zaxis = Line.CreateUnbound(filp, XYZ.BasisZ); - var filp = RsRevitUtils.GetXYZByElement(fi); - Line zaxis = Line.CreateUnbound(filp, XYZ.BasisZ); + //旋转,移动 + ElementTransformUtils.RotateElement(doc, fi.Id, zaxis, angle); + fi.GetParameters("长").FirstOrDefault().Set(length); + fi.GetParameters("宽").FirstOrDefault().Set(width); - //旋转,移动 - ElementTransformUtils.RotateElement(doc, fi.Id, zaxis, angle); - fi.GetParameters("长").FirstOrDefault().Set(length); - fi.GetParameters("宽").FirstOrDefault().Set(width); + if (i >= instances.Count - n) + { + var loc = RsRevitUtils.GetLocationPointByElement(instances[i]); - if (i >= instances.Count - n) - { - var loc = RsRevitUtils.GetXYZByElement(instances[i]); + var dis1 = loc.DistanceTo(endpoint1); + var dis2 = loc.DistanceTo(endpoint2); - var dis1 = loc.DistanceTo(endp1); - var dis2 = loc.DistanceTo(endp2); + if (dis1 < interval) + { + fi.GetParameters("长").FirstOrDefault().Set(d1); + } + else if (dis2 < interval) + { + fi.GetParameters("长").FirstOrDefault().Set(d2); + } + } + //ElementTransformUtils.CopyElement(doc, fi.Id, offestvector * (width + gap)); + ////垂直基准线平移 + //ElementTransformUtils.MoveElement(doc, fi.Id, offestdir); - if (dis1 < interval) - { - fi.GetParameters("长").FirstOrDefault().Set(d1); - } - else if (dis2 < interval) - { - fi.GetParameters("长").FirstOrDefault().Set(d2); - } - } - //ElementTransformUtils.CopyElement(doc, fi.Id, offestvector * (width + gap)); - ////垂直基准线平移 - //ElementTransformUtils.MoveElement(doc, fi.Id, offestdir); + ////平行基准线平移 + //ElementTransformUtils.MoveElement(doc, fi.Id, line.Direction * w / 2); + //if (i >= 1) + //{ + // XYZ additionaldir = zdir.CrossProduct(line.Direction).Normalize() * i * (passagewidth + l); + // ElementTransformUtils.MoveElement(doc, fi.Id, additionaldir); + //} + //位于直线右侧时,需要进行左右翻转 + //if (OnLeft == false && fi.CanFlipHand) + //{ + // fi.flipHand(); + //} + } + }, "调整地砖"); - ////平行基准线平移 - //ElementTransformUtils.MoveElement(doc, fi.Id, line.Direction * w / 2); - //if (i >= 1) - //{ - // XYZ additionaldir = zdir.CrossProduct(line.Direction).Normalize() * i * (passagewidth + l); - // ElementTransformUtils.MoveElement(doc, fi.Id, additionaldir); - //} - //位于直线右侧时,需要进行左右翻转 - //if (OnLeft == false && fi.CanFlipHand) - //{ - // fi.flipHand(); - //} - } + doc.Invoke(ts => + { + List idsCopied = new List(); + for (int i = 0; i < instances.Count; i++) + { + FamilyInstance fi = instances[i]; + int num = (int)Math.Floor(longestLine.Length / (width + gap)); + double rem = longestLine.Length - num * (width + gap); + for (int j = 1; j <= num; j++) + { + ICollection eles; + if (j == num) + { + eles = ElementTransformUtils.CopyElement(doc, fi.Id, offestVector * ((rem / 2) + (width + gap) * (j - 0.5) + gap)); + FamilyInstance copyinstance = doc.GetElement(eles.FirstOrDefault()) as FamilyInstance; + copyinstance.GetParameters("宽").FirstOrDefault().Set(rem); - trans.Commit(); - } - using (Transaction trans = new Transaction(doc, "复制地砖")) - { - List copyids = new List(); - trans.Start(); - for (int i = 0; i < instances.Count; i++) - { - FamilyInstance fi = instances[i]; - int num = (int)Math.Floor(line1.Length / (width + gap)); - double rem = line1.Length - num * (width + gap); - for (int j = 1; j <= num; j++) - { - ICollection eles; - if (j == num) - { - eles = ElementTransformUtils.CopyElement(doc, fi.Id, offestvector * ((rem / 2) + (width + gap) * (j - 0.5) + gap)); - FamilyInstance copyinstance = doc.GetElement(eles.FirstOrDefault()) as FamilyInstance; - copyinstance.GetParameters("宽").FirstOrDefault().Set(rem); + idsCopied.AddRange(eles.ToList()); + break; + } + eles = ElementTransformUtils.CopyElement(doc, fi.Id, offestVector * (width + gap) * j); + idsCopied.AddRange(eles.ToList()); + } + } + foreach (var id in idsCopied) + { + FamilyInstance instanceCopied = doc.GetElement(id) as FamilyInstance; + if (instanceCopied.Room == null) + { + doc.Delete(id); + } + } + }, "复制地砖"); - copyids.AddRange(eles.ToList()); - break; - } - eles = ElementTransformUtils.CopyElement(doc, fi.Id, offestvector * (width + gap) * j); - copyids.AddRange(eles.ToList()); - } - } - foreach (var id in copyids) - { - FamilyInstance copyinstance = doc.GetElement(id) as FamilyInstance; - if (copyinstance.Room == null) - { - doc.Delete(id); - } - } - trans.Commit(); - } + #region MyRegion - #region MyRegion + //foreach (var seg in segments) + //{ + // Curve cur = seg.GetCurve(); + // if (cur.GetEndPoint(0).IsAlmostEqualTo(startP) || cur.GetEndPoint(1).IsAlmostEqualTo(startP)) + // { + // currefer = cur; + // } + // if (cur.GetEndPoint(1).IsAlmostEqualTo(startP)) + // { + // currefer1 = cur; + // } - //foreach (var seg in segments) - //{ - // Curve cur = seg.GetCurve(); - // if (cur.GetEndPoint(0).IsAlmostEqualTo(startP) || cur.GetEndPoint(1).IsAlmostEqualTo(startP)) - // { - // currefer = cur; - // } - // if (cur.GetEndPoint(1).IsAlmostEqualTo(startP)) - // { - // currefer1 = cur; - // } + // //XYZ p1 = cur.Evaluate(100 / 304.8, false); + // //XYZ p2 = cur.Evaluate(200 / 304.8, false); + //} - // //XYZ p1 = cur.Evaluate(100 / 304.8, false); - // //XYZ p2 = cur.Evaluate(200 / 304.8, false); - //} + //var n = Math.Floor(currefer1.Length / interval) + 1; + //var rem = currefer1.Length % interval / interval; - //var n = Math.Floor(currefer1.Length / interval) + 1; - //var rem = currefer1.Length % interval / interval; + //var x = 0.5; + //if (rem < 0.334) + //{ + // x = (1 + rem) / 4; + // for (int i = 0; i < n; i++) + // { + // Curve l = null; + // if (i == 0) + // { + // l = currefer.CreateOffset((i + x) * interval, -XYZ.BasisZ); + // } + // if (i >= 1) + // { + // l = currefer.CreateOffset((i - 0.5 + 2 * x) * interval, -XYZ.BasisZ); + // } + // if (i == n - 1) + // { + // l = currefer.CreateOffset((i - 1 + 3 * x) * interval, -XYZ.BasisZ); + // } - //var x = 0.5; - //if (rem < 0.334) - //{ - // x = (1 + rem) / 4; - // for (int i = 0; i < n; i++) - // { - // Curve l = null; - // if (i == 0) - // { - // l = currefer.CreateOffset((i + x) * interval, -XYZ.BasisZ); - // } - // if (i >= 1) - // { - // l = currefer.CreateOffset((i - 0.5 + 2 * x) * interval, -XYZ.BasisZ); - // } - // if (i == n - 1) - // { - // l = currefer.CreateOffset((i - 1 + 3 * x) * interval, -XYZ.BasisZ); - // } + // curves.Add(l); + // } + //} + //else + //{ + // for (int i = 0; i < n; i++) + // { + // //var v = cur.Direction.CrossProduct(XYZ.BasisZ); + // //createoffset的偏移方向由线方向 叉乘 自己给定的方向 - // curves.Add(l); - // } - //} - //else - //{ - // for (int i = 0; i < n; i++) - // { - // //var v = cur.Direction.CrossProduct(XYZ.BasisZ); - // //createoffset的偏移方向由线方向 叉乘 自己给定的方向 + // var l = currefer.CreateOffset((i + x) * interval, -XYZ.BasisZ); + // if (i == n - 1) + // { + // l = currefer.CreateOffset((i - 1 + x) * interval, -XYZ.BasisZ); + // } + // curves.Add(l); + // } + //} - // var l = currefer.CreateOffset((i + x) * interval, -XYZ.BasisZ); - // if (i == n - 1) - // { - // l = currefer.CreateOffset((i - 1 + x) * interval, -XYZ.BasisZ); - // } - // curves.Add(l); - // } - //} + //var m = Math.Floor(currefer.Length / interval) + 1; + //var rem1 = currefer.Length % interval / interval; + //x = 0.5; + //if (rem1 < 0.334) + //{ + // x = (1 + rem1) / 4; + // for (int i = 0; i < m; i++) + // { + // Curve l = null; + // if (i == 0) + // { + // l = currefer1.CreateOffset((i + x) * interval, -XYZ.BasisZ); + // } + // if (i >= 1) + // { + // l = currefer1.CreateOffset((i - 0.5 + 2 * x) * interval, -XYZ.BasisZ); + // } + // if (i == m - 1) + // { + // l = currefer1.CreateOffset((i - 1 + 3 * x) * interval, -XYZ.BasisZ); + // } - //var m = Math.Floor(currefer.Length / interval) + 1; - //var rem1 = currefer.Length % interval / interval; - //x = 0.5; - //if (rem1 < 0.334) - //{ - // x = (1 + rem1) / 4; - // for (int i = 0; i < m; i++) - // { - // Curve l = null; - // if (i == 0) - // { - // l = currefer1.CreateOffset((i + x) * interval, -XYZ.BasisZ); - // } - // if (i >= 1) - // { - // l = currefer1.CreateOffset((i - 0.5 + 2 * x) * interval, -XYZ.BasisZ); - // } - // if (i == m - 1) - // { - // l = currefer1.CreateOffset((i - 1 + 3 * x) * interval, -XYZ.BasisZ); - // } + // curves.Add(l); + // } + //} + //else + //{ + // for (int i = 0; i < m; i++) + // { + // var l = currefer1.CreateOffset((i + x) * interval, -XYZ.BasisZ); + // if (i == m - 1) + // { + // l = currefer.CreateOffset((i - 1 + x) * interval, -XYZ.BasisZ); + // } + // curves.Add(l); + // } + //} - // curves.Add(l); - // } - //} - //else - //{ - // for (int i = 0; i < m; i++) - // { - // var l = currefer1.CreateOffset((i + x) * interval, -XYZ.BasisZ); - // if (i == m - 1) - // { - // l = currefer.CreateOffset((i - 1 + x) * interval, -XYZ.BasisZ); - // } - // curves.Add(l); - // } - //} + //var pts = GetIntersectPoints(curves); + //Plane pl = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, new XYZ()); + //foreach (var item in curves) + //{ + // ModelCurve model = doc.Create.NewModelCurve(item, SketchPlane.Create(doc, pl)); + //} - //var pts = GetIntersectPoints(curves); - //Plane pl = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, new XYZ()); - //foreach (var item in curves) - //{ - // ModelCurve model = doc.Create.NewModelCurve(item, SketchPlane.Create(doc, pl)); - //} + //foreach (var p in pts) + //{ + // var fi = doc.Create + // .NewFamilyInstance(p, symbol, baselevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); + // instances.Add(fi); + //} + //foreach (var fi in instances) + //{ + // var lp = fi.Location as LocationPoint; + // var p = lp.Point; + // foreach (var seg in segments) + // { + // var l = seg.GetCurve() as Line; + // if (l.Distance(p) - ((1 + rem) / 4 * interval) < 0.001) + // { + // if (l.Direction.X < 0.001) + // { + // fi.GetParameters("长度").FirstOrDefault().Set((1 + rem) / 2 * (interval - halfgap)); + // } + // else if (l.Direction.Y < 0.001) + // { + // fi.GetParameters("宽度").FirstOrDefault().Set((1 + rem) / 2 * (interval - halfgap)); + // } + // } + // else if (l.Distance(p) - ((1 + rem1) / 4 * interval) < 0.001) + // { + // if (l.Direction.X < 0.001) + // { + // fi.GetParameters("长度").FirstOrDefault().Set((1 + rem1) / 2 * (interval - halfgap)); + // } + // else if (l.Direction.Y < 0.001) + // { + // fi.GetParameters("宽度").FirstOrDefault().Set((1 + rem1) / 2 * (interval - halfgap)); + // } + // } + // if (true) + // { + // } + // } + //} - //foreach (var p in pts) - //{ - // var fi = doc.Create - // .NewFamilyInstance(p, symbol, baselevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); - // instances.Add(fi); - //} - //foreach (var fi in instances) - //{ - // var lp = fi.Location as LocationPoint; - // var p = lp.Point; - // foreach (var seg in segments) - // { - // var l = seg.GetCurve() as Line; - // if (l.Distance(p) - ((1 + rem) / 4 * interval) < 0.001) - // { - // if (l.Direction.X < 0.001) - // { - // fi.GetParameters("长度").FirstOrDefault().Set((1 + rem) / 2 * (interval - halfgap)); - // } - // else if (l.Direction.Y < 0.001) - // { - // fi.GetParameters("宽度").FirstOrDefault().Set((1 + rem) / 2 * (interval - halfgap)); - // } - // } - // else if (l.Distance(p) - ((1 + rem1) / 4 * interval) < 0.001) - // { - // if (l.Direction.X < 0.001) - // { - // fi.GetParameters("长度").FirstOrDefault().Set((1 + rem1) / 2 * (interval - halfgap)); - // } - // else if (l.Direction.Y < 0.001) - // { - // fi.GetParameters("宽度").FirstOrDefault().Set((1 + rem1) / 2 * (interval - halfgap)); - // } - // } - // if (true) - // { - // } - // } - //} + //Do Something. - //ModelCurve mc = doc.Create.NewModelCurve(); - //var geoelem = room.get_Geometry(new Options()); - //foreach (var geomObj in geoelem) - //{ - // Solid geomSolid = geomObj as Solid; - // if (null != geomSolid) - // { - // foreach (Face geomFace in geomSolid.Faces) - // { - // break; - // } - // break; - // } - //} - - //Do Something. - - #endregion MyRegion - - tg.Assimilate(); - } - catch (Autodesk.Revit.Exceptions.OperationCanceledException) - { - if (tg.GetStatus() == TransactionStatus.Started) - { - tg.RollBack(); - } - return Result.Cancelled; - } - } - return Result.Succeeded; + #endregion MyRegion + } + catch (Autodesk.Revit.Exceptions.OperationCanceledException) + { + if (tg.GetStatus() == TransactionStatus.Started) + { + tg.RollBack(); + } + return Result.Succeeded; + } + return Result.Succeeded; + }, "地面铺装"); } private List GetIntersectPoints(List curves) diff --git a/RookieStation/CmdPlaceLamps.cs b/RookieStation/CmdPlaceLamps.cs index d623c5d..0cd79ba 100644 --- a/RookieStation/CmdPlaceLamps.cs +++ b/RookieStation/CmdPlaceLamps.cs @@ -27,11 +27,11 @@ namespace RookieStation.PackAreaModule DocumentSet docset = uiapp.Application.Documents; Family family = null; FamilySymbol symbol; - double lrdistance = 0.0; - double fbdistance = 0.0; + double leftRightDistance = 0.0; + double frontDistance = 0.0; - var roomcounts = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).GetElementCount(); - if (roomcounts == 0) + var roomCount = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).GetElementCount(); + if (roomCount == 0) { TaskDialog.Show("温馨提示", "项目中当前没有房间"); return Result.Cancelled; @@ -40,8 +40,8 @@ namespace RookieStation.PackAreaModule if (placeLamps.DialogResult == true) { - lrdistance = placeLamps.LRDistance / 304.8; - fbdistance = placeLamps.LRDistance / 304.8; + leftRightDistance = placeLamps.LeftRightDistance / 304.8; + frontDistance = placeLamps.FrontDistance / 304.8; } else { @@ -49,195 +49,186 @@ namespace RookieStation.PackAreaModule } double interval = 2000 / 304.8; - using (TransactionGroup tg = new TransactionGroup(doc, "布置灯具")) - { - try - { - var v = new FilteredElementCollector(doc).OfClass(typeof(View)) - .Cast() - .FirstOrDefault(x => x.ViewType == ViewType.FloorPlan && x.GenLevel.Elevation == 0); + return doc.InvokeGroup(tg => + { + try + { + var v = new FilteredElementCollector(doc).OfClass(typeof(View)) + .Cast() + .FirstOrDefault(x => x.ViewType == ViewType.FloorPlan && x.GenLevel.Elevation == 0); - var baselevel = new FilteredElementCollector(doc) - .OfClass(typeof(Level)) - .Cast() - .FirstOrDefault(x => x.Elevation == 0); + var baseLevel = new FilteredElementCollector(doc) + .OfClass(typeof(Level)) + .Cast() + .FirstOrDefault(x => x.Elevation == 0); - List modelCurveIds = new List(); - tg.Start(); - if (uidoc.ActiveView.ViewType != ViewType.FloorPlan) - { - uidoc.RequestViewChange(v); - } + List modelCurveIds = new List(); + if (uidoc.ActiveView.ViewType != ViewType.FloorPlan) + { + uidoc.RequestViewChange(v); + } - SelectFilter selfilter = new SelectFilter(); - Reference roomrefer = uidoc.Selection.PickObject(ObjectType.Element, selfilter, "请选择房间"); - Room room = doc.GetElement(roomrefer) as Room; + SelectFilter roomFilter = new SelectFilter(); + Reference roomReference = uidoc.Selection.PickObject(ObjectType.Element, roomFilter, "请选择房间"); + Room room = doc.GetElement(roomReference) as Room; - var roompoint = RsRevitUtils.GetXYZByElement(room); + var roomLocationPoint = RsRevitUtils.GetLocationPointByElement(room); - IList segments = room.GetBoundarySegments(new SpatialElementBoundaryOptions()).FirstOrDefault(); + IList segments = room.GetBoundarySegments(new SpatialElementBoundaryOptions()).FirstOrDefault(); - using (Transaction ts = new Transaction(doc, "模型线创建")) - { - ts.Start(); - foreach (var seg in segments) - { - Curve cur = seg.GetCurve(); - Plane plane = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, new XYZ()); - var mc = doc.Create.NewModelCurve(cur, SketchPlane.Create(doc, plane)); - modelCurveIds.Add(mc.Id); - } + doc.Invoke(ts => + { + foreach (var segment in segments) + { + Curve curve = segment.GetCurve(); + Plane plane = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, new XYZ()); + var mc = doc.Create.NewModelCurve(curve, SketchPlane.Create(doc, plane)); + modelCurveIds.Add(mc.Id); + } + }, "模型线创建"); - ts.Commit(); - } - //Reference edge = uidoc.Selection.PickObject(ObjectType.Edge, "请选择边界"); - SelectFilter mlfilter = new SelectFilter(); - Reference refline = uidoc.Selection.PickObject(ObjectType.Element, mlfilter, "请选择基准边线"); - //模型线选取 - var ml = doc.GetElement(refline) as ModelLine; - Line line = ml.GeometryCurve as Line; - Line line1 = RsRevitUtils.GetLongestSegmentLine(segments, line); - //var m = doc.GetElement(refer.ElementId); + //Reference edge = uidoc.Selection.PickObject(ObjectType.Edge, "请选择边界"); + SelectFilter mlfilter = new SelectFilter(); + Reference referline = uidoc.Selection.PickObject(ObjectType.Element, mlfilter, "请选择基准边线"); + //模型线选取 + var ml = doc.GetElement(referline) as ModelLine; + Line line = ml.GeometryCurve as Line; + Line line1 = RsRevitUtils.GetLongestSegmentLine(segments, line); + //var m = doc.GetElement(refer.ElementId); - XYZ basepoint = uidoc.Selection.PickPoint(UserConstant.SnapAll, "请选择基准点(位于基准线上)"); - double alength = basepoint.DistanceTo(line.GetEndPoint(0)) + basepoint.DistanceTo(line.GetEndPoint(1)); - if (line.Length - alength > 0.001) - { - System.Windows.MessageBox.Show("请选择基准线上的点", "温馨提示"); - return Result.Cancelled; - } - //if (basepoint.IsAlmostEqualTo(ml.GeometryCurve.GetEndPoint(0)) || basepoint.IsAlmostEqualTo(ml.GeometryCurve.GetEndPoint(1))) - //{ - //} - var endp1 = line.GetEndPoint(0); - var endp2 = line.GetEndPoint(1); - var v1 = endp1 - basepoint; - var v2 = endp2 - basepoint; - var v0 = roompoint - basepoint; - List curves = new List(); - List instances = new List(); - //Curve currefer = null; - //Curve currefer1 = null; + XYZ basePoint = uidoc.Selection.PickPoint(UserConstant.SnapAll, "请选择基准点(位于基准线上)"); + double lengthCount = basePoint.DistanceTo(line.GetEndPoint(0)) + basePoint.DistanceTo(line.GetEndPoint(1)); + if (line.Length - lengthCount > 0.001) + { + System.Windows.MessageBox.Show("请选择基准线上的点", "温馨提示"); + return Result.Cancelled; + } + //if (basepoint.IsAlmostEqualTo(ml.GeometryCurve.GetEndPoint(0)) || basepoint.IsAlmostEqualTo(ml.GeometryCurve.GetEndPoint(1))) + //{ + //} + var endpoint1 = line.GetEndPoint(0); + var endpoint2 = line.GetEndPoint(1); + var v1 = endpoint1 - basePoint; + var v2 = endpoint2 - basePoint; + var v0 = roomLocationPoint - basePoint; + List curves = new List(); + List instances = new List(); + //Curve currefer = null; + //Curve currefer1 = null; - List pts = new List(); - List lastps = new List(); - XYZ zdir1 = null; - XYZ zdir2 = null; - XYZ offestvector = null; + List pts = new List(); + List lastps = new List(); + XYZ zdir1 = null; + XYZ zdir2 = null; + XYZ offestVector = null; - if (!v1.IsAlmostEqualTo(XYZ.Zero) && endp1.DistanceTo(basepoint) > interval) - { - //if (endp1.DistanceTo(basepoint) < interval) - //{ - // System.Windows.MessageBox.Show("基准点与基准线端点距离太近"); - // return Result.Cancelled; - //} - zdir1 = v1.CrossProduct(v0).Normalize(); - //偏移的方向,直线的侧方向 - offestvector = zdir1.CrossProduct(v1).Normalize(); - Line l1 = Line.CreateBound(basepoint, line.GetEndPoint(0)); + if (!v1.IsAlmostEqualTo(XYZ.Zero) && endpoint1.DistanceTo(basePoint) > interval) + { + //if (endp1.DistanceTo(basepoint) < interval) + //{ + // System.Windows.MessageBox.Show("基准点与基准线端点距离太近"); + // return Result.Cancelled; + //} + zdir1 = v1.CrossProduct(v0).Normalize(); + //偏移的方向,直线的侧方向 + offestVector = zdir1.CrossProduct(v1).Normalize(); + Line l1 = Line.CreateBound(basePoint, line.GetEndPoint(0)); - for (int i = 0; i < 1000; i++) - { - var parameter = i * interval; - if (!l1.IsInside(parameter + lrdistance + interval / 2)) - { - break; - } - XYZ p = l1.Evaluate(parameter, false); - XYZ finalpoint = p + (l1.Direction * interval / 2) + (offestvector * fbdistance); - if (v2.IsAlmostEqualTo(XYZ.Zero)) - { - finalpoint = p + (l1.Direction * lrdistance) + (offestvector * fbdistance); - } + for (int i = 0; i < 1000; i++) + { + var parameter = i * interval; + if (!l1.IsInside(parameter + leftRightDistance + interval / 2)) + { + break; + } + XYZ p = l1.Evaluate(parameter, false); + XYZ finalPoint = p + (l1.Direction * interval / 2) + (offestVector * frontDistance); + if (v2.IsAlmostEqualTo(XYZ.Zero)) + { + finalPoint = p + (l1.Direction * leftRightDistance) + (offestVector * frontDistance); + } - pts.Add(finalpoint); - } - } + pts.Add(finalPoint); + } + } - if (!v2.IsAlmostEqualTo(XYZ.Zero) && endp2.DistanceTo(basepoint) > interval) - { - //if (endp2.DistanceTo(basepoint) < length) - //{ - // System.Windows.MessageBox.Show("基准点与基准线端点距离太近"); - // return Result.Cancelled; - //} - zdir2 = v2.CrossProduct(v0).Normalize(); - offestvector = zdir2.CrossProduct(v2).Normalize(); - var x = zdir2.CrossProduct(v2); - Line l2 = Line.CreateBound(basepoint, line.GetEndPoint(1)); + if (!v2.IsAlmostEqualTo(XYZ.Zero) && endpoint2.DistanceTo(basePoint) > interval) + { + //if (endp2.DistanceTo(basepoint) < length) + //{ + // System.Windows.MessageBox.Show("基准点与基准线端点距离太近"); + // return Result.Cancelled; + //} + zdir2 = v2.CrossProduct(v0).Normalize(); + offestVector = zdir2.CrossProduct(v2).Normalize(); + var x = zdir2.CrossProduct(v2); + Line l2 = Line.CreateBound(basePoint, line.GetEndPoint(1)); - for (int i = 0; i < 1000; i++) - { - var parameter = i * interval; - if (!l2.IsInside(parameter + lrdistance + interval / 2)) - { - break; - } - XYZ p = l2.Evaluate(parameter, false); - //附加的基准线的水平垂直偏移距离 - var finalpoint = p + (l2.Direction * interval / 2) + (offestvector * fbdistance); - if (v1.IsAlmostEqualTo(XYZ.Zero)) - { - finalpoint = p + (l2.Direction * lrdistance) + (offestvector * fbdistance); - } + for (int i = 0; i < 1000; i++) + { + var parameter = i * interval; + if (!l2.IsInside(parameter + leftRightDistance + interval / 2)) + { + break; + } + XYZ p = l2.Evaluate(parameter, false); + //附加的基准线的水平垂直偏移距离 + var finalpoint = p + (l2.Direction * interval / 2) + (offestVector * frontDistance); + if (v1.IsAlmostEqualTo(XYZ.Zero)) + { + finalpoint = p + (l2.Direction * leftRightDistance) + (offestVector * frontDistance); + } - pts.Add(finalpoint); - } - //var lastl2 = pts.Last().DistanceTo(endp2); - } + pts.Add(finalpoint); + } + //var lastl2 = pts.Last().DistanceTo(endp2); + } - using (Transaction trans = new Transaction(doc, "载入布置灯具")) - { - trans.Start(); - //删除模型线 - doc.Delete(modelCurveIds); - family = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "Lamp\\成品吊灯.rfa"); - ElementId symbolId = family.GetFamilySymbolIds().FirstOrDefault(); - symbol = doc.GetElement(symbolId) as FamilySymbol; - symbol.Activate(); - foreach (var p in pts) - { - var fi = doc.Create - .NewFamilyInstance(p, symbol, baselevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); - instances.Add(fi); - } - foreach (var p in lastps) - { - var fi = doc.Create - .NewFamilyInstance(p, symbol, baselevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); - instances.Add(fi); - } - trans.Commit(); - } - using (Transaction trans = new Transaction(doc, "复制灯具")) - { - trans.Start(); - for (int i = 0; i < instances.Count; i++) - { - FamilyInstance fi = instances[i]; - int num = (int)Math.Floor((line1.Length - 2 * fbdistance) / interval); - double rem = line1.Length - num * interval; - for (int j = 1; j <= num; j++) - { - ElementTransformUtils.CopyElement(doc, fi.Id, offestvector * interval * j); - } - } - trans.Commit(); - } - - tg.Assimilate(); - } - catch (Autodesk.Revit.Exceptions.OperationCanceledException) - { - if (tg.GetStatus() == TransactionStatus.Started) - { - tg.RollBack(); - } - return Result.Cancelled; - } - } - return Result.Succeeded; + doc.Invoke(ts => + { + //删除模型线 + doc.Delete(modelCurveIds); + family = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "Lamp\\成品吊灯.rfa"); + ElementId symbolId = family.GetFamilySymbolIds().FirstOrDefault(); + symbol = doc.GetElement(symbolId) as FamilySymbol; + symbol.Activate(); + foreach (var p in pts) + { + var fi = doc.Create + .NewFamilyInstance(p, symbol, baseLevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); + instances.Add(fi); + } + foreach (var p in lastps) + { + var fi = doc.Create + .NewFamilyInstance(p, symbol, baseLevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); + instances.Add(fi); + } + }, "载入布置灯具"); + doc.Invoke(ts => + { + for (int i = 0; i < instances.Count; i++) + { + FamilyInstance fi = instances[i]; + int num = (int)Math.Floor((line1.Length - 2 * frontDistance) / interval); + double rem = line1.Length - num * interval; + for (int j = 1; j <= num; j++) + { + ElementTransformUtils.CopyElement(doc, fi.Id, offestVector * interval * j); + } + } + }, "复制灯具"); + } + catch (Autodesk.Revit.Exceptions.OperationCanceledException) + { + //if (tg.GetStatus() == TransactionStatus.Started) + //{ + // tg.RollBack(); + //} + return Result.Succeeded; + } + return Result.Succeeded; + }, "布置灯具"); } } } \ No newline at end of file diff --git a/RookieStation/CmdPlaceReceptionArea.cs b/RookieStation/CmdPlaceReceptionArea.cs index 1b3130f..116ed0d 100644 --- a/RookieStation/CmdPlaceReceptionArea.cs +++ b/RookieStation/CmdPlaceReceptionArea.cs @@ -49,93 +49,96 @@ namespace RookieStation.ShippingAreaModule WpfReceptionArea receptionAreaPlacement = CommonUtils.GenerateWindow(); //初始值 //基层厚度 - double base_layer_thickness = 15 / 304.8; + double baseLayerThickness = 15 / 304.8; //踢脚线高度 - double Skirting_line_height = 50 / 304.8; + double skirtingLineHeight = 50 / 304.8; //踢脚线厚度 - double Skirting_line_thickness = 1.2 / 304.8; + double skirtingLineThickness = 1.2 / 304.8; //铝塑板长度 - double aluminum_plastic_panel_length = 1220 / 304.8; + double aluminumPlasticPanelLength = 0; //铝塑板高度 - double aluminum_plastic_panel_height = 2400 / 304.8; + double aluminumPlasticPanelHeight = 0; //铝塑板厚度 - double aluminum_plastic_panel_thickness = 3 / 304.8; + double aluminumPlasticPanelThickness = 3 / 304.8; //分缝 double gap = 2 / 304.8; //灰色乳胶漆厚度 - double grey_emulsion_paint_width = 1 / 304.8; + double greyEmulsionPaintWidth = 1 / 304.8; //发光字族类型 - string glow_text_symbol; + string glowTextSymbol; //墙间距 - double lamps_wall_distance = 900 / 304.8; + double lampsWallDistance = 0; //灯间距 - double lamps_interval = 900 / 304.8; + double lampsInterval = 0; + //灯高度 + double lampsHeight = 0; if (receptionAreaPlacement.DialogResult == true) { //铝塑板长度 - aluminum_plastic_panel_length = receptionAreaPlacement.aluminump_lastic_panel_length / 304.8; + aluminumPlasticPanelLength = receptionAreaPlacement.AluminumpLasticPanelLength / 304.8; //铝塑板高度 - aluminum_plastic_panel_height = receptionAreaPlacement.aluminump_lastic_panel_height / 304.8; + aluminumPlasticPanelHeight = receptionAreaPlacement.AluminumpLasticPanelHeight / 304.8; //分缝 - gap = receptionAreaPlacement.aluminump_lastic_panel_gap / 304.8; + gap = receptionAreaPlacement.AluminumpLasticPanelGgap / 304.8; - glow_text_symbol = receptionAreaPlacement.glow_text_symbol; + glowTextSymbol = receptionAreaPlacement.GlowTextSymbol; - lamps_wall_distance = receptionAreaPlacement.lamp_wall_distance / 304.8; - lamps_interval = receptionAreaPlacement.lamps_interval / 304.8; + lampsWallDistance = receptionAreaPlacement.LampWallDistance / 304.8; + lampsInterval = receptionAreaPlacement.LampsInterval / 304.8; + lampsHeight = receptionAreaPlacement.LampsHeight / 304.8; } else { return Result.Cancelled; } - Level baselevel = uidoc.ActiveView.GenLevel; + Level baseLevel = uidoc.ActiveView.GenLevel; Family family = null; FamilySymbol symbol; return doc.InvokeGroup(tg => { try { - FamilySymbol linesymbol = RsRevitUtils.GetGuideSymbol(doc); + FamilySymbol guideSymbol = RsRevitUtils.GetGuideSymbol(doc); eleIdsAdded.Clear(); uiapp.Application.DocumentChanged += Application_DocumentChanged; - uidoc.PromptForFamilyInstancePlacement(linesymbol); + uidoc.PromptForFamilyInstancePlacement(guideSymbol); uiapp.Application.DocumentChanged -= Application_DocumentChanged; //在此处无法取消订阅 //uiapp.Application.DocumentChanged -= Application_DocumentChanged; } catch (Autodesk.Revit.Exceptions.OperationCanceledException) { - var interval = gap + aluminum_plastic_panel_length; + var interval = gap + aluminumPlasticPanelLength; if (eleIdsAdded.Count == 0) { return Result.Cancelled; } - Line refer_line = RsRevitUtils.GetGuideGeometryAndDeleteGuide(doc, eleIdsAdded); + Line referline = RsRevitUtils.GetGuideGeometryAndDeleteGuide(doc, eleIdsAdded); uiapp.Application.DocumentChanged -= Application_DocumentChanged; - double backgroundwall_length = refer_line.Length; - if (backgroundwall_length < 1500 / 304.8) + double backgroundWallLength = referline.Length; + if (backgroundWallLength < 1500 / 304.8) { TaskDialog.Show("温馨提示", "距离太接"); return Result.Cancelled; } - List wallids = new List(); - WallType base_layer_type = null; - base_layer_thickness = RsRevitUtils.GetWallWidthByWallTypeName(doc, "阻燃板", out base_layer_type); + List wallIds = new List(); + WallType baseLayerType = null; + baseLayerThickness = RsRevitUtils.GetWallWidthByWallTypeName(doc, "阻燃板", out baseLayerType); - WallType grey_emulsion_paint_type = null; - grey_emulsion_paint_width = RsRevitUtils.GetWallWidthByWallTypeName(doc, "灰色乳胶漆", out grey_emulsion_paint_type); + WallType greyEmulsionPaintType = null; + greyEmulsionPaintWidth = RsRevitUtils.GetWallWidthByWallTypeName(doc, "灰色乳胶漆", out greyEmulsionPaintType); - WallType aluminum_plastic_panel_type = null; - aluminum_plastic_panel_thickness = RsRevitUtils.GetWallWidthByWallTypeName(doc, "铝塑板", out aluminum_plastic_panel_type); + WallType aluminumPlasticPanelType = null; + aluminumPlasticPanelThickness = RsRevitUtils.GetWallWidthByWallTypeName(doc, "铝塑板", out aluminumPlasticPanelType); - WallType Skirting_line_type = null; - Skirting_line_thickness = RsRevitUtils.GetWallWidthByWallTypeName(doc, "踢脚线", out Skirting_line_type); + WallType skirtingLineType = null; + skirtingLineThickness = RsRevitUtils.GetWallWidthByWallTypeName(doc, "踢脚线", out skirtingLineType); //铝塑板块数 - int n = (int)Math.Floor(refer_line.Length / interval); - double rem = refer_line.Length % (gap + aluminum_plastic_panel_length); - if (base_layer_type == null || aluminum_plastic_panel_type == null || Skirting_line_type == null || grey_emulsion_paint_type == null) + int n = (int)Math.Floor(referline.Length / interval); + double rem = referline.Length % (gap + aluminumPlasticPanelLength); + if (baseLayerType == null || aluminumPlasticPanelType == null || skirtingLineType == null || greyEmulsionPaintType == null) { TaskDialog.Show("温馨提示", "需要新建装饰所需的墙类型,类型名称需分别包含阻燃板,灰色乳胶漆,铝塑板,踢脚线"); return Result.Cancelled; @@ -145,76 +148,51 @@ namespace RookieStation.ShippingAreaModule //长度不满足设置的铝塑板长度时 if (n == 0) { - var offestline = refer_line.CreateOffset(aluminum_plastic_panel_thickness / 2 + base_layer_thickness, -XYZ.BasisZ); - var wall = Wall.Create(doc, offestline, aluminum_plastic_panel_type.Id, doc.ActiveView.GenLevel.Id, aluminum_plastic_panel_height, Skirting_line_height, false, false); - wallids.Add(wall.Id); + var offestline = referline.CreateOffset(aluminumPlasticPanelThickness / 2 + baseLayerThickness, -XYZ.BasisZ); + var wall = Wall.Create(doc, offestline, aluminumPlasticPanelType.Id, doc.ActiveView.GenLevel.Id, aluminumPlasticPanelHeight, skirtingLineHeight, false, false); + wallIds.Add(wall.Id); } else { for (int i = 0; i < n + 1; i++) { - var startpoint = refer_line.Evaluate(i * interval, false); - var endpoint = refer_line.Evaluate(((i + 1) * interval) - gap, false); + var startpoint = referline.Evaluate(i * interval, false); + var endpoint = referline.Evaluate(((i + 1) * interval) - gap, false); if (i == n) { - endpoint = refer_line.GetEndPoint(1); + endpoint = referline.GetEndPoint(1); } Line line = Line.CreateBound(startpoint, endpoint); - var offestline = line.CreateOffset(aluminum_plastic_panel_thickness / 2 + base_layer_thickness, -XYZ.BasisZ); - var wall = Wall.Create(doc, offestline, aluminum_plastic_panel_type.Id, doc.ActiveView.GenLevel.Id, aluminum_plastic_panel_height, Skirting_line_height, false, false); + var offestline = line.CreateOffset(aluminumPlasticPanelThickness / 2 + baseLayerThickness, -XYZ.BasisZ); + var wall = Wall.Create(doc, offestline, aluminumPlasticPanelType.Id, doc.ActiveView.GenLevel.Id, aluminumPlasticPanelHeight, skirtingLineHeight, false, false); //不允许连接 WallUtils.DisallowWallJoinAtEnd(wall, 0); //curves.Add() - wallids.Add(wall.Id); + wallIds.Add(wall.Id); } } - var skirting_offestline = refer_line.CreateOffset(Skirting_line_thickness / 2 + base_layer_thickness, -XYZ.BasisZ); - var skirtingwall = Wall.Create(doc, skirting_offestline, Skirting_line_type.Id, doc.ActiveView.GenLevel.Id, Skirting_line_height, 0, false, false); - wallids.Add(skirtingwall.Id); + var skirtingOffestLine = referline.CreateOffset(skirtingLineThickness / 2 + baseLayerThickness, -XYZ.BasisZ); + var skirtingwall = Wall.Create(doc, skirtingOffestLine, skirtingLineType.Id, doc.ActiveView.GenLevel.Id, skirtingLineHeight, 0, false, false); + wallIds.Add(skirtingwall.Id); - var base_layer_offestline = refer_line.CreateOffset(base_layer_thickness / 2, -XYZ.BasisZ); - var baselayerwall = Wall.Create(doc, base_layer_offestline, base_layer_type.Id, doc.ActiveView.GenLevel.Id, UserConstant.Height / 304.8, 0, false, false); - wallids.Add(baselayerwall.Id); + var baseLayerOffestLine = referline.CreateOffset(baseLayerThickness / 2, -XYZ.BasisZ); + var baseLayerWall = Wall.Create(doc, baseLayerOffestLine, baseLayerType.Id, doc.ActiveView.GenLevel.Id, UserConstant.Height / 304.8, 0, false, false); + wallIds.Add(baseLayerWall.Id); //高度大于3000才有灰色乳胶漆 if (UserConstant.Height > 3000) { - double baseheight = aluminum_plastic_panel_height + Skirting_line_height; - var grey_emulsion_paint_offestline = refer_line.CreateOffset(base_layer_thickness + grey_emulsion_paint_width / 2, -XYZ.BasisZ); - var greypaintwall = Wall.Create(doc, grey_emulsion_paint_offestline, grey_emulsion_paint_type.Id, doc.ActiveView.GenLevel.Id, UserConstant.Height / 304.8 - baseheight, baseheight, false, false); - wallids.Add(greypaintwall.Id); + double baseHeight = aluminumPlasticPanelHeight + skirtingLineHeight; + var greyEmulsionPaintOffestLine = referline.CreateOffset(baseLayerThickness + greyEmulsionPaintWidth / 2, -XYZ.BasisZ); + Wall greyPaintWall = Wall.Create(doc, greyEmulsionPaintOffestLine, greyEmulsionPaintType.Id, doc.ActiveView.GenLevel.Id, UserConstant.Height / 304.8 - baseHeight, baseHeight, false, false); + wallIds.Add(greyPaintWall.Id); } doc.Regenerate(); - doc.Create.NewGroup(wallids); + doc.Create.NewGroup(wallIds); }, "背景墙创建"); - //SelectFilter wallfilter = new SelectFilter(); - //var wallrefer = uidoc.Selection.PickObject(ObjectType.Element, wallfilter, "请选择作为背景墙的墙体"); - //var wall = doc.GetElement(wallrefer) as Wall; - - //WallFaceSelectionFilter selfilter = new WallFaceSelectionFilter(wall.Id); - //var facerefer = uidoc.Selection.PickObject(ObjectType.Face, selfilter, "请选择要装饰的墙面"); - - //PlanarFace pf = wall.GetGeometryObjectFromReference(facerefer) as PlanarFace; - - //XYZ normal = pf.FaceNormal; - //XYZ p1 = uidoc.Selection.PickObject(ObjectType.PointOnElement, selfilter, "请选取背景墙左侧端点").GlobalPoint; - - //XYZ p2 = uidoc.Selection.PickObject(ObjectType.PointOnElement, selfilter, "请选取背景墙右侧端点").GlobalPoint; - - //XYZ p1 = uidoc.Selection.PickPoint(UserConstant.SnapAll, "请选取背景墙左侧端点"); - //XYZ p2 = uidoc.Selection.PickPoint(UserConstant.SnapAll, "请选取背景墙右侧端点"); - - //两点的水平距离 - - //if (UserConstant.Height / 3 * 2 < 2200) - //{ - // TaskDialog.Show("温馨提示", "层高设置有误"); - // return Result.Cancelled; - //} - #region 菜鸟使命布置 FamilyInstance signage = null; @@ -225,27 +203,22 @@ namespace RookieStation.ShippingAreaModule symbol = doc.GetElement(symbolId) as FamilySymbol; symbol.Activate(); - //var x = family.FamilyPlacementType; - //signage = doc.Create.NewFamilyInstance(facerefer, p2 + new XYZ(0, 0, height + 100 / 304.8), symbol, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); + var endPoint = referline.GetEndPoint(0); - var endpoint = refer_line.GetEndPoint(0); - - endpoint += (Skirting_line_height + aluminum_plastic_panel_height) * XYZ.BasisZ; - signage = doc.Create.NewFamilyInstance(endpoint, symbol, StructuralType.NonStructural); + endPoint += (skirtingLineHeight + aluminumPlasticPanelHeight) * XYZ.BasisZ; + signage = doc.Create.NewFamilyInstance(endPoint, symbol, StructuralType.NonStructural); //标准面要朝上,族要面向背侧 - - //symbol.GetParameters("背景墙长度").FirstOrDefault().Set(distance); }, "菜鸟的使命"); doc.Invoke(ts => { //族的正面要超前 - RsRevitUtils.AdjustInstance(doc, signage, refer_line, grey_emulsion_paint_width + base_layer_thickness); + RsRevitUtils.AdjustInstance(doc, signage, referline, greyEmulsionPaintWidth + baseLayerThickness); }, "调整菜鸟使命"); #endregion 菜鸟使命布置 - double reception_length = refer_line.Length / 3 * 2; - double reception_wall_distance = 1000 / 304.8; + double receptionLength = referline.Length / 3 * 2; + double receptionWallDistance = 1000 / 304.8; FamilyInstance reception = null; doc.Invoke(ts => { @@ -253,48 +226,48 @@ namespace RookieStation.ShippingAreaModule ElementId symbolId = family.GetFamilySymbolIds().FirstOrDefault(); symbol = doc.GetElement(symbolId) as FamilySymbol; symbol.Activate(); - var wall_center_point = refer_line.Evaluate(0.5, true); + var wallCenterPoint = referline.Evaluate(0.5, true); - reception = doc.Create.NewFamilyInstance(wall_center_point, symbol, baselevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); + reception = doc.Create.NewFamilyInstance(wallCenterPoint, symbol, baseLevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); - symbol.GetParameters("台面长度").FirstOrDefault().Set(reception_length); + symbol.GetParameters("台面长度").FirstOrDefault().Set(receptionLength); //symbol.GetParameters("台面长度").FirstOrDefault().AsDouble(); }, "接待台布置"); doc.Invoke(ts => { - RsRevitUtils.AdjustInstance(doc, reception, refer_line, reception_wall_distance); + RsRevitUtils.AdjustInstance(doc, reception, referline, receptionWallDistance); }, "调整接待台"); FamilyInstance logo = null; doc.Invoke(ts => { family = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "Sign\\菜鸟LOGO.rfa"); - ElementId symbolId = family.GetFamilySymbolIds().FirstOrDefault(id => doc.GetElement(id).Name == glow_text_symbol); + ElementId symbolId = family.GetFamilySymbolIds().FirstOrDefault(id => doc.GetElement(id).Name == glowTextSymbol); symbol = doc.GetElement(symbolId) as FamilySymbol; symbol.Activate(); - var wall_center_point = refer_line.Evaluate(0.5, true); + var wallCenterPoint = referline.Evaluate(0.5, true); - logo = doc.Create.NewFamilyInstance(wall_center_point, symbol, baselevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); + logo = doc.Create.NewFamilyInstance(wallCenterPoint, symbol, baseLevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); //symbol.GetParameters("背景墙长度").FirstOrDefault().Set(reception_length); //width = symbol.GetParameters("台面宽度").FirstOrDefault().AsDouble(); }, "菜鸟LOG布置"); doc.Invoke(ts => { - RsRevitUtils.AdjustInstance(doc, logo, refer_line, aluminum_plastic_panel_thickness + base_layer_thickness); + RsRevitUtils.AdjustInstance(doc, logo, referline, aluminumPlasticPanelThickness + baseLayerThickness); }, "调整lOGO"); doc.Invoke(ts => { - family = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "Lamp\\圆形吊灯.rfa"); + family = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "Lamp\\吊灯.rfa"); ElementId symbolId = family.GetFamilySymbolIds().FirstOrDefault(); symbol = doc.GetElement(symbolId) as FamilySymbol; symbol.Activate(); - var normal_direction = refer_line.Direction; - List lamp_location_points = new List(); - var lamps_location_line = refer_line.CreateOffset(lamps_wall_distance, -XYZ.BasisZ); - var center_point = lamps_location_line.Evaluate(0.5, true); - n = (int)Math.Floor(backgroundwall_length / lamps_interval); + var referlineDirection = referline.Direction; + List lampLocationPoints = new List(); + var lampsLocationLine = referline.CreateOffset(lampsWallDistance, -XYZ.BasisZ); + var centerPoint = lampsLocationLine.Evaluate(0.5, true); + n = (int)Math.Floor(backgroundWallLength / lampsInterval); //单侧的数量 int m = (int)Math.Floor((n + 1.0) / 2); if ((n + 1) % 2 == 0) @@ -302,48 +275,34 @@ namespace RookieStation.ShippingAreaModule //开始间隔为0.5 for (int i = 0; i < m; i++) { - XYZ p = center_point.Add(normal_direction * (i + 0.5) * lamps_interval); - XYZ reversep = center_point.Add(-normal_direction * (i + 0.5) * lamps_interval); + XYZ p = centerPoint.Add(referlineDirection * (i + 0.5) * lampsInterval) + XYZ.BasisZ * lampsHeight; + XYZ reversePoint = centerPoint.Add(-referlineDirection * (i + 0.5) * lampsInterval) + XYZ.BasisZ * lampsHeight; - lamp_location_points.Add(p); - lamp_location_points.Add(reversep); + lampLocationPoints.Add(p); + lampLocationPoints.Add(reversePoint); } - foreach (XYZ p in lamp_location_points) + foreach (XYZ p in lampLocationPoints) { - doc.Create.NewFamilyInstance(p, symbol, baselevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); + doc.Create.NewFamilyInstance(p, symbol, baseLevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); } } else { - lamp_location_points.Add(center_point); + lampLocationPoints.Add(centerPoint); //i=0时居中,不在单侧,开始间隔为1 for (int i = 0; i < m; i++) { - XYZ p = center_point.Add(normal_direction * (i + 1) * lamps_interval); - XYZ reversep = center_point.Add(-normal_direction * (i + 1) * lamps_interval); - lamp_location_points.Add(p); - lamp_location_points.Add(reversep); + XYZ p = centerPoint.Add(referlineDirection * (i + 1) * lampsInterval); + XYZ reversePoint = centerPoint.Add(-referlineDirection * (i + 1) * lampsInterval); + lampLocationPoints.Add(p); + lampLocationPoints.Add(reversePoint); } - foreach (XYZ p in lamp_location_points) + foreach (XYZ p in lampLocationPoints) { - doc.Create.NewFamilyInstance(p, symbol, baselevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); + doc.Create.NewFamilyInstance(p, symbol, baseLevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); } } }, "吊灯布置"); - - //doc.Invoke(ts => - //{ - // if (backgroundwall.CanFlipFacing && backgroundwall.CanFlipHand && !backgroundwall.FacingOrientation.IsAlmostEqualTo(normal)) - // { - // backgroundwall.flipFacing(); - // backgroundwall.flipHand(); - // } - // if (frontdesk.CanFlipFacing && backgroundwall.CanFlipHand && !frontdesk.FacingOrientation.IsAlmostEqualTo(normal)) - // { - // frontdesk.flipFacing(); - // frontdesk.flipHand(); - // } - //}, "调整"); } return Result.Succeeded; @@ -392,37 +351,17 @@ namespace RookieStation.ShippingAreaModule private Reference GetWallSideFaceReference(Wall wall, XYZ normal) { - var facerefer = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Interior).FirstOrDefault(); - var facerefer1 = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Exterior).FirstOrDefault(); + var interFaceReference = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Interior).FirstOrDefault(); + var exterFaceReference = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Exterior).FirstOrDefault(); - PlanarFace pf = wall.GetGeometryObjectFromReference(facerefer) as PlanarFace; + PlanarFace pf = wall.GetGeometryObjectFromReference(interFaceReference) as PlanarFace; if (pf.FaceNormal.IsAlmostEqualTo(normal)) { - return facerefer; + return interFaceReference; } else { - return facerefer1; - } - } - - public class WallFaceSelectionFilter : ISelectionFilter - { - private ElementId eid = null; - - public WallFaceSelectionFilter(ElementId elementId) - { - eid = elementId; - } - - public bool AllowElement(Element element) - { - return element is Wall && eid == element.Id; - } - - public bool AllowReference(Reference refer, XYZ point) - { - return true; + return exterFaceReference; } } } diff --git a/RookieStation/CmdPlaceShelves.cs b/RookieStation/CmdPlaceShelves.cs index 6d7f209..b03451a 100644 --- a/RookieStation/CmdPlaceShelves.cs +++ b/RookieStation/CmdPlaceShelves.cs @@ -73,126 +73,126 @@ namespace RookieStation.PackAreaModule { return Result.Cancelled; } - Line refer_line = RsRevitUtils.GetGuideGeometryAndDeleteGuide(doc, eleIdsAdded); + Line referline = RsRevitUtils.GetGuideGeometryAndDeleteGuide(doc, eleIdsAdded); uiapp.Application.DocumentChanged -= Application_DocumentChanged; //始终位于左侧,Z轴朝上 - var zaxis = XYZ.BasisZ; - Family shelf_family = null; - FamilySymbol shelf_symbol = null; - double shelf_spacing = vm.Spacing / 304.8; + var zAxis = XYZ.BasisZ; + Family shelfFamily = null; + FamilySymbol shelfSymbol = null; + double shelfSpacing = vm.ShelfSpacing / 304.8; //通道宽度 - double passage_width = vm.PassageWidth / 304.8; - double parallel_referline_offest = vm.ParalelReferOffest / 304.8; - double vertical_referline_offest = vm.VerticalReferOffest / 304.8; + double passageWidth = vm.PassageWidth / 304.8; + double parallelReferlineOffest = vm.ParallelReferlineOffest / 304.8; + double verticalReferlineOffest = vm.VerticalReferlineOffest / 304.8; for (int i = 0; i < shelves.Count; i++) { //List all_points = new List(); - List first_row_points = new List(); + List firstRowPoints = new List(); Shelf shelf = shelves[i]; - double shelf_width = shelf.Width / 304.8; - double line_parameter = 0.0; + double shelfWidth = shelf.Width / 304.8; + double lineParameter = 0.0; int n = 100;//循环次数 - XYZ p = XYZ.Zero; + XYZ pointOnReferline = XYZ.Zero; - if (parallel_referline_offest < 0.001)//起点无间距 + if (parallelReferlineOffest < 0.001)//起点无间距 { for (int j = 0; j < n; j++) { - if (!refer_line.IsInside((line_parameter + shelf_width))) + if (!referline.IsInside((lineParameter + shelfWidth))) { break; } if (j % 2 == 0) { - p = refer_line.Evaluate(line_parameter, false); - line_parameter += shelf_spacing + shelf_width; + pointOnReferline = referline.Evaluate(lineParameter, false); + lineParameter += shelfSpacing + shelfWidth; } else { - p = refer_line.Evaluate(line_parameter, false); - line_parameter += shelf_width; + pointOnReferline = referline.Evaluate(lineParameter, false); + lineParameter += shelfWidth; } - first_row_points.Add(p); + firstRowPoints.Add(pointOnReferline); } } else//起点有距离 { - line_parameter = parallel_referline_offest; + lineParameter = parallelReferlineOffest; for (int j = 0; j < n; j++) { - if (!refer_line.IsInside(line_parameter + shelf_width)) + if (!referline.IsInside(lineParameter + shelfWidth)) { break; } if (j % 2 == 0) { - p = refer_line.Evaluate(line_parameter, false); - line_parameter += shelf_width; + pointOnReferline = referline.Evaluate(lineParameter, false); + lineParameter += shelfWidth; } else { - p = refer_line.Evaluate(line_parameter, false); - line_parameter += shelf_spacing + shelf_width; + pointOnReferline = referline.Evaluate(lineParameter, false); + lineParameter += shelfSpacing + shelfWidth; } - first_row_points.Add(p); + firstRowPoints.Add(pointOnReferline); } } double l = shelf.Length / 304.8; - XYZ normal_vertical_offest_vector = zaxis.CrossProduct(refer_line.Direction).Normalize(); + XYZ normalVerticalOffestVector = zAxis.CrossProduct(referline.Direction).Normalize(); List instances = new List(); - XYZ final_point = XYZ.Zero; + XYZ finalPoint = XYZ.Zero; doc.Invoke(ts => { - shelf_family = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "Shelf\\单联货架.rfa"); - var shelf_symbol_ids = shelf_family.GetFamilySymbolIds(); - foreach (var id in shelf_symbol_ids) + shelfFamily = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "Shelf\\单联货架.rfa"); + var shelfSymbolIds = shelfFamily.GetFamilySymbolIds(); + foreach (var id in shelfSymbolIds) { - FamilySymbol temp_symbol = doc.GetElement(id) as FamilySymbol; - if (temp_symbol.Name == shelf.SymbolName) + FamilySymbol tempSymbol = doc.GetElement(id) as FamilySymbol; + if (tempSymbol.Name == shelf.SymbolName) { - shelf_symbol = temp_symbol; + shelfSymbol = tempSymbol; break; } } - shelf_symbol.Activate(); + shelfSymbol.Activate(); }, "加载货架,激活类型"); switch (shelf.NumOfGroup) { case NumOfGroup.Single: - for (int j = 0; j < first_row_points.Count; j++) + for (int j = 0; j < firstRowPoints.Count; j++) { - XYZ pt = first_row_points[j]; - XYZ offest_direction = normal_vertical_offest_vector * (vertical_referline_offest + l / 2); + XYZ tempPoint = firstRowPoints[j]; + XYZ offestVector = normalVerticalOffestVector * (verticalReferlineOffest + l / 2); //垂直基准线平移 平行基准线平移 - final_point = pt + offest_direction + refer_line.Direction * shelf_width / 2; + finalPoint = tempPoint + offestVector + referline.Direction * shelfWidth / 2; //附加通道和(单联、多联)货架长度的偏移 if (i > 0) { - double total_length = GetTotalLength(shelves, i); + double totalLength = GetTotalLength(shelves, i); //附加排在前面通道和所有货架的长度 - XYZ additional_dir = normal_vertical_offest_vector * (i * passage_width + total_length); - final_point += additional_dir; + XYZ additional_dir = normalVerticalOffestVector * (i * passageWidth + totalLength); + finalPoint += additional_dir; } FamilyInstance instance = null; //all_points.Add(final_point); doc.Invoke(ts => { - instance = doc.Create.NewFamilyInstance(final_point, shelf_symbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); + instance = doc.Create.NewFamilyInstance(finalPoint, shelfSymbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); instances.Add(instance); }, "创建货架"); //位于直线右侧时,需要进行左右翻转 doc.Invoke(ts => { - if (parallel_referline_offest < 0.001) + if (parallelReferlineOffest < 0.001) { if (j % 2 != 0 && instance.CanFlipHand) { @@ -213,49 +213,49 @@ namespace RookieStation.PackAreaModule case NumOfGroup.Double: - for (int j = 0; j < first_row_points.Count; j++) + for (int j = 0; j < firstRowPoints.Count; j++) { - XYZ pt = first_row_points[j]; + XYZ tempPoint = firstRowPoints[j]; //偏移距离 - XYZ offest_direction = normal_vertical_offest_vector * (vertical_referline_offest + l); + XYZ offestVector = normalVerticalOffestVector * (verticalReferlineOffest + l); //基础偏移距离,移动半个长度到直线的一侧,垂直基准线平移 平行基准线平移 - final_point = pt + offest_direction + refer_line.Direction * shelf_width / 2; + finalPoint = tempPoint + offestVector + referline.Direction * shelfWidth / 2; //附加通道和(单联、多联)货架长度的偏移 if (i > 0) { double totallength = GetTotalLength(shelves, i); - XYZ additionaldir = normal_vertical_offest_vector * (i * passage_width + totallength); - final_point += additionaldir; + XYZ additionaldir = normalVerticalOffestVector * (i * passageWidth + totallength); + finalPoint += additionaldir; } - FamilyInstance end_instance = null; - FamilyInstance start_instance = null; + FamilyInstance endInstance = null; + FamilyInstance startInstance = null; doc.Invoke(ts => { - end_instance = doc.Create.NewFamilyInstance(final_point + l / 2 * normal_vertical_offest_vector, shelf_symbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); + endInstance = doc.Create.NewFamilyInstance(finalPoint + l / 2 * normalVerticalOffestVector, shelfSymbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); - start_instance = doc.Create.NewFamilyInstance(final_point - l / 2 * normal_vertical_offest_vector, shelf_symbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); + startInstance = doc.Create.NewFamilyInstance(finalPoint - l / 2 * normalVerticalOffestVector, shelfSymbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); - instances.Add(start_instance); + instances.Add(startInstance); - instances.Add(end_instance); + instances.Add(endInstance); }, "创建货架"); doc.Invoke(ts => { - if (parallel_referline_offest < 0.001) + if (parallelReferlineOffest < 0.001) { - if (j % 2 != 0 && start_instance.CanFlipHand && end_instance.CanFlipHand) + if (j % 2 != 0 && startInstance.CanFlipHand && endInstance.CanFlipHand) { - start_instance.flipHand(); - end_instance.flipHand(); + startInstance.flipHand(); + endInstance.flipHand(); } } else { - if (j % 2 == 0 && start_instance.CanFlipHand && end_instance.CanFlipHand) + if (j % 2 == 0 && startInstance.CanFlipHand && endInstance.CanFlipHand) { - start_instance.flipHand(); - end_instance.flipHand(); + startInstance.flipHand(); + endInstance.flipHand(); } } }, "翻转货架"); @@ -267,34 +267,34 @@ namespace RookieStation.PackAreaModule case NumOfGroup.Three: - for (int j = 0; j < first_row_points.Count; j++) + for (int j = 0; j < firstRowPoints.Count; j++) { - XYZ pt = first_row_points[j]; - XYZ offestdir = normal_vertical_offest_vector * (vertical_referline_offest + l * 3 / 2); + XYZ tempPoint = firstRowPoints[j]; + XYZ offestVector = normalVerticalOffestVector * (verticalReferlineOffest + l * 3 / 2); //垂直基准线平移 平行基准线平移 - final_point = pt + offestdir + refer_line.Direction * shelf_width / 2; + finalPoint = tempPoint + offestVector + referline.Direction * shelfWidth / 2; //附加通道和(单联、多联)货架长度的偏移 if (i > 0) { double totallength = GetTotalLength(shelves, i); - XYZ additionaldir = normal_vertical_offest_vector * (i * passage_width + totallength); - final_point += additionaldir; + XYZ additionaldir = normalVerticalOffestVector * (i * passageWidth + totallength); + finalPoint += additionaldir; } FamilyInstance end_instance = null; FamilyInstance center_instance = null; FamilyInstance start_instance = null; doc.Invoke(ts => { - center_instance = doc.Create.NewFamilyInstance(final_point, shelf_symbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); - end_instance = doc.Create.NewFamilyInstance(final_point + l * normal_vertical_offest_vector, shelf_symbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); - start_instance = doc.Create.NewFamilyInstance(final_point - l * normal_vertical_offest_vector, shelf_symbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); + center_instance = doc.Create.NewFamilyInstance(finalPoint, shelfSymbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); + end_instance = doc.Create.NewFamilyInstance(finalPoint + l * normalVerticalOffestVector, shelfSymbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); + start_instance = doc.Create.NewFamilyInstance(finalPoint - l * normalVerticalOffestVector, shelfSymbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural); instances.Add(center_instance); instances.Add(end_instance); instances.Add(start_instance); }, "创建货架"); doc.Invoke(ts => { - if (parallel_referline_offest < 0.001) + if (parallelReferlineOffest < 0.001) { if (j % 2 != 0 && start_instance.CanFlipHand && center_instance.CanFlipHand && end_instance.CanFlipHand) { @@ -324,7 +324,7 @@ namespace RookieStation.PackAreaModule doc.Invoke(ts => { - XYZ veroffestdir = zaxis.CrossProduct(refer_line.Direction).Normalize(); + XYZ veroffestdir = zAxis.CrossProduct(referline.Direction).Normalize(); //旋转角度 double angle = XYZ.BasisY.AngleTo(veroffestdir); //判断相对于Y轴是正向角度(逆时针)还是逆向角度(顺时针) @@ -338,7 +338,7 @@ namespace RookieStation.PackAreaModule for (int j = 0; j < instances.Count; j++) { FamilyInstance instance = instances[j]; - var location_XYZ = RsRevitUtils.GetXYZByElement(instance); + var location_XYZ = RsRevitUtils.GetLocationPointByElement(instance); Line zline = Line.CreateUnbound(location_XYZ, XYZ.BasisZ); //旋转,移动 @@ -453,10 +453,10 @@ namespace RookieStation.PackAreaModule foreach (var ins in card_instances) { - var lp = RsRevitUtils.GetXYZByElement(ins); + var lp = RsRevitUtils.GetLocationPointByElement(ins); foreach (var card in card_instances) { - var lpt = RsRevitUtils.GetXYZByElement(card); + var lpt = RsRevitUtils.GetLocationPointByElement(card); if (!card.Id.Equals(ins.Id) && lp.IsAlmostEqualTo(lpt)) { ids_delete.Add(ins.Id); diff --git a/RookieStation/CmdPlaceWallFinishes.cs b/RookieStation/CmdPlaceWallFinishes.cs index 7bd4bcf..7287152 100644 --- a/RookieStation/CmdPlaceWallFinishes.cs +++ b/RookieStation/CmdPlaceWallFinishes.cs @@ -24,12 +24,6 @@ namespace RookieStation.Finishes Autodesk.Revit.ApplicationServices.Application app = uiapp.Application; Document doc = uidoc.Document; - var roomcounts = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).GetElementCount(); - if (roomcounts == 0) - { - TaskDialog.Show("温馨提示", "项目中当前没有房间"); - return Result.Cancelled; - } ElementCategoryFilter ecf = new ElementCategoryFilter(BuiltInCategory.OST_Walls); ElementCategoryFilter ecf1 = new ElementCategoryFilter(BuiltInCategory.OST_StackedWalls); LogicalOrFilter lof = new LogicalOrFilter(ecf, ecf1); @@ -63,99 +57,187 @@ namespace RookieStation.Finishes { return Result.Cancelled; } - WallType walltype = finishes.WallType; - bool iscontinue = true; + WallType wallType = finishes.WallType; + double wallWidth = wallType.Width; + double wallHeight = finishes.WallHeight; + double wallBaseOffest = finishes.WallBaseOffest; + string placeType = finishes.PlaceType; + bool isContinue = true; + try { - while (iscontinue) + while (isContinue) { - Reference refer = uidoc.Selection.PickObject(ObjectType.Element, new SelectFilter(), "请选择布置的房间"); + if (placeType == "房间") + { + var roomCount = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).GetElementCount(); + if (roomCount == 0) + { + TaskDialog.Show("温馨提示", "项目中当前没有房间"); + return Result.Failed; + } + Reference refer = uidoc.Selection.PickObject(ObjectType.Element, new SelectFilter(), "请选择布置的房间"); + Room room = uidoc.Document.GetElement(refer) as Room; + List curveLoopList = new List(); + List walltojoin = new List(); + List> wallToJoinList = new List>(); + var opts = new SpatialElementBoundaryOptions(); + //{ + // SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Finish + //}; + + //BuiltInCategory builtInCategory = (BuiltInCategory)walltype.Category.Id.IntegerValue; + //if (walltype.Kind == WallKind.Stacked) + //{ + // var li = walltype.GetSubelements(); + // walltype.get + //} + //if (walltype.Kind == WallKind.Basic) + //{ + // var compounds = walltype.GetCompoundStructure(); + // for (int i = 0; i < compounds.LayerCount; i++) + // { + // offest += compounds.GetWidth(); + // } + //} + + var segementsList = room.GetBoundarySegments(opts); + + if (segementsList != null) + { + foreach (var boundarySegments in segementsList) + { + CurveLoop curveLoop = new CurveLoop(); + foreach (var boundarySegment in boundarySegments) + { + curveLoop.Append(boundarySegment.GetCurve()); + walltojoin.Add(boundarySegment.ElementId); + } + wallToJoinList.Add(walltojoin); + curveLoopList.Add(curveLoop); + } + } + doc.Invoke(ts => + { + Plane plane = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, new XYZ()); + //var mc = doc.Create.NewModelCurveArray(array, SketchPlane.Create(doc, plane)); + for (int i = 0; i < curveLoopList.Count; i++) + { + //切线方向叉乘参数中的向量,内侧叉乘-z + var offest_curveloop = CurveLoop.CreateViaOffset(curveLoopList[i], wallWidth / 2, -XYZ.BasisZ); + for (int j = 0; j < offest_curveloop.Count(); j++) + { + Curve curve = offest_curveloop.ElementAt(j); + ////c的方向叉乘参数中的向量,内侧叉乘-z + //var lc = c.CreateOffset(100 / 304.8, -XYZ.BasisZ); + + //var x = curve.ComputeDerivatives(0.5, true).BasisX.CrossProduct(-XYZ.BasisZ).Normalize() * 100 / 304.8; + //var mc = doc.Create.NewModelCurve(lc, SketchPlane.Create(doc, plane)); + //var mc = doc.Create.NewModelCurve(c, SketchPlane.Create(doc, plane)); + var wallCreated = Wall.Create(doc, curve, wallType.Id, doc.ActiveView.GenLevel.Id, wallHeight / 304.8, wallBaseOffest / 304.8, false, false); + wallCreated.get_Parameter(BuiltInParameter.WALL_ATTR_ROOM_BOUNDING).Set(0); + doc.Regenerate(); + //连接墙体让门窗可以剪切出来 + if (wallToJoinList[i][j].IntegerValue > 0) + { + Element elemToJoin = doc.GetElement(wallToJoinList[i][j]); + try + { + JoinGeometryUtils.JoinGeometry(doc, elemToJoin, wallCreated); + } + catch (Exception ex) + { + Log.WriteLog(ex.Message); + } + } + + //WallUtils.AllowWallJoinAtEnd(w, 0); + //offestcurves.Add(lc); + } + } + }, "创建房间饰面"); + } + else if (placeType == "墙面") + { + Reference referFace = uidoc.Selection.PickObject(ObjectType.Face, new SelectFilter(), "请选择布置的墙面"); + Wall wall = doc.GetElement(referFace) as Wall; + Face face = wall.GetGeometryObjectFromReference(referFace) as Face; + + var bottomFace = GetWallBottomFace(wall); + Curve instersectCurve = null; + face.Intersect(bottomFace, out instersectCurve); + doc.Invoke(ts => + { + Curve curve = instersectCurve.CreateOffset(wallWidth / 2, XYZ.BasisZ); + + var wallCreated = Wall.Create(doc, curve, wallType.Id, doc.ActiveView.GenLevel.Id, wallHeight / 304.8, wallBaseOffest / 304.8, false, false); + doc.Regenerate(); + try + { + JoinGeometryUtils.JoinGeometry(doc, wall, wallCreated); + } + catch (Exception ex) + { + Log.WriteLog(ex.Message); + } + }, "创建墙面饰面"); + //var loops = face.GetEdgesAsCurveLoops().OrderBy(x => x.GetExactLength()); + //// + //var cl = loops.LastOrDefault().GetEnumerator(); + ////face.Intersect(vp.SketchPlane.GetPlane()) + //while (cl.MoveNext()) + //{ + // var c = cl.Current; + //} + } + else if (placeType == "整墙") + { + Reference refer = uidoc.Selection.PickObject(ObjectType.Element, new SelectFilter(), "请选择布置的墙体"); + Wall wall = uidoc.Document.GetElement(refer) as Wall; + Face face = wall.GetGeometryObjectFromReference(refer) as Face; + + var bottomFace = GetWallBottomFace(wall); + var sideFaces = GetWallSideFaces(wall); + //CurveLoop loop = new CurveLoop(); + List curs = new List(); + Curve IntersectCurve = null; + foreach (var sideFace in sideFaces) + { + bottomFace.Intersect(sideFace, out IntersectCurve); + curs.Add(IntersectCurve); + //ModelCurve ml = doc.Create.NewModelCurve(cur, doc.ActiveView.SketchPlane); + + //loop.Append(cur); + } + //var loop = CurveLoop.Create(curs); + //var offestcurveloop = CurveLoop.CreateViaOffset(loop, wallwidth / 2, XYZ.BasisZ); + doc.Invoke(ts => + { + for (int i = 0; i < curs.Count(); i++) + { + Curve curve = curs.ElementAt(i).CreateOffset(wallWidth / 2, -XYZ.BasisZ); + var wallCreated = Wall.Create(doc, curve, wallType.Id, doc.ActiveView.GenLevel.Id, wallHeight / 304.8, wallBaseOffest / 304.8, false, false); + + doc.Regenerate(); + try + { + JoinGeometryUtils.JoinGeometry(doc, wall, wallCreated); + } + catch (Exception ex) + { + Log.WriteLog(ex.Message); + } + + //WallUtils.AllowWallJoinAtEnd(w, 0); + //offestcurves.Add(lc); + } + }, "创建墙体饰面"); + } //walltype包含了叠层墙和基本墙,属于不同族,如果出现名称一样,则会过滤出来两个 //var walltypes = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).OfClass(typeof(WallType)).WhereElementIsElementType(); //var walls = new FilteredElementCollector(doc).OfClass(typeof(Wall)); //var walltype = walltypes.Where(x => x.Name == "常规 - 200mm").FirstOrDefault() as WallType; - - Room room = uidoc.Document.GetElement(refer) as Room; - List curveLoopList = new List(); - List walltojoin = new List(); - List> walltojoinlist = new List>(); - var opts = new SpatialElementBoundaryOptions(); - //{ - // SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Finish - //}; - double wallwidth = walltype.Width; - double wallheight = finishes.WallHeight; - //BuiltInCategory builtInCategory = (BuiltInCategory)walltype.Category.Id.IntegerValue; - //if (walltype.Kind == WallKind.Stacked) - //{ - // var li = walltype.GetSubelements(); - // walltype.get - //} - //if (walltype.Kind == WallKind.Basic) - //{ - // var compounds = walltype.GetCompoundStructure(); - // for (int i = 0; i < compounds.LayerCount; i++) - // { - // offest += compounds.GetWidth(); - // } - //} - - var segementsList = room.GetBoundarySegments(opts); - - if (segementsList != null) - { - foreach (var boundarySegments in segementsList) - { - CurveLoop curveLoop = new CurveLoop(); - foreach (var boundarySegment in boundarySegments) - { - curveLoop.Append(boundarySegment.GetCurve()); - walltojoin.Add(boundarySegment.ElementId); - } - walltojoinlist.Add(walltojoin); - curveLoopList.Add(curveLoop); - } - } - - doc.Invoke(ts => - { - Plane plane = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, new XYZ()); - //var mc = doc.Create.NewModelCurveArray(array, SketchPlane.Create(doc, plane)); - for (int i = 0; i < curveLoopList.Count; i++) - { - //切线方向叉乘参数中的向量,内侧叉乘-z - var offestcurveloop = CurveLoop.CreateViaOffset(curveLoopList[i], wallwidth / 2, -XYZ.BasisZ); - for (int j = 0; j < offestcurveloop.Count(); j++) - { - Curve curve = offestcurveloop.ElementAt(j); - ////c的方向叉乘参数中的向量,内侧叉乘-z - //var lc = c.CreateOffset(100 / 304.8, -XYZ.BasisZ); - - //var x = curve.ComputeDerivatives(0.5, true).BasisX.CrossProduct(-XYZ.BasisZ).Normalize() * 100 / 304.8; - //var mc = doc.Create.NewModelCurve(lc, SketchPlane.Create(doc, plane)); - //var mc = doc.Create.NewModelCurve(c, SketchPlane.Create(doc, plane)); - var w = Wall.Create(doc, curve, walltype.Id, doc.ActiveView.GenLevel.Id, wallheight / 304.8, 0 / 304.8, false, false); - w.get_Parameter(BuiltInParameter.WALL_ATTR_ROOM_BOUNDING).Set(0); - doc.Regenerate(); - //让门窗可以剪切出来 - if (walltojoinlist[i][j].IntegerValue > 0) - { - Element elemtojoin = doc.GetElement(walltojoinlist[i][j]); - try - { - JoinGeometryUtils.JoinGeometry(doc, elemtojoin, w); - } - catch (Exception) - { - } - } - - //WallUtils.AllowWallJoinAtEnd(w, 0); - //offestcurves.Add(lc); - } - } - }, "创建墙饰面"); } } catch (Autodesk.Revit.Exceptions.OperationCanceledException) @@ -165,5 +247,77 @@ namespace RookieStation.Finishes return Result.Succeeded; } + + public List GetWallSideFaces(Wall wall) + { + Options opt = new Options(); + opt.ComputeReferences = true; + opt.DetailLevel = ViewDetailLevel.Fine; + GeometryElement ge = wall.get_Geometry(opt); + List lstpf = new List(); + foreach (GeometryObject obj in ge) + { + Solid solid = obj as Solid; + if (solid != null) + { + foreach (Face face in solid.Faces) + { + PlanarFace pf = face as PlanarFace; + if (pf != null) + { + if (pf.FaceNormal.DotProduct(XYZ.BasisZ) == 0) + { + lstpf.Add(pf); + } + //if (pf.FaceNormal.CrossProduct(wall.Orientation).IsZeroLength()) + //{ + // lstpf.Add(pf); + //} + } + var cy = face as CylindricalFace; + if (cy != null) + { + lstpf.Add(cy); + } + } + return lstpf; + } + } + return null; + } + + public PlanarFace GetWallBottomFace(Wall wall) + { + Options opt = new Options(); + opt.ComputeReferences = true; + opt.DetailLevel = ViewDetailLevel.Fine; + GeometryElement ge = wall.get_Geometry(opt); + PlanarFace pf = null; + foreach (GeometryObject obj in ge) + { + Solid solid = obj as Solid; + if (solid != null) + { + foreach (Face face in solid.Faces) + { + PlanarFace temppf = face as PlanarFace; + if (temppf != null) + { + if (temppf.FaceNormal.IsAlmostEqualTo(-XYZ.BasisZ)) + { + pf = temppf; + break; + } + //if (pf.FaceNormal.CrossProduct(wall.Orientation).IsZeroLength()) + //{ + // lstpf.Add(pf); + //} + } + } + return pf; + } + } + return null; + } } } \ No newline at end of file diff --git a/RookieStation/Custom/Enum.cs b/RookieStation/Custom/Enum.cs index 7f4dd98..3570979 100644 --- a/RookieStation/Custom/Enum.cs +++ b/RookieStation/Custom/Enum.cs @@ -19,7 +19,7 @@ namespace RookieStation Three = 3, } - public enum LengthType + public enum ShelfLength { [Description("1000")] x1000 = 1, @@ -34,7 +34,7 @@ namespace RookieStation x2000 = 4, } - public enum WidthType + public enum ShelfWidth { [Description("400")] x400 = 1, diff --git a/RookieStation/Custom/Shelf.cs b/RookieStation/Custom/Shelf.cs index 4130ab7..9d40f6a 100644 --- a/RookieStation/Custom/Shelf.cs +++ b/RookieStation/Custom/Shelf.cs @@ -10,9 +10,9 @@ namespace RookieStation public class Shelf { //public bool IsSelected { get; set; } - public LengthType LengthType { get; set; } + public ShelfLength ShelfLength { get; set; } - public WidthType WidthType { get; set; } + public ShelfWidth ShelfWidth { get; set; } public NumOfGroup NumOfGroup { get; set; } //public int StartNumber { get; set; } //public int EndNumber { get; set; } @@ -21,7 +21,7 @@ namespace RookieStation { get { - string strlength = CommonUtils.GetEnumDescription(LengthType); + string strlength = CommonUtils.GetEnumDescription(ShelfLength); return Convert.ToDouble(strlength); } } @@ -30,11 +30,11 @@ namespace RookieStation { get { - string strwidth = CommonUtils.GetEnumDescription(WidthType); + string strwidth = CommonUtils.GetEnumDescription(ShelfWidth); return Convert.ToDouble(strwidth); } } - public string SymbolName => String.Format("{0}{1}{2}{3}", CommonUtils.GetEnumDescription(LengthType), "mmx", CommonUtils.GetEnumDescription(WidthType), "mm"); + public string SymbolName => String.Format("{0}{1}{2}{3}", CommonUtils.GetEnumDescription(ShelfLength), "mmx", CommonUtils.GetEnumDescription(ShelfWidth), "mm"); } } \ No newline at end of file diff --git a/RookieStation/RookieStation.csproj b/RookieStation/RookieStation.csproj index 1f4a383..87b79b6 100644 --- a/RookieStation/RookieStation.csproj +++ b/RookieStation/RookieStation.csproj @@ -92,7 +92,6 @@ - True True diff --git a/RookieStation/RsApp.cs b/RookieStation/RsApp.cs index b0ba1ae..8893467 100644 --- a/RookieStation/RsApp.cs +++ b/RookieStation/RsApp.cs @@ -55,7 +55,7 @@ namespace RookieStation LargeImage = ConvertFromBitmap(Properties.Resources.cainiao), Image = ConvertFromBitmap(Properties.Resources.cainiao) }; - var projectbtn = (PushButton)projectPanel.AddItem(projectPBD); + var projectBtn = (PushButton)projectPanel.AddItem(projectPBD); //前台布置 RibbonPanel receptionAreaPanel = application.CreateRibbonPanel(TabName, ReceptionPanelName); PushButtonData receptionLayoutPBD = new PushButtonData("寄件区布置", "前台布置", AddInPath, "RookieStation.ShippingAreaModule.CmdPlaceReceptionArea") @@ -63,8 +63,8 @@ namespace RookieStation LargeImage = ConvertFromBitmap(Properties.Resources.Reception), Image = ConvertFromBitmap(Properties.Resources.Reception) }; - var receptionbtn = (PushButton)receptionAreaPanel.AddItem(receptionLayoutPBD); - receptionbtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled"; + var receptionBtn = (PushButton)receptionAreaPanel.AddItem(receptionLayoutPBD); + receptionBtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled"; //出入口布置 RibbonPanel packAreaPanel = application.CreateRibbonPanel(TabName, EntranceAndExitGatePanelName); PushButtonData entrancegateLayoutPBD = new PushButtonData("入口布置", "入口闸机", AddInPath, "RookieStation.PackAreaModule.CmdPlaceEntranceGate") @@ -77,38 +77,38 @@ namespace RookieStation LargeImage = ConvertFromBitmap(Properties.Resources.ExitGate), Image = ConvertFromBitmap(Properties.Resources.ExitGate) }; - //var gatebtn = (PushButton)gatePanel.AddItem(exportGateLayoutPBD); + //var gateBtn = (PushButton)gatePanel.AddItem(exportGateLayoutPBD); //IList gateItemsStacked = packAreaPanel.AddStackedItems(entrancegateLayoutPBD, exitGateLayoutPBD); - //var entrancebtn = (PushButton)gateItemsStacked[0]; - //var exitbtn = (PushButton)gateItemsStacked[1]; - var entrancebtn = (PushButton)packAreaPanel.AddItem(entrancegateLayoutPBD); - var exitbtn = (PushButton)packAreaPanel.AddItem(exitGateLayoutPBD); - entrancebtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled"; - exitbtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled"; + //var entranceBtn = (PushButton)gateItemsStacked[0]; + //var exitBtn = (PushButton)gateItemsStacked[1]; + var entranceBtn = (PushButton)packAreaPanel.AddItem(entrancegateLayoutPBD); + var exitBtn = (PushButton)packAreaPanel.AddItem(exitGateLayoutPBD); + entranceBtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled"; + exitBtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled"; PushButtonData placeShelvesPBD = new PushButtonData("货架布置", "货架布置", AddInPath, "RookieStation.PackAreaModule.CmdPlaceShelves") { LargeImage = ConvertFromBitmap(Properties.Resources.Shelf), Image = ConvertFromBitmap(Properties.Resources.Shelf) }; - var placeShelvesbtn = (PushButton)packAreaPanel.AddItem(placeShelvesPBD); - placeShelvesbtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled"; + var placeShelvesBtn = (PushButton)packAreaPanel.AddItem(placeShelvesPBD); + placeShelvesBtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled"; PushButtonData placeShelveCardsPBD = new PushButtonData("货架端牌", "货架端牌", AddInPath, "RookieStation.PackAreaModule.CmdArrangeShelfCards") { LargeImage = ConvertFromBitmap(Properties.Resources.ShelfCard), Image = ConvertFromBitmap(Properties.Resources.ShelfCard) }; - var placeShelveCardsbtn = (PushButton)packAreaPanel.AddItem(placeShelveCardsPBD); + var placeShelveCardsBtn = (PushButton)packAreaPanel.AddItem(placeShelveCardsPBD); PushButtonData placeLampsPBD = new PushButtonData("灯具布置", "灯具布置", AddInPath, "RookieStation.PackAreaModule.CmdPlaceLamps") { LargeImage = ConvertFromBitmap(Properties.Resources.Lamp), Image = ConvertFromBitmap(Properties.Resources.Lamp) }; - var placeLampsbtn = (PushButton)packAreaPanel.AddItem(placeLampsPBD); - placeLampsbtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled"; + var placeLampsBtn = (PushButton)packAreaPanel.AddItem(placeLampsPBD); + placeLampsBtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled"; //饰面,完成面 RibbonPanel finishesPanel = application.CreateRibbonPanel(TabName, FinishesPanelName); @@ -117,16 +117,17 @@ namespace RookieStation LargeImage = ConvertFromBitmap(Properties.Resources.FloorFinishes), Image = ConvertFromBitmap(Properties.Resources.FloorFinishes) }; - var floorcoveringbtn = (PushButton)finishesPanel.AddItem(floorfinishesPBD); - floorcoveringbtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled"; + var floorcoveringBtn = (PushButton)finishesPanel.AddItem(floorfinishesPBD); + floorcoveringBtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled"; PushButtonData wallcoveringPBD = new PushButtonData("墙饰面", "墙饰面", AddInPath, "RookieStation.Finishes.CmdPlaceWallFinishes") { LargeImage = ConvertFromBitmap(Properties.Resources.WallFinishes), Image = ConvertFromBitmap(Properties.Resources.WallFinishes) }; - var wallcoveringbtn = (PushButton)finishesPanel.AddItem(wallcoveringPBD); - wallcoveringbtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled"; + + var wallcoveringBtn = (PushButton)finishesPanel.AddItem(wallcoveringPBD); + wallcoveringBtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled"; //统计面板 RibbonPanel statisticsPanel = application.CreateRibbonPanel(TabName, StatisticsPanelName); diff --git a/RookieStation/RsLibrary/Document/样板工程量清单.xlsx b/RookieStation/RsLibrary/Document/样板工程量清单.xlsx index be0f38e..2c854e7 100644 Binary files a/RookieStation/RsLibrary/Document/样板工程量清单.xlsx and b/RookieStation/RsLibrary/Document/样板工程量清单.xlsx differ diff --git a/RookieStation/ShelvesPlacementViewModel.cs b/RookieStation/ShelvesPlacementViewModel.cs index 727da74..feb396c 100644 --- a/RookieStation/ShelvesPlacementViewModel.cs +++ b/RookieStation/ShelvesPlacementViewModel.cs @@ -13,7 +13,7 @@ namespace RookieStation /// /// 基于参考线的偏移(垂距) /// - public double VerticalReferOffest { get; set; } + public double VerticalReferlineOffest { get; set; } /// /// 通道宽度 @@ -23,12 +23,12 @@ namespace RookieStation /// /// 基于参考线的偏移(起点水平) /// - public double ParalelReferOffest { get; set; } + public double ParallelReferlineOffest { get; set; } /// /// 货架间距 /// - public double Spacing { get; set; } + public double ShelfSpacing { get; set; } public ShelvesPlacementViewModel() { @@ -44,32 +44,32 @@ namespace RookieStation for (int i = 0; i < sc.Count; i++) { Shelf shelf = new Shelf(); - string shelf_string = sc[i]; - string[] shelf_chars = shelf_string.Split(','); - foreach (NumOfGroup ng in Enum.GetValues(typeof(NumOfGroup))) + string shelfInfo = sc[i]; + string[] shelfChars = shelfInfo.Split(','); + foreach (NumOfGroup numDescription in Enum.GetValues(typeof(NumOfGroup))) { - string description = CommonUtils.GetEnumDescription(ng); - if (description == shelf_chars[0]) + string description = CommonUtils.GetEnumDescription(numDescription); + if (description == shelfChars[0]) { - shelf.NumOfGroup = ng; + shelf.NumOfGroup = numDescription; break; } } - foreach (LengthType lt in Enum.GetValues(typeof(LengthType))) + foreach (ShelfLength lengthDescription in Enum.GetValues(typeof(ShelfLength))) { - string description = CommonUtils.GetEnumDescription(lt); - if (description == shelf_chars[1]) + string description = CommonUtils.GetEnumDescription(lengthDescription); + if (description == shelfChars[1]) { - shelf.LengthType = lt; + shelf.ShelfLength = lengthDescription; break; } } - foreach (WidthType wt in Enum.GetValues(typeof(WidthType))) + foreach (ShelfWidth widthDescription in Enum.GetValues(typeof(ShelfWidth))) { - string description = CommonUtils.GetEnumDescription(wt); - if (description == shelf_chars[2]) + string description = CommonUtils.GetEnumDescription(widthDescription); + if (description == shelfChars[2]) { - shelf.WidthType = wt; + shelf.ShelfWidth = widthDescription; break; } } diff --git a/RookieStation/TestCmd.cs b/RookieStation/TestCmd.cs deleted file mode 100644 index cb89276..0000000 --- a/RookieStation/TestCmd.cs +++ /dev/null @@ -1,52 +0,0 @@ -using Autodesk.Revit.DB; -using Autodesk.Revit.UI; -using Autodesk.Revit.UI.Selection; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace RookieStation -{ - [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)] - [Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)] - internal class TestCmd : IExternalCommand - { - public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) - { - UIApplication uiapp = commandData.Application; - UIDocument uidoc = uiapp.ActiveUIDocument; - Autodesk.Revit.ApplicationServices.Application app = uiapp.Application; - Document doc = uidoc.Document; - DocumentSet docset = uiapp.Application.Documents; - ICollection sys = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_FurnitureSystems).OfClass(typeof(FamilyInstance)).ToElements(); - foreach (FamilyInstance sy in sys) - { - if (sy.Symbol.FamilyName.Contains("亚克力")) - { - TaskDialog.Show("提示", "存在"); - } - } - using (Transaction trans = new Transaction(doc, "cmd")) - { - try - { - trans.Start(); - //Do Something. - trans.Commit(); - } - catch (Exception ex) - { - message = ex.Message; - if (trans.GetStatus() == TransactionStatus.Started) - { - trans.RollBack(); - } - return Result.Cancelled; - } - } - return Result.Succeeded; - } - } -} \ No newline at end of file diff --git a/RookieStation/Utils/DocumentExtension.cs b/RookieStation/Utils/DocumentExtension.cs index 200a7f4..be9a883 100644 --- a/RookieStation/Utils/DocumentExtension.cs +++ b/RookieStation/Utils/DocumentExtension.cs @@ -178,9 +178,9 @@ namespace RookieStation.Utils { tg.Start(); - var result = func(tg); + TResult result = func(tg); - var status = tg.GetStatus(); + TransactionStatus status = tg.GetStatus(); switch (status) { case TransactionStatus.Started: diff --git a/RookieStation/Utils/RsRevitUtils.cs b/RookieStation/Utils/RsRevitUtils.cs index 712a28e..a1e47ff 100644 --- a/RookieStation/Utils/RsRevitUtils.cs +++ b/RookieStation/Utils/RsRevitUtils.cs @@ -14,31 +14,31 @@ namespace RookieStation.Utils /// /// 英尺转米 /// - /// + /// /// - public static double FtConvertToM(double valuetoconvert) + public static double FtConvertToM(double valueToConvert) { - return UnitUtils.ConvertFromInternalUnits(valuetoconvert, DisplayUnitType.DUT_METERS); + return UnitUtils.ConvertFromInternalUnits(valueToConvert, DisplayUnitType.DUT_METERS); } /// /// 平方英尺转平方米 /// - /// + /// /// - public static double SFConvertToSM(double valuetoconvert) + public static double SFConvertToSM(double valueToConvert) { - return UnitUtils.ConvertFromInternalUnits(valuetoconvert, DisplayUnitType.DUT_SQUARE_METERS); + return UnitUtils.ConvertFromInternalUnits(valueToConvert, DisplayUnitType.DUT_SQUARE_METERS); } /// /// 英尺转换成毫米单位 /// - /// + /// /// - public static double FtConvertToMM(double valuetoconvert) + public static double FtConvertToMM(double valueToConvert) { - return UnitUtils.ConvertFromInternalUnits(valuetoconvert, DisplayUnitType.DUT_MILLIMETERS); + return UnitUtils.ConvertFromInternalUnits(valueToConvert, DisplayUnitType.DUT_MILLIMETERS); } /// @@ -46,14 +46,14 @@ namespace RookieStation.Utils /// /// 墙类型包含的字符串 /// - public static double GetWallWidthByWallTypeName(Document doc, string wallTypeName, out WallType walltype) + public static double GetWallWidthByWallTypeName(Document doc, string wallTypeName, out WallType wallType) { double thickness = 0.0; var walltypelist = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).OfClass(typeof(WallType)).Cast(); - walltype = walltypelist.FirstOrDefault(t => t.Name.Contains(wallTypeName)); - if (walltype != null) + wallType = walltypelist.FirstOrDefault(t => t.Name.Contains(wallTypeName)); + if (wallType != null) { - thickness = walltype.Width; + thickness = wallType.Width; //var compounds = walltype.GetCompoundStructure(); //for (int i = 0; i < compounds.LayerCount; i++) //{ @@ -68,7 +68,7 @@ namespace RookieStation.Utils /// /// /// - public static XYZ GetXYZByElement(Element instance) + public static XYZ GetLocationPointByElement(Element instance) { return instance.Location is LocationPoint lp ? lp.Point : null; } @@ -77,19 +77,19 @@ namespace RookieStation.Utils /// 调整族实例位置 /// /// - /// 需要偏移的族实例 - /// 用于调整偏移和角度的参考线 + /// 需要偏移的族实例 + /// 用于调整偏移和角度的参考线 /// 偏移量 - public static void AdjustInstances(Document doc, List fis, Line refer_line, double offest) + public static void AdjustInstances(Document doc, List instances, Line referLine, double offest) { - var zdir = XYZ.BasisZ; + XYZ zdir = XYZ.BasisZ; //通过第三点垂直于直线的单位向量(无论左右侧)*偏移距离(一半的闸机长度) - XYZ offestdir = zdir.CrossProduct(refer_line.Direction).Normalize() * offest; + XYZ offestVector = zdir.CrossProduct(referLine.Direction).Normalize() * offest; //旋转角度 - double angle = XYZ.BasisY.AngleTo(offestdir); + double angle = XYZ.BasisY.AngleTo(offestVector); //判断相对于Y轴是正向角度(逆时针)还是逆向角度(顺时针) - XYZ z = offestdir.CrossProduct(XYZ.BasisY).Normalize(); + XYZ z = offestVector.CrossProduct(XYZ.BasisY).Normalize(); if (z.IsAlmostEqualTo(XYZ.BasisZ)) { //逆向旋转,角度取负值 @@ -97,13 +97,13 @@ namespace RookieStation.Utils //var ml = doc.Create.NewModelCurve(Line.CreateBound(XYZ.Zero, re), SketchPlane.Create(doc, Plane.CreateByNormalAndOrigin(XYZ.BasisZ, new XYZ()))); } - foreach (var fi in fis) + foreach (FamilyInstance instance in instances) { - var p = GetXYZByElement(fi); + XYZ p = GetLocationPointByElement(instance); Line l = Line.CreateUnbound(p, XYZ.BasisZ); //旋转,移动 - ElementTransformUtils.RotateElement(doc, fi.Id, l, angle); - ElementTransformUtils.MoveElement(doc, fi.Id, offestdir); + ElementTransformUtils.RotateElement(doc, instance.Id, l, angle); + ElementTransformUtils.MoveElement(doc, instance.Id, offestVector); } } @@ -112,30 +112,30 @@ namespace RookieStation.Utils /// /// /// - /// + /// /// - public static void AdjustInstance(Document doc, FamilyInstance fi, Line refer_line, double offest) + public static void AdjustInstance(Document doc, FamilyInstance fi, Line referLine, double offest) { //朝着向量方向左侧偏移 - var zdir = XYZ.BasisZ; + XYZ zdir = XYZ.BasisZ; //通过第三点垂直于直线的单位向量(无论左右侧)*偏移距离(一半的闸机长度) - XYZ offest_direction = zdir.CrossProduct(refer_line.Direction).Normalize() * offest; + XYZ offestVector = zdir.CrossProduct(referLine.Direction).Normalize() * offest; //旋转角度 - double angle = XYZ.BasisY.AngleTo(offest_direction); + double angle = XYZ.BasisY.AngleTo(offestVector); //判断相对于Y轴是正向角度(逆时针)还是逆向角度(顺时针) - XYZ z = offest_direction.CrossProduct(XYZ.BasisY).Normalize(); + XYZ z = offestVector.CrossProduct(XYZ.BasisY).Normalize(); if (z.IsAlmostEqualTo(XYZ.BasisZ)) { //逆向旋转,角度取负值 angle = -angle; } - var p = GetXYZByElement(fi); + XYZ p = GetLocationPointByElement(fi); Line l = Line.CreateUnbound(p, XYZ.BasisZ); //旋转,移动 ElementTransformUtils.RotateElement(doc, fi.Id, l, angle + Math.PI); - ElementTransformUtils.MoveElement(doc, fi.Id, offest_direction); + ElementTransformUtils.MoveElement(doc, fi.Id, offestVector); } /// @@ -144,14 +144,14 @@ namespace RookieStation.Utils public static void AddProjectTemplate() { //Autodesk.Revit.ApplicationServices.Application.CurrentUsersDataFolderPath - string oriDatei = @"" + Environment.GetEnvironmentVariable("appdata") + @"\Autodesk\Revit\Autodesk Revit 2020\Revit.ini"; - string tmpDatei = UserConstant.FamilyLibraryDirectory + "\\Rs.ini"; + string oriDateFilePath = @"" + Environment.GetEnvironmentVariable("appdata") + @"\Autodesk\Revit\Autodesk Revit 2020\Revit.ini"; + string tmpDateFilePath = UserConstant.FamilyLibraryDirectory + "\\Rs.ini"; - if (System.IO.File.Exists(oriDatei)) + if (System.IO.File.Exists(oriDateFilePath)) { - using (StreamReader sr = new StreamReader(oriDatei, Encoding.Unicode)) + using (StreamReader sr = new StreamReader(oriDateFilePath, Encoding.Unicode)) { - StreamWriter sw = new StreamWriter(tmpDatei, false, Encoding.Unicode); + StreamWriter sw = new StreamWriter(tmpDateFilePath, false, Encoding.Unicode); string inputLine = ""; while ((inputLine = sr.ReadLine()) != null) @@ -172,34 +172,34 @@ namespace RookieStation.Utils sw.Close(); } - System.IO.File.Replace(tmpDatei, oriDatei, null); + System.IO.File.Replace(tmpDateFilePath, oriDateFilePath, null); } } public static FamilySymbol GetGuideSymbol(Document doc) { - FamilySymbol linesymbol = null; + FamilySymbol lineSymbol = null; doc.Invoke(ts => { - Family linefamily = GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "定位线.rfa"); - linesymbol = doc.GetElement(linefamily.GetFamilySymbolIds().FirstOrDefault()) as FamilySymbol; + Family lineFamily = GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "定位线.rfa"); + lineSymbol = doc.GetElement(lineFamily.GetFamilySymbolIds().FirstOrDefault()) as FamilySymbol; }, "载入定位线并布置"); - return linesymbol; + return lineSymbol; } public static Line GetGuideGeometryAndDeleteGuide(Document doc, List eleIdsAdded) { - ElementId referlineid = eleIdsAdded.FirstOrDefault(); - FamilyInstance referline = doc.GetElement(referlineid) as FamilyInstance; - LocationCurve lc = referline.Location as LocationCurve; - Line referlinegeom = lc.Curve as Line; + ElementId referLineId = eleIdsAdded.FirstOrDefault(); + FamilyInstance guideLine = doc.GetElement(referLineId) as FamilyInstance; + LocationCurve lc = guideLine.Location as LocationCurve; + Line line = lc.Curve as Line; doc.Invoke(ts => { - doc.Delete(referlineid); + doc.Delete(referLineId); }, "删除参考线"); - return referlinegeom; + return line; } /// @@ -210,7 +210,7 @@ namespace RookieStation.Utils /// 所有的面 public static List GetFaceByElement(Element item, Options options) { - List listFace = new List(); + List faces = new List(); //根据打开的方式得到几何信息 GeometryElement geometry = item.get_Geometry(options); foreach (GeometryObject geomObj in geometry) @@ -223,14 +223,14 @@ namespace RookieStation.Utils foreach (GeometryObject instObj in geomInstance.GetInstanceGeometry()) { //三维的实体 - Solid instsolid = instObj as Solid; - if (instsolid == null || instsolid.Faces.Size == 0 || instsolid.Edges.Size == 0) + Solid instSolid = instObj as Solid; + if (instSolid == null || instSolid.Faces.Size == 0 || instSolid.Edges.Size == 0) { continue; } - foreach (Face face in instsolid.Faces) + foreach (Face face in instSolid.Faces) { - listFace.Add(face); + faces.Add(face); } } } @@ -246,12 +246,12 @@ namespace RookieStation.Utils { foreach (Face face in solid.Faces) { - listFace.Add(face); + faces.Add(face); } } } } - return listFace; + return faces; } /// @@ -261,7 +261,7 @@ namespace RookieStation.Utils /// public static List GetFacesByFamilyInstance(FamilyInstance instance, Options options) { - List listFace = new List(); + List faces = new List(); //根据打开的方式得到几何信息 GeometryElement geometry = instance.get_Geometry(options); foreach (GeometryObject geomObj in geometry) @@ -280,14 +280,14 @@ namespace RookieStation.Utils foreach (GeometryObject instObj in instanceGeometry) { //三维的实体 - Solid instsolid = instObj as Solid; - if (instsolid == null || instsolid.Faces.Size == 0 || instsolid.Edges.Size == 0) + Solid instSolid = instObj as Solid; + if (instSolid == null || instSolid.Faces.Size == 0 || instSolid.Edges.Size == 0) { continue; } - foreach (Face face in instsolid.Faces) + foreach (Face face in instSolid.Faces) { - listFace.Add(face); + faces.Add(face); } } } @@ -303,12 +303,12 @@ namespace RookieStation.Utils { foreach (Face face in solid.Faces) { - listFace.Add(face); + faces.Add(face); } } } } - return listFace; + return faces; } /// @@ -318,7 +318,7 @@ namespace RookieStation.Utils /// public static List GetFamilyInstanceFaces(FamilyInstance instance, Options options) { - List listFace = new List(); + List faces = new List(); //根据打开的方式得到几何信息 GeometryElement geometry = instance.get_Geometry(options); @@ -334,14 +334,14 @@ namespace RookieStation.Utils foreach (GeometryObject instObj in geomInstance.GetInstanceGeometry()) { //三维的实体 - Solid instsolid = instObj as Solid; - if (instsolid == null || instsolid.Faces.Size == 0 || instsolid.Edges.Size == 0) + Solid instSolid = instObj as Solid; + if (instSolid == null || instSolid.Faces.Size == 0 || instSolid.Edges.Size == 0) { continue; } - foreach (Face face in instsolid.Faces) + foreach (Face face in instSolid.Faces) { - listFace.Add(face); + faces.Add(face); } } } @@ -357,12 +357,12 @@ namespace RookieStation.Utils { foreach (Face face in solid.Faces) { - listFace.Add(face); + faces.Add(face); } } } } - return listFace; + return faces; } /// @@ -399,20 +399,20 @@ namespace RookieStation.Utils /// 获取已载入同名族,若无,则载入 /// /// - /// + /// /// - internal static Family GetLoadedFamily(Document doc, string familyname) + internal static Family GetLoadedFamily(Document doc, string familyName) { Family family; family = new FilteredElementCollector(doc) .OfClass(typeof(Family)) .Cast() - .Where(f => f.Name == Path.GetFileNameWithoutExtension(familyname)) + .Where(f => f.Name == Path.GetFileNameWithoutExtension(familyName)) .FirstOrDefault(); if (family == null) { - doc.LoadFamily(familyname, new RsFamilyLoadOption(), out family); + doc.LoadFamily(familyName, new RsFamilyLoadOption(), out family); } return family; @@ -422,23 +422,23 @@ namespace RookieStation.Utils /// 获取垂直于基准线的最长边 /// /// - /// + /// /// - public static Line GetLongestSegmentLine(IList segments, Line baseline) + public static Line GetLongestSegmentLine(IList segments, Line baseLine) { Line line = null; //var m = doc.GetElement(refer.ElementId); foreach (var seg in segments) { - Line templine = seg.GetCurve() as Line; + Line tempLine = seg.GetCurve() as Line; //判断是否垂直 - double dotp = Math.Abs(templine.Direction.DotProduct(baseline.Direction)); + double dotp = Math.Abs(tempLine.Direction.DotProduct(baseLine.Direction)); if (dotp < 0.0001) { - if (line == null || line.Length < templine.Length) + if (line == null || line.Length < tempLine.Length) { - line = templine; + line = tempLine; } } } diff --git a/RookieStation/Utils/ViewPlanCmdEnabled.cs b/RookieStation/Utils/ViewPlanCmdEnabled.cs index 6756095..b1461f5 100644 --- a/RookieStation/Utils/ViewPlanCmdEnabled.cs +++ b/RookieStation/Utils/ViewPlanCmdEnabled.cs @@ -15,6 +15,19 @@ namespace RookieStation { public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories) { + //Application revitApplication = applicationData.Application; + //ApplicationOptions options = ApplicationOptions.Get(); + + //switch (options.Availability) + //{ + // case ApplicationAvailablity.ArchitectureDiscipline: + // return revitApplication.IsArchitectureEnabled; + // case ApplicationAvailablity.StructuralAnalysis: + // return revitApplication.IsStructuralAnalysisEnabled; + // case ApplicationAvailablity.MEP: + // return revitApplication.IsSystemsEnabled; + //} + if (null != applicationData.ActiveUIDocument) { Autodesk.Revit.DB.View view = applicationData.ActiveUIDocument.Document.ActiveView; diff --git a/RookieStation/WpfEntranceGate.xaml b/RookieStation/WpfEntranceGate.xaml index 44f5b81..e341021 100644 --- a/RookieStation/WpfEntranceGate.xaml +++ b/RookieStation/WpfEntranceGate.xaml @@ -30,7 +30,7 @@ Margin="2" Header="通道宽度(mm)"> diff --git a/RookieStation/WpfEntranceGate.xaml.cs b/RookieStation/WpfEntranceGate.xaml.cs index c629bfb..ec86e2b 100644 --- a/RookieStation/WpfEntranceGate.xaml.cs +++ b/RookieStation/WpfEntranceGate.xaml.cs @@ -20,7 +20,7 @@ namespace RookieStation /// public partial class WpfEntranceGate { - public double passage_width = 0.0; + public double PassageWidth { get; set; } public WpfEntranceGate() { @@ -29,10 +29,11 @@ namespace RookieStation private void btnConfirm_Click(object sender, RoutedEventArgs e) { - bool a = double.TryParse(tbpassage_width.Text, out passage_width); - + double passageWidth; + bool a = double.TryParse(tbPassage_width.Text, out passageWidth); if (a) { + PassageWidth = passageWidth; DialogResult = true; } } diff --git a/RookieStation/WpfExitGate.xaml b/RookieStation/WpfExitGate.xaml index 9c85e8a..3d5eb44 100644 --- a/RookieStation/WpfExitGate.xaml +++ b/RookieStation/WpfExitGate.xaml @@ -55,7 +55,7 @@ Margin="2" Header="通道宽度(mm)"> diff --git a/RookieStation/WpfExitGate.xaml.cs b/RookieStation/WpfExitGate.xaml.cs index faf1525..6eab67b 100644 --- a/RookieStation/WpfExitGate.xaml.cs +++ b/RookieStation/WpfExitGate.xaml.cs @@ -20,9 +20,9 @@ namespace RookieStation /// public partial class WpfExitGate { - public bool isStartPassage = true; + public bool IsStartPassage { get; set; } - public double passage_width = 0.0; + public double PassageWidth { get; set; } public WpfExitGate() @@ -32,15 +32,17 @@ namespace RookieStation private void btnConfirm_Click(object sender, RoutedEventArgs e) { - bool a = double.TryParse(tbpassage_width.Text, out passage_width); + double passageWidth; + bool a = double.TryParse(tbPassagewidth.Text, out passageWidth); if (rbStartPassage.IsChecked == true) { - isStartPassage = true; + PassageWidth = passageWidth; + IsStartPassage = true; } else if (rbStartInspection.IsChecked == true) { - isStartPassage = false; + IsStartPassage = false; } if (a) { diff --git a/RookieStation/WpfFloorFinishes.xaml b/RookieStation/WpfFloorFinishes.xaml index e9a025f..e09f761 100644 --- a/RookieStation/WpfFloorFinishes.xaml +++ b/RookieStation/WpfFloorFinishes.xaml @@ -35,7 +35,7 @@ Margin="2" Header="砖长(mm)"> public partial class WpfFloorFinishes { - public double cLength; + public double PavementLength { get; set; } - public double cWidth; + public double PavementWidth { get; set; } - public double cGap; + public double PavementGap { get; set; } public WpfFloorFinishes() @@ -34,11 +34,15 @@ namespace RookieStation private void btnConfirm_Click(object sender, RoutedEventArgs e) { - var a = double.TryParse(tbLength.Text, out cLength); - var b = double.TryParse(tbWidth.Text, out cWidth); - var c = double.TryParse(tbGap.Text, out cGap); + double length, width, gap; + var a = double.TryParse(tbPavementLength.Text, out length); + var b = double.TryParse(tbPavementWidth.Text, out width); + var c = double.TryParse(tbPavementGap.Text, out gap); if (a && b && c) { + PavementLength = length; + PavementWidth = width; + PavementGap = gap; DialogResult = true; } else diff --git a/RookieStation/WpfLampsLayout.xaml.cs b/RookieStation/WpfLampsLayout.xaml.cs index 6eeee60..e0af2a5 100644 --- a/RookieStation/WpfLampsLayout.xaml.cs +++ b/RookieStation/WpfLampsLayout.xaml.cs @@ -20,8 +20,8 @@ namespace RookieStation /// public partial class WpfLampsLayout { - public double LRDistance; - public double FBDistance; + public double LeftRightDistance { get; set; } + public double FrontDistance { get; set; } public WpfLampsLayout() { @@ -30,10 +30,13 @@ namespace RookieStation private void btnConfirm_Click(object sender, RoutedEventArgs e) { - bool a = double.TryParse(tbDistanceLR.Text, out LRDistance); - bool b = double.TryParse(tbDistanceFB.Text, out FBDistance); + double lrDistance, fDistance; + bool a = double.TryParse(tbDistanceLR.Text, out lrDistance); + bool b = double.TryParse(tbDistanceFB.Text, out fDistance); if (a && b) { + LeftRightDistance = lrDistance; + FrontDistance = fDistance; DialogResult = true; } } diff --git a/RookieStation/WpfReceptionArea.xaml b/RookieStation/WpfReceptionArea.xaml index 4d1a15d..75a1209 100644 --- a/RookieStation/WpfReceptionArea.xaml +++ b/RookieStation/WpfReceptionArea.xaml @@ -3,12 +3,13 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:local="clr-namespace:RookieStation" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - Width="485" - Height="220" - MinWidth="550" - MinHeight="250" + Width="126" + Height="338" + MinWidth="220" + MinHeight="480" mc:Ignorable="d"> @@ -20,68 +21,66 @@ - + + + - - - - - - - - - - - - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + +