From a24832045cb91ac783b449751f05cbe0257f238b Mon Sep 17 00:00:00 2001 From: Ziyun Shang Date: Tue, 2 Nov 2021 14:30:19 +0800 Subject: [PATCH 1/4] Keep the revit element with Node when Disable Transaction --- CHANGELOG.md | 7 ++-- src/DynamoRevit/DynamoRevit.cs | 6 ++-- .../Elements/AbstractFamilyInstance.cs | 10 ++++++ .../RevitNodes/Elements/AdaptiveComponent.cs | 21 +++++++++--- src/Libraries/RevitNodes/Elements/Area.cs | 9 ++++++ src/Libraries/RevitNodes/Elements/Ceiling.cs | 15 +++++++-- .../RevitNodes/Elements/CurtainSystem.cs | 9 ++++++ .../RevitNodes/Elements/CurveElement.cs | 9 ++++++ .../RevitNodes/Elements/Dimension.cs | 9 ++++++ .../RevitNodes/Elements/DimensionType.cs | 9 ++++++ .../RevitNodes/Elements/DirectShape.cs | 9 ++++++ .../RevitNodes/Elements/DividedPath.cs | 9 ++++++ .../RevitNodes/Elements/DividedSurface.cs | 9 ++++++ src/Libraries/RevitNodes/Elements/Element.cs | 27 ++++++++++++++-- .../RevitNodes/Elements/ElementType.cs | 9 ++++++ .../RevitNodes/Elements/ElevationMarker.cs | 9 ++++++ src/Libraries/RevitNodes/Elements/FaceWall.cs | 9 ++++++ src/Libraries/RevitNodes/Elements/Family.cs | 9 ++++++ .../RevitNodes/Elements/FillPatternElement.cs | 9 ++++++ .../RevitNodes/Elements/FilledRegion.cs | 9 ++++++ src/Libraries/RevitNodes/Elements/Floor.cs | 15 +++++++-- src/Libraries/RevitNodes/Elements/Form.cs | 9 ++++++ src/Libraries/RevitNodes/Elements/FreeForm.cs | 9 ++++++ .../RevitNodes/Elements/GlobalParameter.cs | 9 ++++++ src/Libraries/RevitNodes/Elements/Grid.cs | 9 ++++++ src/Libraries/RevitNodes/Elements/Group.cs | 9 ++++++ .../RevitNodes/Elements/ImportInstance.cs | 9 ++++++ src/Libraries/RevitNodes/Elements/Level.cs | 9 ++++++ .../RevitNodes/Elements/LinePatternElement.cs | 9 ++++++ src/Libraries/RevitNodes/Elements/Material.cs | 9 ++++++ .../RevitNodes/Elements/ModelText.cs | 9 ++++++ .../RevitNodes/Elements/PathOfTravel.cs | 24 ++++++++++++++ .../RevitNodes/Elements/ReferencePlane.cs | 9 ++++++ .../RevitNodes/Elements/ReferencePoint.cs | 9 ++++++ src/Libraries/RevitNodes/Elements/Revision.cs | 9 ++++++ .../RevitNodes/Elements/RevisionCloud.cs | 11 ++++++- src/Libraries/RevitNodes/Elements/Roof.cs | 17 ++++++++-- src/Libraries/RevitNodes/Elements/Room.cs | 11 ++++++- .../RevitNodes/Elements/ScheduleOnSheet.cs | 9 ++++++ .../RevitNodes/Elements/SketchPlane.cs | 9 ++++++ src/Libraries/RevitNodes/Elements/Space.cs | 9 ++++++ .../RevitNodes/Elements/SunSettings.cs | 9 ++++++ .../RevitNodes/Elements/TextElement.cs | 9 ++++++ .../RevitNodes/Elements/Topography.cs | 9 ++++++ .../RevitNodes/Elements/UnknownElement.cs | 9 ++++++ src/Libraries/RevitNodes/Elements/Viewport.cs | 9 ++++++ .../RevitNodes/Elements/Views/DraftingView.cs | 9 ++++++ .../RevitNodes/Elements/Views/Legend.cs | 9 ++++++ .../RevitNodes/Elements/Views/PlanView.cs | 9 ++++++ .../RevitNodes/Elements/Views/ScheduleView.cs | 9 ++++++ .../RevitNodes/Elements/Views/SectionView.cs | 9 ++++++ .../RevitNodes/Elements/Views/Sheet.cs | 32 +++++++++++++++---- .../RevitNodes/Elements/Views/View3D.cs | 9 ++++++ src/Libraries/RevitNodes/Elements/Wall.cs | 9 ++++++ .../Filter/ParameterFilterElement.cs | 9 ++++++ .../Persistence/ElementIDLifecycleManager.cs | 9 ++++-- 56 files changed, 561 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16f46a7bf..9ddfaeb76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,7 @@ - -## 0.3.8 -* Upgrade Greg, GregRevitOAuth, and RestSharp to RestSharp 106.12.0 to address a security issue. - -## 0.3.7 * Add Transaction controls - "Sync with Revit" Toggle button. +* Upgrade Greg, GregRevitOAuth, and RestSharp to RestSharp 106.12.0 to address a security issue. +* Keep ElementBinding when set Transaction disabled. ## 0.3.6 * Upgrade DynamoRevit to 2.13.0. diff --git a/src/DynamoRevit/DynamoRevit.cs b/src/DynamoRevit/DynamoRevit.cs index c07edaed2..3f2be4747 100644 --- a/src/DynamoRevit/DynamoRevit.cs +++ b/src/DynamoRevit/DynamoRevit.cs @@ -576,16 +576,18 @@ private static void AddSyncWithRevitControls(DynamoView dynamoView) var runsettingStackPanel = runsettingsGrid.Children.OfType().FirstOrDefault(); var srcDic = Dynamo.UI.SharedDictionaryManager.DynamoModernDictionary; + if (TransactionManager.Instance.DisableTransactions) + TransactionManager.Instance.DisableTransactions = false; var toggleItem = new System.Windows.Controls.Primitives.ToggleButton { Width = 40, Height = 20, - IsChecked = true, + IsChecked = !TransactionManager.Instance.DisableTransactions, VerticalContentAlignment = System.Windows.VerticalAlignment.Center, ToolTip = Resources.SyncWithRevitToolTip }; - + toggleItem.SetValue(System.Windows.Controls.Primitives.ToggleButton.StyleProperty, srcDic["EllipseToggleButton1"]); toggleItem.Click += OnReadOnlyModeToggleChecked; diff --git a/src/Libraries/RevitNodes/Elements/AbstractFamilyInstance.cs b/src/Libraries/RevitNodes/Elements/AbstractFamilyInstance.cs index 2653a8dff..13caa80b6 100644 --- a/src/Libraries/RevitNodes/Elements/AbstractFamilyInstance.cs +++ b/src/Libraries/RevitNodes/Elements/AbstractFamilyInstance.cs @@ -1,4 +1,5 @@ using Autodesk.DesignScript.Runtime; +using Autodesk.Revit.DB; using Revit.GeometryConversion; using RevitServices.Persistence; using RevitServices.Transactions; @@ -33,6 +34,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalFamilyInstance; } } + /// + /// + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetFamilyInstance(element as Autodesk.Revit.DB.FamilyInstance); + } + #endregion #region Protected mutators diff --git a/src/Libraries/RevitNodes/Elements/AdaptiveComponent.cs b/src/Libraries/RevitNodes/Elements/AdaptiveComponent.cs index 014a9a704..c9165b1d6 100644 --- a/src/Libraries/RevitNodes/Elements/AdaptiveComponent.cs +++ b/src/Libraries/RevitNodes/Elements/AdaptiveComponent.cs @@ -29,7 +29,7 @@ public class AdaptiveComponent : AbstractFamilyInstance /// private AdaptiveComponent(Autodesk.Revit.DB.FamilyInstance familyInstance) { - SafeInit(() => InitAdaptiveComponent(familyInstance)); + SafeInit(() => InitAdaptiveComponent(familyInstance), true); } /// @@ -64,9 +64,7 @@ private AdaptiveComponent(double[] parms, Reference c, FamilyType ft) /// private void InitAdaptiveComponent(Autodesk.Revit.DB.FamilyInstance familyInstance) { - TransactionManager.Instance.EnsureInTransaction(Document); InternalSetFamilyInstance(familyInstance); - TransactionManager.Instance.TransactionTaskDone(); } /// @@ -511,11 +509,24 @@ private static AdaptiveComponent[] InternalByPoints(Point[][] points, FamilyType if (oldInstances != null) countOfOldInstances = oldInstances.Count(); int reusableCount = Math.Min(countToBeCreated, countOfOldInstances); - TransactionManager.Instance.EnsureInTransaction(Document); - List instances = new List(); List components = new List(); + if (TransactionManager.Instance.DisableTransactions) + { + if(oldInstances != null) + { + foreach (var instance in oldInstances) + { + var adpCom = new AdaptiveComponent(instance); + components.Add(adpCom); + } + return components.ToArray(); + } + } + + TransactionManager.Instance.EnsureInTransaction(Document); + try { // Reuse the adaptive components that can be reused if possible diff --git a/src/Libraries/RevitNodes/Elements/Area.cs b/src/Libraries/RevitNodes/Elements/Area.cs index 3ec19cfd3..b6934a6b3 100644 --- a/src/Libraries/RevitNodes/Elements/Area.cs +++ b/src/Libraries/RevitNodes/Elements/Area.cs @@ -26,6 +26,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalArea; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetArea(element as Autodesk.Revit.DB.Area); + } + #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/Ceiling.cs b/src/Libraries/RevitNodes/Elements/Ceiling.cs index 29b7afb22..a657cd021 100644 --- a/src/Libraries/RevitNodes/Elements/Ceiling.cs +++ b/src/Libraries/RevitNodes/Elements/Ceiling.cs @@ -34,6 +34,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalCeiling; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetCeiling(element as Autodesk.Revit.DB.Ceiling); + } + #endregion #region Private constructors @@ -117,7 +126,8 @@ public static Ceiling ByOutlineTypeAndLevel(Curve[] outlineCurves, CeilingType c } var ceiling = ByOutlineTypeAndLevel(PolyCurve.ByJoinedCurves(outlineCurves), ceilingType, level); - DocumentManager.Regenerate(); + if (!TransactionManager.Instance.DisableTransactions) + DocumentManager.Regenerate(); return ceiling; } @@ -161,7 +171,8 @@ public static Ceiling ByOutlineTypeAndLevel(PolyCurve outline, CeilingType ceili } var ceiling = new Ceiling(loops, ceilingType.InternalCeilingType, level.InternalLevel); - DocumentManager.Regenerate(); + if (!TransactionManager.Instance.DisableTransactions) + DocumentManager.Regenerate(); return ceiling; } diff --git a/src/Libraries/RevitNodes/Elements/CurtainSystem.cs b/src/Libraries/RevitNodes/Elements/CurtainSystem.cs index 9643fca53..782aff75f 100644 --- a/src/Libraries/RevitNodes/Elements/CurtainSystem.cs +++ b/src/Libraries/RevitNodes/Elements/CurtainSystem.cs @@ -32,6 +32,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalCurtainSystem; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetCurtainSystem(element as Autodesk.Revit.DB.CurtainSystem); + } + #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/CurveElement.cs b/src/Libraries/RevitNodes/Elements/CurveElement.cs index 6c02744ba..6bf84c48c 100644 --- a/src/Libraries/RevitNodes/Elements/CurveElement.cs +++ b/src/Libraries/RevitNodes/Elements/CurveElement.cs @@ -28,6 +28,15 @@ internal Autodesk.Revit.DB.CurveElement InternalCurveElement private set; } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetCurveElement(element as Autodesk.Revit.DB.CurveElement); + } + #region public properties /// diff --git a/src/Libraries/RevitNodes/Elements/Dimension.cs b/src/Libraries/RevitNodes/Elements/Dimension.cs index e5bfe382e..041eb45a7 100644 --- a/src/Libraries/RevitNodes/Elements/Dimension.cs +++ b/src/Libraries/RevitNodes/Elements/Dimension.cs @@ -37,6 +37,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalRevitElement; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetElement(element as Autodesk.Revit.DB.Dimension); + } + #endregion #region Private mutators diff --git a/src/Libraries/RevitNodes/Elements/DimensionType.cs b/src/Libraries/RevitNodes/Elements/DimensionType.cs index c3a128b24..d22c2efef 100644 --- a/src/Libraries/RevitNodes/Elements/DimensionType.cs +++ b/src/Libraries/RevitNodes/Elements/DimensionType.cs @@ -31,6 +31,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalRevitElement; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetElement(element as Autodesk.Revit.DB.DimensionType); + } + #endregion #region Private mutators diff --git a/src/Libraries/RevitNodes/Elements/DirectShape.cs b/src/Libraries/RevitNodes/Elements/DirectShape.cs index 29a1c675a..03215408d 100644 --- a/src/Libraries/RevitNodes/Elements/DirectShape.cs +++ b/src/Libraries/RevitNodes/Elements/DirectShape.cs @@ -86,6 +86,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalDirectShape; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetDirectShape(element as Autodesk.Revit.DB.DirectShape); + } + #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/DividedPath.cs b/src/Libraries/RevitNodes/Elements/DividedPath.cs index b017489fb..ab3eb5b09 100644 --- a/src/Libraries/RevitNodes/Elements/DividedPath.cs +++ b/src/Libraries/RevitNodes/Elements/DividedPath.cs @@ -47,6 +47,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalDividedPath; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetDividedPath(element as Autodesk.Revit.DB.DividedPath); + } + /// /// All points along the DividedPath. /// diff --git a/src/Libraries/RevitNodes/Elements/DividedSurface.cs b/src/Libraries/RevitNodes/Elements/DividedSurface.cs index fd5d6fc4d..1d9335cfa 100644 --- a/src/Libraries/RevitNodes/Elements/DividedSurface.cs +++ b/src/Libraries/RevitNodes/Elements/DividedSurface.cs @@ -34,6 +34,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalDividedSurface; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetDividedSurface(element as Autodesk.Revit.DB.DividedSurface); + } + #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/Element.cs b/src/Libraries/RevitNodes/Elements/Element.cs index aa1abf303..54e3a43a4 100644 --- a/src/Libraries/RevitNodes/Elements/Element.cs +++ b/src/Libraries/RevitNodes/Elements/Element.cs @@ -30,6 +30,18 @@ public abstract class Element : IDisposable, IGraphicItem, IFormattable /// protected void SafeInit(Action init) { + if(TransactionManager.Instance.DisableTransactions) + { + var elementManager = ElementIDLifecycleManager.GetInstance(); + var element = ElementBinder.GetElementFromTrace(Document); + + if (element != null) + { + SetInternalElement(element); + elementManager.UnRegisterAssociation(element.Id.IntegerValue, this); + return; + } + } TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument); SafeInitImpl(init); @@ -210,6 +222,15 @@ public abstract Autodesk.Revit.DB.Element InternalElement get; } + /// + /// + /// + /// + internal virtual void SetInternalElement(Autodesk.Revit.DB.Element element) + { + // Implement in subclass + } + private ElementId internalId; /// @@ -280,7 +301,8 @@ public virtual void Dispose() // closing homeworkspace or the element itself is frozen. if (DisposeLogic.IsShuttingDown || DisposeLogic.IsClosingHomeworkspace || IsFrozen) return; - + if (TransactionManager.Instance.DisableTransactions) + return; bool didRevitDelete = ElementIDLifecycleManager.GetInstance().IsRevitDeleted(Id); var elementManager = ElementIDLifecycleManager.GetInstance(); @@ -302,7 +324,8 @@ public virtual void Dispose() throw new InvalidOperationException(string.Format(Properties.Resources.CantCloseLastOpenView, this.ToString())); } } - DocumentManager.Instance.DeleteElement(new ElementUUID(InternalUniqueId)); + if(!TransactionManager.Instance.DisableTransactions) + DocumentManager.Instance.DeleteElement(new ElementUUID(InternalUniqueId)); } else { diff --git a/src/Libraries/RevitNodes/Elements/ElementType.cs b/src/Libraries/RevitNodes/Elements/ElementType.cs index d1fa65f31..66a7cbd82 100644 --- a/src/Libraries/RevitNodes/Elements/ElementType.cs +++ b/src/Libraries/RevitNodes/Elements/ElementType.cs @@ -36,6 +36,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalElementType; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InitElementType(element as Autodesk.Revit.DB.ElementType); + } + #endregion #region Protected constructors diff --git a/src/Libraries/RevitNodes/Elements/ElevationMarker.cs b/src/Libraries/RevitNodes/Elements/ElevationMarker.cs index 72488ca63..6227dbe54 100644 --- a/src/Libraries/RevitNodes/Elements/ElevationMarker.cs +++ b/src/Libraries/RevitNodes/Elements/ElevationMarker.cs @@ -33,6 +33,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalMarker; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetElevationMarker(element as Autodesk.Revit.DB.ElevationMarker); + } + #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/FaceWall.cs b/src/Libraries/RevitNodes/Elements/FaceWall.cs index 0f814905c..1287d761e 100644 --- a/src/Libraries/RevitNodes/Elements/FaceWall.cs +++ b/src/Libraries/RevitNodes/Elements/FaceWall.cs @@ -32,6 +32,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalFaceWall; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetFaceWall(element as Autodesk.Revit.DB.FaceWall); + } + #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/Family.cs b/src/Libraries/RevitNodes/Elements/Family.cs index f6b4bbe95..c175c35f9 100644 --- a/src/Libraries/RevitNodes/Elements/Family.cs +++ b/src/Libraries/RevitNodes/Elements/Family.cs @@ -28,6 +28,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalFamily; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetFamily(element as Autodesk.Revit.DB.Family); + } + #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/FillPatternElement.cs b/src/Libraries/RevitNodes/Elements/FillPatternElement.cs index 89f578bfa..b6c055716 100644 --- a/src/Libraries/RevitNodes/Elements/FillPatternElement.cs +++ b/src/Libraries/RevitNodes/Elements/FillPatternElement.cs @@ -30,6 +30,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalRevitElement; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetElement(element as Autodesk.Revit.DB.FillPatternElement); + } + #endregion #region Private mutators diff --git a/src/Libraries/RevitNodes/Elements/FilledRegion.cs b/src/Libraries/RevitNodes/Elements/FilledRegion.cs index 492c671f0..3d3129638 100644 --- a/src/Libraries/RevitNodes/Elements/FilledRegion.cs +++ b/src/Libraries/RevitNodes/Elements/FilledRegion.cs @@ -35,6 +35,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalRevitElement; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetElement(element as Autodesk.Revit.DB.FilledRegion); + } + #endregion #region Private mutators diff --git a/src/Libraries/RevitNodes/Elements/Floor.cs b/src/Libraries/RevitNodes/Elements/Floor.cs index 9fb66904e..08824497f 100644 --- a/src/Libraries/RevitNodes/Elements/Floor.cs +++ b/src/Libraries/RevitNodes/Elements/Floor.cs @@ -35,6 +35,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalFloor; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetFloor(element as Autodesk.Revit.DB.Floor); + } + private static readonly double Tolerance = 1e-6; #endregion @@ -126,7 +135,8 @@ public static Floor ByOutlineTypeAndLevel(Curve[] outlineCurves, FloorType floor } var floor = ByOutlineTypeAndLevel(PolyCurve.ByJoinedCurves(outlineCurves), floorType, level); - DocumentManager.Regenerate(); + if (!TransactionManager.Instance.DisableTransactions) + DocumentManager.Regenerate(); return floor; } @@ -173,7 +183,8 @@ public static Floor ByOutlineTypeAndLevel(PolyCurve outline, FloorType floorType } var floor = new Floor(loops, floorType.InternalFloorType, level.InternalLevel, offset); - DocumentManager.Regenerate(); + if(!TransactionManager.Instance.DisableTransactions) + DocumentManager.Regenerate(); return floor; } diff --git a/src/Libraries/RevitNodes/Elements/Form.cs b/src/Libraries/RevitNodes/Elements/Form.cs index 5299f0e82..d1cd925db 100644 --- a/src/Libraries/RevitNodes/Elements/Form.cs +++ b/src/Libraries/RevitNodes/Elements/Form.cs @@ -30,6 +30,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalForm; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetForm(element as Autodesk.Revit.DB.Form); + } + #endregion #region Private constructor diff --git a/src/Libraries/RevitNodes/Elements/FreeForm.cs b/src/Libraries/RevitNodes/Elements/FreeForm.cs index 4f0f050bf..09052dcd9 100644 --- a/src/Libraries/RevitNodes/Elements/FreeForm.cs +++ b/src/Libraries/RevitNodes/Elements/FreeForm.cs @@ -36,6 +36,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalFreeFormElement; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetFreeFormElement(element as Autodesk.Revit.DB.FreeFormElement); + } + #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/GlobalParameter.cs b/src/Libraries/RevitNodes/Elements/GlobalParameter.cs index 464a1fdf0..c6e57cbf8 100644 --- a/src/Libraries/RevitNodes/Elements/GlobalParameter.cs +++ b/src/Libraries/RevitNodes/Elements/GlobalParameter.cs @@ -33,6 +33,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalGlobalParameter; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetGlobalParameter(element as Autodesk.Revit.DB.GlobalParameter); + } + #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/Grid.cs b/src/Libraries/RevitNodes/Elements/Grid.cs index f5e545a8c..c324571a6 100644 --- a/src/Libraries/RevitNodes/Elements/Grid.cs +++ b/src/Libraries/RevitNodes/Elements/Grid.cs @@ -33,6 +33,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalGrid; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetGrid(element as Autodesk.Revit.DB.Grid); + } + #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/Group.cs b/src/Libraries/RevitNodes/Elements/Group.cs index e5ed2e6ad..8ecf941e6 100644 --- a/src/Libraries/RevitNodes/Elements/Group.cs +++ b/src/Libraries/RevitNodes/Elements/Group.cs @@ -33,6 +33,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalGroup; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InitGroup(element as Autodesk.Revit.DB.Group); + } + #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/ImportInstance.cs b/src/Libraries/RevitNodes/Elements/ImportInstance.cs index 7b5ff0e37..9daeed1b0 100644 --- a/src/Libraries/RevitNodes/Elements/ImportInstance.cs +++ b/src/Libraries/RevitNodes/Elements/ImportInstance.cs @@ -27,6 +27,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalImportInstance; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetImportInstance(element as Autodesk.Revit.DB.ImportInstance); + } + internal Autodesk.Revit.DB.ImportInstance InternalImportInstance { get; diff --git a/src/Libraries/RevitNodes/Elements/Level.cs b/src/Libraries/RevitNodes/Elements/Level.cs index 61e4ce6d6..f05c19c53 100644 --- a/src/Libraries/RevitNodes/Elements/Level.cs +++ b/src/Libraries/RevitNodes/Elements/Level.cs @@ -68,6 +68,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalLevel; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetLevel(element as Autodesk.Revit.DB.Level); + } + #endregion #region Private constructor diff --git a/src/Libraries/RevitNodes/Elements/LinePatternElement.cs b/src/Libraries/RevitNodes/Elements/LinePatternElement.cs index 4ad50f3dd..7a629c6ea 100644 --- a/src/Libraries/RevitNodes/Elements/LinePatternElement.cs +++ b/src/Libraries/RevitNodes/Elements/LinePatternElement.cs @@ -30,6 +30,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalRevitElement; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetElement(element as Autodesk.Revit.DB.LinePatternElement); + } + #endregion #region Private mutators diff --git a/src/Libraries/RevitNodes/Elements/Material.cs b/src/Libraries/RevitNodes/Elements/Material.cs index 2769e341f..130a34b27 100644 --- a/src/Libraries/RevitNodes/Elements/Material.cs +++ b/src/Libraries/RevitNodes/Elements/Material.cs @@ -28,6 +28,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalMaterial; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetMaterial(element as Autodesk.Revit.DB.Material); + } + #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/ModelText.cs b/src/Libraries/RevitNodes/Elements/ModelText.cs index d6c6febce..a8cd06932 100644 --- a/src/Libraries/RevitNodes/Elements/ModelText.cs +++ b/src/Libraries/RevitNodes/Elements/ModelText.cs @@ -41,6 +41,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalModelText; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetModelText(element as Autodesk.Revit.DB.ModelText); + } + #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/PathOfTravel.cs b/src/Libraries/RevitNodes/Elements/PathOfTravel.cs index 033ab0e3e..392581f7c 100644 --- a/src/Libraries/RevitNodes/Elements/PathOfTravel.cs +++ b/src/Libraries/RevitNodes/Elements/PathOfTravel.cs @@ -36,6 +36,15 @@ public override Rvt.Element InternalElement get { return m_rvtPathOfTravel; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InitPathOfTravel(element as RvtAnalysis.PathOfTravel); + } + #endregion #region Private constructors @@ -374,6 +383,21 @@ private static PathOfTravel[] InternalByViewEndPoints(Rvt.View rvtView, IEnumera { List pathsOfTravel = new List(); + if(TransactionManager.Instance.DisableTransactions) + { + IEnumerable persistRvtElements = ElementBinder.GetElementsFromTrace(Document); + if(persistRvtElements != null) + { + foreach (var ele in persistRvtElements) + { + var persisEle = new PathOfTravel(ele); + pathsOfTravel.Add(persisEle); + } + + return pathsOfTravel.ToArray(); + } + } + TransactionManager.Instance.EnsureInTransaction(Document); try diff --git a/src/Libraries/RevitNodes/Elements/ReferencePlane.cs b/src/Libraries/RevitNodes/Elements/ReferencePlane.cs index ffd19dc1a..328c392d4 100644 --- a/src/Libraries/RevitNodes/Elements/ReferencePlane.cs +++ b/src/Libraries/RevitNodes/Elements/ReferencePlane.cs @@ -38,6 +38,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalReferencePlane; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetReferencePlane(element as Autodesk.Revit.DB.ReferencePlane); + } + #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/ReferencePoint.cs b/src/Libraries/RevitNodes/Elements/ReferencePoint.cs index 8947e30aa..878ac5f19 100644 --- a/src/Libraries/RevitNodes/Elements/ReferencePoint.cs +++ b/src/Libraries/RevitNodes/Elements/ReferencePoint.cs @@ -42,6 +42,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalReferencePoint; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetReferencePoint(element as Autodesk.Revit.DB.ReferencePoint); + } + #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/Revision.cs b/src/Libraries/RevitNodes/Elements/Revision.cs index 5cdd8dc64..b745f2a6e 100644 --- a/src/Libraries/RevitNodes/Elements/Revision.cs +++ b/src/Libraries/RevitNodes/Elements/Revision.cs @@ -34,6 +34,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalRevitElement; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetElement(element as Autodesk.Revit.DB.Revision); + } + #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/RevisionCloud.cs b/src/Libraries/RevitNodes/Elements/RevisionCloud.cs index d780d23a3..c39cd0c4e 100644 --- a/src/Libraries/RevitNodes/Elements/RevisionCloud.cs +++ b/src/Libraries/RevitNodes/Elements/RevisionCloud.cs @@ -35,6 +35,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalRevitElement; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetElement(element as Autodesk.Revit.DB.RevisionCloud); + } + #endregion #region Private constructors @@ -66,7 +75,7 @@ private RevisionCloud(Autodesk.Revit.DB.View view, List /// /// Set the internal Element, ElementId, and UniqueId /// - /// + /// private void InternalSetElement(Autodesk.Revit.DB.RevisionCloud element) { InternalRevitElement = element; diff --git a/src/Libraries/RevitNodes/Elements/Roof.cs b/src/Libraries/RevitNodes/Elements/Roof.cs index 8e9be6f0b..ee6b71739 100644 --- a/src/Libraries/RevitNodes/Elements/Roof.cs +++ b/src/Libraries/RevitNodes/Elements/Roof.cs @@ -35,6 +35,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalRoof; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetRoof(element as Autodesk.Revit.DB.RoofBase); + } + #endregion #region Private constructors @@ -130,7 +139,7 @@ private void InitRoof(CurveArray curves, Autodesk.Revit.DB.Level level, Autodesk /// /// Set the InternalRoof property and the associated element id and unique id /// - /// + /// private void InternalSetRoof(Autodesk.Revit.DB.RoofBase roof) { InternalRoof = roof; @@ -165,7 +174,8 @@ public static Roof ByOutlineTypeAndLevel(Curve[] outline, RoofType roofType, Lev }); var roof = new Roof(ca, level.InternalLevel,roofType.InternalRoofType); - DocumentManager.Regenerate(); + if (!TransactionManager.Instance.DisableTransactions) + DocumentManager.Regenerate(); return roof; } @@ -194,7 +204,8 @@ public static Roof ByOutlineExtrusionTypeAndLevel(PolyCurve outline, RoofType ro }); var roof = new Roof(ca, plane.InternalReferencePlane, level.InternalLevel, roofType.InternalRoofType, extrusionStart, extrusionEnd); - DocumentManager.Regenerate(); + if (!TransactionManager.Instance.DisableTransactions) + DocumentManager.Regenerate(); return roof; } diff --git a/src/Libraries/RevitNodes/Elements/Room.cs b/src/Libraries/RevitNodes/Elements/Room.cs index 0f55c1148..4ed6c83ec 100644 --- a/src/Libraries/RevitNodes/Elements/Room.cs +++ b/src/Libraries/RevitNodes/Elements/Room.cs @@ -33,7 +33,16 @@ public override Autodesk.Revit.DB.Element InternalElement { get { return InternalRevitElement; } } - + + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetElement(element as Autodesk.Revit.DB.Architecture.Room); + } + #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/ScheduleOnSheet.cs b/src/Libraries/RevitNodes/Elements/ScheduleOnSheet.cs index 57fa7ea4d..5ac51ac60 100644 --- a/src/Libraries/RevitNodes/Elements/ScheduleOnSheet.cs +++ b/src/Libraries/RevitNodes/Elements/ScheduleOnSheet.cs @@ -31,6 +31,15 @@ public override Autodesk.Revit.DB.Element InternalElement { get { return InternalScheduleOnSheet; } } + + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetScheduleOnSheet(element as Autodesk.Revit.DB.ScheduleSheetInstance); + } #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/SketchPlane.cs b/src/Libraries/RevitNodes/Elements/SketchPlane.cs index f593b6a1f..1fc7a9c21 100644 --- a/src/Libraries/RevitNodes/Elements/SketchPlane.cs +++ b/src/Libraries/RevitNodes/Elements/SketchPlane.cs @@ -35,6 +35,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalSketchPlane; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetSketchPlane(element as Autodesk.Revit.DB.SketchPlane); + } + #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/Space.cs b/src/Libraries/RevitNodes/Elements/Space.cs index bf9cd1736..fe4251b16 100644 --- a/src/Libraries/RevitNodes/Elements/Space.cs +++ b/src/Libraries/RevitNodes/Elements/Space.cs @@ -32,6 +32,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalRevitElement; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetElement(element as Autodesk.Revit.DB.Mechanical.Space); + } + #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/SunSettings.cs b/src/Libraries/RevitNodes/Elements/SunSettings.cs index 1a81262b2..29eca2b95 100644 --- a/src/Libraries/RevitNodes/Elements/SunSettings.cs +++ b/src/Libraries/RevitNodes/Elements/SunSettings.cs @@ -38,6 +38,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalSunAndShadowSettings; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InitSunSettings(element as Autodesk.Revit.DB.SunAndShadowSettings); + } + /// /// Calculates the direction of the sun. /// diff --git a/src/Libraries/RevitNodes/Elements/TextElement.cs b/src/Libraries/RevitNodes/Elements/TextElement.cs index 9ed298b94..b88631f02 100644 --- a/src/Libraries/RevitNodes/Elements/TextElement.cs +++ b/src/Libraries/RevitNodes/Elements/TextElement.cs @@ -68,6 +68,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalRevitElement; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetElement(element); + } + /// /// Reference to the Element /// diff --git a/src/Libraries/RevitNodes/Elements/Topography.cs b/src/Libraries/RevitNodes/Elements/Topography.cs index d8f930be5..3a794801d 100644 --- a/src/Libraries/RevitNodes/Elements/Topography.cs +++ b/src/Libraries/RevitNodes/Elements/Topography.cs @@ -31,6 +31,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalTopographySurface; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetTopographySurface(element as TopographySurface); + } + #endregion #region public properties diff --git a/src/Libraries/RevitNodes/Elements/UnknownElement.cs b/src/Libraries/RevitNodes/Elements/UnknownElement.cs index 824acfb4a..bc6b0470e 100644 --- a/src/Libraries/RevitNodes/Elements/UnknownElement.cs +++ b/src/Libraries/RevitNodes/Elements/UnknownElement.cs @@ -18,6 +18,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return _element; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetElement(element); + } + /// /// Private constructor /// diff --git a/src/Libraries/RevitNodes/Elements/Viewport.cs b/src/Libraries/RevitNodes/Elements/Viewport.cs index 6eb35576c..30eb3e1dd 100644 --- a/src/Libraries/RevitNodes/Elements/Viewport.cs +++ b/src/Libraries/RevitNodes/Elements/Viewport.cs @@ -32,6 +32,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalViewport; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetViewport(element as Autodesk.Revit.DB.Viewport); + } + #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/Views/DraftingView.cs b/src/Libraries/RevitNodes/Elements/Views/DraftingView.cs index 1d379e0e8..90ad484ed 100644 --- a/src/Libraries/RevitNodes/Elements/Views/DraftingView.cs +++ b/src/Libraries/RevitNodes/Elements/Views/DraftingView.cs @@ -35,6 +35,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalViewDrafting; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetDraftingView(element as Autodesk.Revit.DB.ViewDrafting); + } + #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/Views/Legend.cs b/src/Libraries/RevitNodes/Elements/Views/Legend.cs index b4a858988..d4827b555 100644 --- a/src/Libraries/RevitNodes/Elements/Views/Legend.cs +++ b/src/Libraries/RevitNodes/Elements/Views/Legend.cs @@ -27,6 +27,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalLegend; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetLegend(element as Autodesk.Revit.DB.View); + } + #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/Views/PlanView.cs b/src/Libraries/RevitNodes/Elements/Views/PlanView.cs index ff00aaff1..cbf7dcc66 100644 --- a/src/Libraries/RevitNodes/Elements/Views/PlanView.cs +++ b/src/Libraries/RevitNodes/Elements/Views/PlanView.cs @@ -32,6 +32,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalViewPlan; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetPlanView(element as Autodesk.Revit.DB.ViewPlan); + } + #endregion #region Protected mutators diff --git a/src/Libraries/RevitNodes/Elements/Views/ScheduleView.cs b/src/Libraries/RevitNodes/Elements/Views/ScheduleView.cs index 5fb536f6b..e70b3cf69 100644 --- a/src/Libraries/RevitNodes/Elements/Views/ScheduleView.cs +++ b/src/Libraries/RevitNodes/Elements/Views/ScheduleView.cs @@ -34,6 +34,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalViewSchedule; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetScheduleView(element as Autodesk.Revit.DB.ViewSchedule); + } + /// /// Reference to Schedule Filters /// diff --git a/src/Libraries/RevitNodes/Elements/Views/SectionView.cs b/src/Libraries/RevitNodes/Elements/Views/SectionView.cs index e2b454a1f..41f594fb3 100644 --- a/src/Libraries/RevitNodes/Elements/Views/SectionView.cs +++ b/src/Libraries/RevitNodes/Elements/Views/SectionView.cs @@ -38,6 +38,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalViewSection; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetSectionView(element as Autodesk.Revit.DB.ViewSection); + } + #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/Views/Sheet.cs b/src/Libraries/RevitNodes/Elements/Views/Sheet.cs index b28407d48..799d8521a 100644 --- a/src/Libraries/RevitNodes/Elements/Views/Sheet.cs +++ b/src/Libraries/RevitNodes/Elements/Views/Sheet.cs @@ -37,6 +37,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalViewSheet; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetViewSheet(element as Autodesk.Revit.DB.ViewSheet); + } + public override void Dispose() { if (DuplicateViews != null) @@ -398,12 +407,12 @@ private void InternalAddViewsToSheetView(IEnumerable vie /// /// Set the InternalViewSheet property and the associated element id and unique id /// - /// - private void InternalSetViewSheet(Autodesk.Revit.DB.ViewSheet floor) + /// + private void InternalSetViewSheet(Autodesk.Revit.DB.ViewSheet viewSheet) { - this.InternalViewSheet = floor; - this.InternalElementId = floor.Id; - this.InternalUniqueId = floor.UniqueId; + this.InternalViewSheet = viewSheet; + this.InternalElementId = viewSheet.Id; + this.InternalUniqueId = viewSheet.UniqueId; } /// @@ -737,9 +746,20 @@ public static Sheet DuplicateSheet(Sheet sheet, bool duplicateWithContents = fal Sheet newSheet = null; + if(TransactionManager.Instance.DisableTransactions) + { + var oldSheet = ElementBinder.GetElementFromTrace(Document); + if(oldSheet != null) + { + newSheet = new Sheet(oldSheet); + + return newSheet; + } + } + try { - RevitServices.Transactions.TransactionManager.Instance.EnsureInTransaction(Application.Document.Current.InternalDocument); + TransactionManager.Instance.EnsureInTransaction(Application.Document.Current.InternalDocument); var oldElements = ElementBinder.GetElementsFromTrace(Document); List elementIds = new List(); diff --git a/src/Libraries/RevitNodes/Elements/Views/View3D.cs b/src/Libraries/RevitNodes/Elements/Views/View3D.cs index 2f32c24c4..53dde64d1 100644 --- a/src/Libraries/RevitNodes/Elements/Views/View3D.cs +++ b/src/Libraries/RevitNodes/Elements/Views/View3D.cs @@ -32,6 +32,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalView3D; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetView3D(element as Autodesk.Revit.DB.View3D); + } + #endregion #region Private helper methods diff --git a/src/Libraries/RevitNodes/Elements/Wall.cs b/src/Libraries/RevitNodes/Elements/Wall.cs index a1ada7320..11f7c565b 100644 --- a/src/Libraries/RevitNodes/Elements/Wall.cs +++ b/src/Libraries/RevitNodes/Elements/Wall.cs @@ -31,6 +31,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalWall; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetWall(element as Autodesk.Revit.DB.Wall); + } + #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Filter/ParameterFilterElement.cs b/src/Libraries/RevitNodes/Filter/ParameterFilterElement.cs index 070cf30f2..4d170a123 100644 --- a/src/Libraries/RevitNodes/Filter/ParameterFilterElement.cs +++ b/src/Libraries/RevitNodes/Filter/ParameterFilterElement.cs @@ -34,6 +34,15 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalRevitElement; } } + /// + /// Set Internal Element from a exsiting element. + /// + /// + internal override void SetInternalElement(Autodesk.Revit.DB.Element element) + { + InternalSetElement(element as Autodesk.Revit.DB.ParameterFilterElement); + } + #endregion #region Private mutators diff --git a/src/Libraries/RevitServices/Persistence/ElementIDLifecycleManager.cs b/src/Libraries/RevitServices/Persistence/ElementIDLifecycleManager.cs index 8da651b0f..1125102da 100644 --- a/src/Libraries/RevitServices/Persistence/ElementIDLifecycleManager.cs +++ b/src/Libraries/RevitServices/Persistence/ElementIDLifecycleManager.cs @@ -100,8 +100,13 @@ public int UnRegisterAssociation(T elementID, Object wrapper) //ID already existed, check we're not over adding if (existingWrappers.Contains(wrapper)) { - int index = existingWrappers.FindIndex((x) => object.ReferenceEquals(x, wrapper)); - existingWrappers.RemoveAt(index); + var removeList = existingWrappers.FindAll((x) => object.ReferenceEquals(x, wrapper)); + for (int i = 0; i < removeList.Count; i++) + { + int index = existingWrappers.FindIndex((x) => object.ReferenceEquals(x, wrapper)); + existingWrappers.RemoveAt(index); + } + if (existingWrappers.Count == 0) { wrappers.Remove(elementID); From 2e26ec48a723a3d41f237ea36ca4bb04ece9cb0f Mon Sep 17 00:00:00 2001 From: Ziyun Shang Date: Tue, 2 Nov 2021 17:31:34 +0800 Subject: [PATCH 2/4] Change InternalElement to virtual in Element class --- .../RevitNodes/Elements/AbstractFamilyInstance.cs | 9 --------- src/Libraries/RevitNodes/Elements/Area.cs | 9 --------- src/Libraries/RevitNodes/Elements/Ceiling.cs | 9 --------- src/Libraries/RevitNodes/Elements/CurtainSystem.cs | 9 --------- src/Libraries/RevitNodes/Elements/CurveElement.cs | 9 --------- src/Libraries/RevitNodes/Elements/Dimension.cs | 9 --------- src/Libraries/RevitNodes/Elements/DimensionType.cs | 9 --------- src/Libraries/RevitNodes/Elements/DirectShape.cs | 9 --------- src/Libraries/RevitNodes/Elements/DividedPath.cs | 9 --------- src/Libraries/RevitNodes/Elements/DividedSurface.cs | 9 --------- src/Libraries/RevitNodes/Elements/Element.cs | 11 +++++++---- src/Libraries/RevitNodes/Elements/ElementType.cs | 9 --------- src/Libraries/RevitNodes/Elements/ElevationMarker.cs | 9 --------- src/Libraries/RevitNodes/Elements/FaceWall.cs | 9 --------- src/Libraries/RevitNodes/Elements/Family.cs | 9 --------- .../RevitNodes/Elements/FillPatternElement.cs | 9 --------- src/Libraries/RevitNodes/Elements/FilledRegion.cs | 9 --------- src/Libraries/RevitNodes/Elements/Floor.cs | 9 --------- src/Libraries/RevitNodes/Elements/Form.cs | 9 --------- src/Libraries/RevitNodes/Elements/FreeForm.cs | 9 --------- src/Libraries/RevitNodes/Elements/GlobalParameter.cs | 9 --------- src/Libraries/RevitNodes/Elements/Grid.cs | 9 --------- src/Libraries/RevitNodes/Elements/Group.cs | 9 --------- src/Libraries/RevitNodes/Elements/ImportInstance.cs | 9 --------- src/Libraries/RevitNodes/Elements/Level.cs | 9 --------- .../RevitNodes/Elements/LinePatternElement.cs | 9 --------- src/Libraries/RevitNodes/Elements/Material.cs | 9 --------- src/Libraries/RevitNodes/Elements/ModelText.cs | 9 --------- src/Libraries/RevitNodes/Elements/PathOfTravel.cs | 9 --------- src/Libraries/RevitNodes/Elements/ReferencePlane.cs | 9 --------- src/Libraries/RevitNodes/Elements/ReferencePoint.cs | 9 --------- src/Libraries/RevitNodes/Elements/Revision.cs | 9 --------- src/Libraries/RevitNodes/Elements/RevisionCloud.cs | 9 --------- src/Libraries/RevitNodes/Elements/Roof.cs | 9 --------- src/Libraries/RevitNodes/Elements/Room.cs | 9 --------- src/Libraries/RevitNodes/Elements/ScheduleOnSheet.cs | 9 --------- src/Libraries/RevitNodes/Elements/SketchPlane.cs | 9 --------- src/Libraries/RevitNodes/Elements/Space.cs | 9 --------- src/Libraries/RevitNodes/Elements/SunSettings.cs | 9 --------- src/Libraries/RevitNodes/Elements/TextElement.cs | 11 +---------- src/Libraries/RevitNodes/Elements/Topography.cs | 9 --------- src/Libraries/RevitNodes/Elements/UnknownElement.cs | 9 --------- src/Libraries/RevitNodes/Elements/Viewport.cs | 9 --------- .../RevitNodes/Elements/Views/DraftingView.cs | 9 --------- src/Libraries/RevitNodes/Elements/Views/Legend.cs | 9 --------- src/Libraries/RevitNodes/Elements/Views/PlanView.cs | 9 --------- .../RevitNodes/Elements/Views/ScheduleView.cs | 9 --------- .../RevitNodes/Elements/Views/SectionView.cs | 9 --------- src/Libraries/RevitNodes/Elements/Views/Sheet.cs | 9 --------- src/Libraries/RevitNodes/Elements/Views/View3D.cs | 9 --------- src/Libraries/RevitNodes/Elements/Wall.cs | 9 --------- .../RevitNodes/Filter/ParameterFilterElement.cs | 9 --------- 52 files changed, 8 insertions(+), 464 deletions(-) diff --git a/src/Libraries/RevitNodes/Elements/AbstractFamilyInstance.cs b/src/Libraries/RevitNodes/Elements/AbstractFamilyInstance.cs index 13caa80b6..6d0dd778b 100644 --- a/src/Libraries/RevitNodes/Elements/AbstractFamilyInstance.cs +++ b/src/Libraries/RevitNodes/Elements/AbstractFamilyInstance.cs @@ -34,15 +34,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalFamilyInstance; } } - /// - /// - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetFamilyInstance(element as Autodesk.Revit.DB.FamilyInstance); - } - #endregion #region Protected mutators diff --git a/src/Libraries/RevitNodes/Elements/Area.cs b/src/Libraries/RevitNodes/Elements/Area.cs index b6934a6b3..3ec19cfd3 100644 --- a/src/Libraries/RevitNodes/Elements/Area.cs +++ b/src/Libraries/RevitNodes/Elements/Area.cs @@ -26,15 +26,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalArea; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetArea(element as Autodesk.Revit.DB.Area); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/Ceiling.cs b/src/Libraries/RevitNodes/Elements/Ceiling.cs index a657cd021..de24f9927 100644 --- a/src/Libraries/RevitNodes/Elements/Ceiling.cs +++ b/src/Libraries/RevitNodes/Elements/Ceiling.cs @@ -34,15 +34,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalCeiling; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetCeiling(element as Autodesk.Revit.DB.Ceiling); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/CurtainSystem.cs b/src/Libraries/RevitNodes/Elements/CurtainSystem.cs index 782aff75f..9643fca53 100644 --- a/src/Libraries/RevitNodes/Elements/CurtainSystem.cs +++ b/src/Libraries/RevitNodes/Elements/CurtainSystem.cs @@ -32,15 +32,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalCurtainSystem; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetCurtainSystem(element as Autodesk.Revit.DB.CurtainSystem); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/CurveElement.cs b/src/Libraries/RevitNodes/Elements/CurveElement.cs index 6bf84c48c..6c02744ba 100644 --- a/src/Libraries/RevitNodes/Elements/CurveElement.cs +++ b/src/Libraries/RevitNodes/Elements/CurveElement.cs @@ -28,15 +28,6 @@ internal Autodesk.Revit.DB.CurveElement InternalCurveElement private set; } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetCurveElement(element as Autodesk.Revit.DB.CurveElement); - } - #region public properties /// diff --git a/src/Libraries/RevitNodes/Elements/Dimension.cs b/src/Libraries/RevitNodes/Elements/Dimension.cs index 041eb45a7..e5bfe382e 100644 --- a/src/Libraries/RevitNodes/Elements/Dimension.cs +++ b/src/Libraries/RevitNodes/Elements/Dimension.cs @@ -37,15 +37,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalRevitElement; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetElement(element as Autodesk.Revit.DB.Dimension); - } - #endregion #region Private mutators diff --git a/src/Libraries/RevitNodes/Elements/DimensionType.cs b/src/Libraries/RevitNodes/Elements/DimensionType.cs index d22c2efef..c3a128b24 100644 --- a/src/Libraries/RevitNodes/Elements/DimensionType.cs +++ b/src/Libraries/RevitNodes/Elements/DimensionType.cs @@ -31,15 +31,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalRevitElement; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetElement(element as Autodesk.Revit.DB.DimensionType); - } - #endregion #region Private mutators diff --git a/src/Libraries/RevitNodes/Elements/DirectShape.cs b/src/Libraries/RevitNodes/Elements/DirectShape.cs index 03215408d..29a1c675a 100644 --- a/src/Libraries/RevitNodes/Elements/DirectShape.cs +++ b/src/Libraries/RevitNodes/Elements/DirectShape.cs @@ -86,15 +86,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalDirectShape; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetDirectShape(element as Autodesk.Revit.DB.DirectShape); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/DividedPath.cs b/src/Libraries/RevitNodes/Elements/DividedPath.cs index ab3eb5b09..b017489fb 100644 --- a/src/Libraries/RevitNodes/Elements/DividedPath.cs +++ b/src/Libraries/RevitNodes/Elements/DividedPath.cs @@ -47,15 +47,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalDividedPath; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetDividedPath(element as Autodesk.Revit.DB.DividedPath); - } - /// /// All points along the DividedPath. /// diff --git a/src/Libraries/RevitNodes/Elements/DividedSurface.cs b/src/Libraries/RevitNodes/Elements/DividedSurface.cs index 1d9335cfa..fd5d6fc4d 100644 --- a/src/Libraries/RevitNodes/Elements/DividedSurface.cs +++ b/src/Libraries/RevitNodes/Elements/DividedSurface.cs @@ -34,15 +34,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalDividedSurface; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetDividedSurface(element as Autodesk.Revit.DB.DividedSurface); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/Element.cs b/src/Libraries/RevitNodes/Elements/Element.cs index 54e3a43a4..e0edd282c 100644 --- a/src/Libraries/RevitNodes/Elements/Element.cs +++ b/src/Libraries/RevitNodes/Elements/Element.cs @@ -217,18 +217,21 @@ public bool AreJoined(Element otherElement) /// A reference to the element /// [SupressImportIntoVM] - public abstract Autodesk.Revit.DB.Element InternalElement + public virtual Autodesk.Revit.DB.Element InternalElement { get; + set; } /// - /// + /// Set Internal Element from a exsiting element. /// /// - internal virtual void SetInternalElement(Autodesk.Revit.DB.Element element) + internal void SetInternalElement(Autodesk.Revit.DB.Element element) { - // Implement in subclass + InternalElement = element; + InternalElementId = element.Id; + InternalUniqueId = element.UniqueId; } private ElementId internalId; diff --git a/src/Libraries/RevitNodes/Elements/ElementType.cs b/src/Libraries/RevitNodes/Elements/ElementType.cs index 66a7cbd82..d1fa65f31 100644 --- a/src/Libraries/RevitNodes/Elements/ElementType.cs +++ b/src/Libraries/RevitNodes/Elements/ElementType.cs @@ -36,15 +36,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalElementType; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InitElementType(element as Autodesk.Revit.DB.ElementType); - } - #endregion #region Protected constructors diff --git a/src/Libraries/RevitNodes/Elements/ElevationMarker.cs b/src/Libraries/RevitNodes/Elements/ElevationMarker.cs index 6227dbe54..72488ca63 100644 --- a/src/Libraries/RevitNodes/Elements/ElevationMarker.cs +++ b/src/Libraries/RevitNodes/Elements/ElevationMarker.cs @@ -33,15 +33,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalMarker; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetElevationMarker(element as Autodesk.Revit.DB.ElevationMarker); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/FaceWall.cs b/src/Libraries/RevitNodes/Elements/FaceWall.cs index 1287d761e..0f814905c 100644 --- a/src/Libraries/RevitNodes/Elements/FaceWall.cs +++ b/src/Libraries/RevitNodes/Elements/FaceWall.cs @@ -32,15 +32,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalFaceWall; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetFaceWall(element as Autodesk.Revit.DB.FaceWall); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/Family.cs b/src/Libraries/RevitNodes/Elements/Family.cs index c175c35f9..f6b4bbe95 100644 --- a/src/Libraries/RevitNodes/Elements/Family.cs +++ b/src/Libraries/RevitNodes/Elements/Family.cs @@ -28,15 +28,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalFamily; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetFamily(element as Autodesk.Revit.DB.Family); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/FillPatternElement.cs b/src/Libraries/RevitNodes/Elements/FillPatternElement.cs index b6c055716..89f578bfa 100644 --- a/src/Libraries/RevitNodes/Elements/FillPatternElement.cs +++ b/src/Libraries/RevitNodes/Elements/FillPatternElement.cs @@ -30,15 +30,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalRevitElement; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetElement(element as Autodesk.Revit.DB.FillPatternElement); - } - #endregion #region Private mutators diff --git a/src/Libraries/RevitNodes/Elements/FilledRegion.cs b/src/Libraries/RevitNodes/Elements/FilledRegion.cs index 3d3129638..492c671f0 100644 --- a/src/Libraries/RevitNodes/Elements/FilledRegion.cs +++ b/src/Libraries/RevitNodes/Elements/FilledRegion.cs @@ -35,15 +35,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalRevitElement; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetElement(element as Autodesk.Revit.DB.FilledRegion); - } - #endregion #region Private mutators diff --git a/src/Libraries/RevitNodes/Elements/Floor.cs b/src/Libraries/RevitNodes/Elements/Floor.cs index 08824497f..55b1e9dfd 100644 --- a/src/Libraries/RevitNodes/Elements/Floor.cs +++ b/src/Libraries/RevitNodes/Elements/Floor.cs @@ -35,15 +35,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalFloor; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetFloor(element as Autodesk.Revit.DB.Floor); - } - private static readonly double Tolerance = 1e-6; #endregion diff --git a/src/Libraries/RevitNodes/Elements/Form.cs b/src/Libraries/RevitNodes/Elements/Form.cs index d1cd925db..5299f0e82 100644 --- a/src/Libraries/RevitNodes/Elements/Form.cs +++ b/src/Libraries/RevitNodes/Elements/Form.cs @@ -30,15 +30,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalForm; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetForm(element as Autodesk.Revit.DB.Form); - } - #endregion #region Private constructor diff --git a/src/Libraries/RevitNodes/Elements/FreeForm.cs b/src/Libraries/RevitNodes/Elements/FreeForm.cs index 09052dcd9..4f0f050bf 100644 --- a/src/Libraries/RevitNodes/Elements/FreeForm.cs +++ b/src/Libraries/RevitNodes/Elements/FreeForm.cs @@ -36,15 +36,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalFreeFormElement; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetFreeFormElement(element as Autodesk.Revit.DB.FreeFormElement); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/GlobalParameter.cs b/src/Libraries/RevitNodes/Elements/GlobalParameter.cs index c6e57cbf8..464a1fdf0 100644 --- a/src/Libraries/RevitNodes/Elements/GlobalParameter.cs +++ b/src/Libraries/RevitNodes/Elements/GlobalParameter.cs @@ -33,15 +33,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalGlobalParameter; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetGlobalParameter(element as Autodesk.Revit.DB.GlobalParameter); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/Grid.cs b/src/Libraries/RevitNodes/Elements/Grid.cs index c324571a6..f5e545a8c 100644 --- a/src/Libraries/RevitNodes/Elements/Grid.cs +++ b/src/Libraries/RevitNodes/Elements/Grid.cs @@ -33,15 +33,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalGrid; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetGrid(element as Autodesk.Revit.DB.Grid); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/Group.cs b/src/Libraries/RevitNodes/Elements/Group.cs index 8ecf941e6..e5ed2e6ad 100644 --- a/src/Libraries/RevitNodes/Elements/Group.cs +++ b/src/Libraries/RevitNodes/Elements/Group.cs @@ -33,15 +33,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalGroup; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InitGroup(element as Autodesk.Revit.DB.Group); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/ImportInstance.cs b/src/Libraries/RevitNodes/Elements/ImportInstance.cs index 9daeed1b0..7b5ff0e37 100644 --- a/src/Libraries/RevitNodes/Elements/ImportInstance.cs +++ b/src/Libraries/RevitNodes/Elements/ImportInstance.cs @@ -27,15 +27,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalImportInstance; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetImportInstance(element as Autodesk.Revit.DB.ImportInstance); - } - internal Autodesk.Revit.DB.ImportInstance InternalImportInstance { get; diff --git a/src/Libraries/RevitNodes/Elements/Level.cs b/src/Libraries/RevitNodes/Elements/Level.cs index f05c19c53..61e4ce6d6 100644 --- a/src/Libraries/RevitNodes/Elements/Level.cs +++ b/src/Libraries/RevitNodes/Elements/Level.cs @@ -68,15 +68,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalLevel; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetLevel(element as Autodesk.Revit.DB.Level); - } - #endregion #region Private constructor diff --git a/src/Libraries/RevitNodes/Elements/LinePatternElement.cs b/src/Libraries/RevitNodes/Elements/LinePatternElement.cs index 7a629c6ea..4ad50f3dd 100644 --- a/src/Libraries/RevitNodes/Elements/LinePatternElement.cs +++ b/src/Libraries/RevitNodes/Elements/LinePatternElement.cs @@ -30,15 +30,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalRevitElement; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetElement(element as Autodesk.Revit.DB.LinePatternElement); - } - #endregion #region Private mutators diff --git a/src/Libraries/RevitNodes/Elements/Material.cs b/src/Libraries/RevitNodes/Elements/Material.cs index 130a34b27..2769e341f 100644 --- a/src/Libraries/RevitNodes/Elements/Material.cs +++ b/src/Libraries/RevitNodes/Elements/Material.cs @@ -28,15 +28,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalMaterial; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetMaterial(element as Autodesk.Revit.DB.Material); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/ModelText.cs b/src/Libraries/RevitNodes/Elements/ModelText.cs index a8cd06932..d6c6febce 100644 --- a/src/Libraries/RevitNodes/Elements/ModelText.cs +++ b/src/Libraries/RevitNodes/Elements/ModelText.cs @@ -41,15 +41,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalModelText; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetModelText(element as Autodesk.Revit.DB.ModelText); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/PathOfTravel.cs b/src/Libraries/RevitNodes/Elements/PathOfTravel.cs index 392581f7c..ee736677d 100644 --- a/src/Libraries/RevitNodes/Elements/PathOfTravel.cs +++ b/src/Libraries/RevitNodes/Elements/PathOfTravel.cs @@ -36,15 +36,6 @@ public override Rvt.Element InternalElement get { return m_rvtPathOfTravel; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InitPathOfTravel(element as RvtAnalysis.PathOfTravel); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/ReferencePlane.cs b/src/Libraries/RevitNodes/Elements/ReferencePlane.cs index 328c392d4..ffd19dc1a 100644 --- a/src/Libraries/RevitNodes/Elements/ReferencePlane.cs +++ b/src/Libraries/RevitNodes/Elements/ReferencePlane.cs @@ -38,15 +38,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalReferencePlane; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetReferencePlane(element as Autodesk.Revit.DB.ReferencePlane); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/ReferencePoint.cs b/src/Libraries/RevitNodes/Elements/ReferencePoint.cs index 878ac5f19..8947e30aa 100644 --- a/src/Libraries/RevitNodes/Elements/ReferencePoint.cs +++ b/src/Libraries/RevitNodes/Elements/ReferencePoint.cs @@ -42,15 +42,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalReferencePoint; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetReferencePoint(element as Autodesk.Revit.DB.ReferencePoint); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/Revision.cs b/src/Libraries/RevitNodes/Elements/Revision.cs index b745f2a6e..5cdd8dc64 100644 --- a/src/Libraries/RevitNodes/Elements/Revision.cs +++ b/src/Libraries/RevitNodes/Elements/Revision.cs @@ -34,15 +34,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalRevitElement; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetElement(element as Autodesk.Revit.DB.Revision); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/RevisionCloud.cs b/src/Libraries/RevitNodes/Elements/RevisionCloud.cs index c39cd0c4e..298c4dbc0 100644 --- a/src/Libraries/RevitNodes/Elements/RevisionCloud.cs +++ b/src/Libraries/RevitNodes/Elements/RevisionCloud.cs @@ -35,15 +35,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalRevitElement; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetElement(element as Autodesk.Revit.DB.RevisionCloud); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/Roof.cs b/src/Libraries/RevitNodes/Elements/Roof.cs index ee6b71739..a3c4cb9e1 100644 --- a/src/Libraries/RevitNodes/Elements/Roof.cs +++ b/src/Libraries/RevitNodes/Elements/Roof.cs @@ -35,15 +35,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalRoof; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetRoof(element as Autodesk.Revit.DB.RoofBase); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/Room.cs b/src/Libraries/RevitNodes/Elements/Room.cs index 4ed6c83ec..197a5f188 100644 --- a/src/Libraries/RevitNodes/Elements/Room.cs +++ b/src/Libraries/RevitNodes/Elements/Room.cs @@ -34,15 +34,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalRevitElement; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetElement(element as Autodesk.Revit.DB.Architecture.Room); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/ScheduleOnSheet.cs b/src/Libraries/RevitNodes/Elements/ScheduleOnSheet.cs index 5ac51ac60..57fa7ea4d 100644 --- a/src/Libraries/RevitNodes/Elements/ScheduleOnSheet.cs +++ b/src/Libraries/RevitNodes/Elements/ScheduleOnSheet.cs @@ -31,15 +31,6 @@ public override Autodesk.Revit.DB.Element InternalElement { get { return InternalScheduleOnSheet; } } - - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetScheduleOnSheet(element as Autodesk.Revit.DB.ScheduleSheetInstance); - } #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/SketchPlane.cs b/src/Libraries/RevitNodes/Elements/SketchPlane.cs index 1fc7a9c21..f593b6a1f 100644 --- a/src/Libraries/RevitNodes/Elements/SketchPlane.cs +++ b/src/Libraries/RevitNodes/Elements/SketchPlane.cs @@ -35,15 +35,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalSketchPlane; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetSketchPlane(element as Autodesk.Revit.DB.SketchPlane); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/Space.cs b/src/Libraries/RevitNodes/Elements/Space.cs index fe4251b16..bf9cd1736 100644 --- a/src/Libraries/RevitNodes/Elements/Space.cs +++ b/src/Libraries/RevitNodes/Elements/Space.cs @@ -32,15 +32,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalRevitElement; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetElement(element as Autodesk.Revit.DB.Mechanical.Space); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/SunSettings.cs b/src/Libraries/RevitNodes/Elements/SunSettings.cs index 29eca2b95..1a81262b2 100644 --- a/src/Libraries/RevitNodes/Elements/SunSettings.cs +++ b/src/Libraries/RevitNodes/Elements/SunSettings.cs @@ -38,15 +38,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalSunAndShadowSettings; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InitSunSettings(element as Autodesk.Revit.DB.SunAndShadowSettings); - } - /// /// Calculates the direction of the sun. /// diff --git a/src/Libraries/RevitNodes/Elements/TextElement.cs b/src/Libraries/RevitNodes/Elements/TextElement.cs index b88631f02..fbfd0d8ea 100644 --- a/src/Libraries/RevitNodes/Elements/TextElement.cs +++ b/src/Libraries/RevitNodes/Elements/TextElement.cs @@ -67,16 +67,7 @@ public override Autodesk.Revit.DB.Element InternalElement { get { return InternalRevitElement; } } - - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetElement(element); - } - + /// /// Reference to the Element /// diff --git a/src/Libraries/RevitNodes/Elements/Topography.cs b/src/Libraries/RevitNodes/Elements/Topography.cs index 3a794801d..d8f930be5 100644 --- a/src/Libraries/RevitNodes/Elements/Topography.cs +++ b/src/Libraries/RevitNodes/Elements/Topography.cs @@ -31,15 +31,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalTopographySurface; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetTopographySurface(element as TopographySurface); - } - #endregion #region public properties diff --git a/src/Libraries/RevitNodes/Elements/UnknownElement.cs b/src/Libraries/RevitNodes/Elements/UnknownElement.cs index bc6b0470e..824acfb4a 100644 --- a/src/Libraries/RevitNodes/Elements/UnknownElement.cs +++ b/src/Libraries/RevitNodes/Elements/UnknownElement.cs @@ -18,15 +18,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return _element; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetElement(element); - } - /// /// Private constructor /// diff --git a/src/Libraries/RevitNodes/Elements/Viewport.cs b/src/Libraries/RevitNodes/Elements/Viewport.cs index 30eb3e1dd..6eb35576c 100644 --- a/src/Libraries/RevitNodes/Elements/Viewport.cs +++ b/src/Libraries/RevitNodes/Elements/Viewport.cs @@ -32,15 +32,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalViewport; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetViewport(element as Autodesk.Revit.DB.Viewport); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/Views/DraftingView.cs b/src/Libraries/RevitNodes/Elements/Views/DraftingView.cs index 90ad484ed..1d379e0e8 100644 --- a/src/Libraries/RevitNodes/Elements/Views/DraftingView.cs +++ b/src/Libraries/RevitNodes/Elements/Views/DraftingView.cs @@ -35,15 +35,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalViewDrafting; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetDraftingView(element as Autodesk.Revit.DB.ViewDrafting); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/Views/Legend.cs b/src/Libraries/RevitNodes/Elements/Views/Legend.cs index d4827b555..b4a858988 100644 --- a/src/Libraries/RevitNodes/Elements/Views/Legend.cs +++ b/src/Libraries/RevitNodes/Elements/Views/Legend.cs @@ -27,15 +27,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalLegend; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetLegend(element as Autodesk.Revit.DB.View); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/Views/PlanView.cs b/src/Libraries/RevitNodes/Elements/Views/PlanView.cs index cbf7dcc66..ff00aaff1 100644 --- a/src/Libraries/RevitNodes/Elements/Views/PlanView.cs +++ b/src/Libraries/RevitNodes/Elements/Views/PlanView.cs @@ -32,15 +32,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalViewPlan; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetPlanView(element as Autodesk.Revit.DB.ViewPlan); - } - #endregion #region Protected mutators diff --git a/src/Libraries/RevitNodes/Elements/Views/ScheduleView.cs b/src/Libraries/RevitNodes/Elements/Views/ScheduleView.cs index e70b3cf69..5fb536f6b 100644 --- a/src/Libraries/RevitNodes/Elements/Views/ScheduleView.cs +++ b/src/Libraries/RevitNodes/Elements/Views/ScheduleView.cs @@ -34,15 +34,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalViewSchedule; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetScheduleView(element as Autodesk.Revit.DB.ViewSchedule); - } - /// /// Reference to Schedule Filters /// diff --git a/src/Libraries/RevitNodes/Elements/Views/SectionView.cs b/src/Libraries/RevitNodes/Elements/Views/SectionView.cs index 41f594fb3..e2b454a1f 100644 --- a/src/Libraries/RevitNodes/Elements/Views/SectionView.cs +++ b/src/Libraries/RevitNodes/Elements/Views/SectionView.cs @@ -38,15 +38,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalViewSection; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetSectionView(element as Autodesk.Revit.DB.ViewSection); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Elements/Views/Sheet.cs b/src/Libraries/RevitNodes/Elements/Views/Sheet.cs index 799d8521a..7e382e39d 100644 --- a/src/Libraries/RevitNodes/Elements/Views/Sheet.cs +++ b/src/Libraries/RevitNodes/Elements/Views/Sheet.cs @@ -37,15 +37,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalViewSheet; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetViewSheet(element as Autodesk.Revit.DB.ViewSheet); - } - public override void Dispose() { if (DuplicateViews != null) diff --git a/src/Libraries/RevitNodes/Elements/Views/View3D.cs b/src/Libraries/RevitNodes/Elements/Views/View3D.cs index 53dde64d1..2f32c24c4 100644 --- a/src/Libraries/RevitNodes/Elements/Views/View3D.cs +++ b/src/Libraries/RevitNodes/Elements/Views/View3D.cs @@ -32,15 +32,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalView3D; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetView3D(element as Autodesk.Revit.DB.View3D); - } - #endregion #region Private helper methods diff --git a/src/Libraries/RevitNodes/Elements/Wall.cs b/src/Libraries/RevitNodes/Elements/Wall.cs index 11f7c565b..a1ada7320 100644 --- a/src/Libraries/RevitNodes/Elements/Wall.cs +++ b/src/Libraries/RevitNodes/Elements/Wall.cs @@ -31,15 +31,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalWall; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetWall(element as Autodesk.Revit.DB.Wall); - } - #endregion #region Private constructors diff --git a/src/Libraries/RevitNodes/Filter/ParameterFilterElement.cs b/src/Libraries/RevitNodes/Filter/ParameterFilterElement.cs index 4d170a123..070cf30f2 100644 --- a/src/Libraries/RevitNodes/Filter/ParameterFilterElement.cs +++ b/src/Libraries/RevitNodes/Filter/ParameterFilterElement.cs @@ -34,15 +34,6 @@ public override Autodesk.Revit.DB.Element InternalElement get { return InternalRevitElement; } } - /// - /// Set Internal Element from a exsiting element. - /// - /// - internal override void SetInternalElement(Autodesk.Revit.DB.Element element) - { - InternalSetElement(element as Autodesk.Revit.DB.ParameterFilterElement); - } - #endregion #region Private mutators From da1d3a968c0cc1ae4ba383a61c3ce14e35222413 Mon Sep 17 00:00:00 2001 From: Ziyun Shang Date: Fri, 5 Nov 2021 10:18:01 +0800 Subject: [PATCH 3/4] Managed elementid lifecycle when Transaction disabled, and revert some debug code --- src/Libraries/RevitNodes/Elements/Element.cs | 15 ++++++++++++--- src/Libraries/RevitNodes/Elements/TextElement.cs | 2 +- .../Persistence/ElementIDLifecycleManager.cs | 9 +++------ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/Libraries/RevitNodes/Elements/Element.cs b/src/Libraries/RevitNodes/Elements/Element.cs index e0edd282c..b023ba684 100644 --- a/src/Libraries/RevitNodes/Elements/Element.cs +++ b/src/Libraries/RevitNodes/Elements/Element.cs @@ -34,11 +34,13 @@ protected void SafeInit(Action init) { var elementManager = ElementIDLifecycleManager.GetInstance(); var element = ElementBinder.GetElementFromTrace(Document); + int count = elementManager.GetRegisteredCount(element.Id.IntegerValue); if (element != null) { SetInternalElement(element); - elementManager.UnRegisterAssociation(element.Id.IntegerValue, this); + if (count > 0) + elementManager.UnRegisterAssociation(Id, this); return; } } @@ -304,11 +306,18 @@ public virtual void Dispose() // closing homeworkspace or the element itself is frozen. if (DisposeLogic.IsShuttingDown || DisposeLogic.IsClosingHomeworkspace || IsFrozen) return; - if (TransactionManager.Instance.DisableTransactions) - return; + bool didRevitDelete = ElementIDLifecycleManager.GetInstance().IsRevitDeleted(Id); var elementManager = ElementIDLifecycleManager.GetInstance(); + + if (TransactionManager.Instance.DisableTransactions) + { + int count = elementManager.GetRegisteredCount(Id); + if(count > 0) + elementManager.UnRegisterAssociation(Id, this); + return; + } int remainingBindings = elementManager.UnRegisterAssociation(Id, this); // Do not delete Revit owned elements diff --git a/src/Libraries/RevitNodes/Elements/TextElement.cs b/src/Libraries/RevitNodes/Elements/TextElement.cs index fbfd0d8ea..9ed298b94 100644 --- a/src/Libraries/RevitNodes/Elements/TextElement.cs +++ b/src/Libraries/RevitNodes/Elements/TextElement.cs @@ -67,7 +67,7 @@ public override Autodesk.Revit.DB.Element InternalElement { get { return InternalRevitElement; } } - + /// /// Reference to the Element /// diff --git a/src/Libraries/RevitServices/Persistence/ElementIDLifecycleManager.cs b/src/Libraries/RevitServices/Persistence/ElementIDLifecycleManager.cs index 1125102da..368116357 100644 --- a/src/Libraries/RevitServices/Persistence/ElementIDLifecycleManager.cs +++ b/src/Libraries/RevitServices/Persistence/ElementIDLifecycleManager.cs @@ -100,13 +100,10 @@ public int UnRegisterAssociation(T elementID, Object wrapper) //ID already existed, check we're not over adding if (existingWrappers.Contains(wrapper)) { - var removeList = existingWrappers.FindAll((x) => object.ReferenceEquals(x, wrapper)); - for (int i = 0; i < removeList.Count; i++) - { - int index = existingWrappers.FindIndex((x) => object.ReferenceEquals(x, wrapper)); + int index = existingWrappers.FindIndex((x) => object.ReferenceEquals(x, wrapper)); + if(index != -1) existingWrappers.RemoveAt(index); - } - + if (existingWrappers.Count == 0) { wrappers.Remove(elementID); From 8aeee7cd94f96fd32c80c1d0c7ffa6676e594442 Mon Sep 17 00:00:00 2001 From: Ziyun Shang Date: Mon, 8 Nov 2021 12:46:23 +0800 Subject: [PATCH 4/4] Deal with PathOfTravel node when Diabled Transaction --- .../RevitNodes/Elements/PathOfTravel.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Libraries/RevitNodes/Elements/PathOfTravel.cs b/src/Libraries/RevitNodes/Elements/PathOfTravel.cs index ee736677d..059f7e24b 100644 --- a/src/Libraries/RevitNodes/Elements/PathOfTravel.cs +++ b/src/Libraries/RevitNodes/Elements/PathOfTravel.cs @@ -300,12 +300,26 @@ internal static PathOfTravel FromExisting(RvtAnalysis.PathOfTravel rvtPathOfTrav /// /// Floor plan view for which rooms will be used to retrieve longest paths to the given exit points. /// List of end (exit) points. - /// List of PathOfTravel elements corresponding to the longest of shortest exit paths from rooms.List of PathOfTravel elements corresponding to the longest of shortest exit paths from rooms. /// private static PathOfTravel[] InternalLongestOfShortestExitPaths(Rvt.View rvtView, IEnumerable endPoints) { List pathsOfTravel = new List(); + if(TransactionManager.Instance.DisableTransactions) + { + IEnumerable persistRvtElements = ElementBinder.GetElementsFromTrace(Document); + if(persistRvtElements != null) + { + foreach (var ele in persistRvtElements) + { + var persisEle = new PathOfTravel(ele); + pathsOfTravel.Add(persisEle); + } + + return pathsOfTravel.ToArray(); + } + } TransactionManager.Instance.EnsureInTransaction(Document); try