Skip to content

Commit b99c356

Browse files
authored
Fix bug - Can not get StairsRun Parent Element (#2624)
1 parent 236c3b4 commit b99c356

File tree

2 files changed

+42
-27
lines changed

2 files changed

+42
-27
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Add some View Nodes - View.HideCategoriesTemporary, View.HideElementsTemporary, View.IsolateCategoriesTemporary, View.IsolateElementsTemporary.
88
* Improve DuplicateSheet Node - add "duplicateWithContents" option, add default suffix value when prefix & suffix are both empty.
99
* Improve DuplicateSheet Node - Set Sheet information when duplicating; Improve View Temporary Nodes.
10+
* Fix bug - Element.GetParentElement can't get StairsRun Parent Element.
1011

1112
## 0.2.18
1213
* Add a Category ScheduleOnSheet and its nodes - ScheduleOnSheet.Sheet, ScheduleOnSheet.Schedule, ScheduleOnSheet.BySheetViewLocation, ScheduleOnSheet.Location and ScheduleOnSheet.SetLocation

src/Libraries/RevitNodes/Elements/Element.cs

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ public static int[] Delete(Element element)
389389
return deletedElements;
390390
}
391391

392+
#region Get/Set Parameter
392393
/// <summary>
393394
/// Get a parameter by name of an element
394395
/// </summary>
@@ -444,6 +445,30 @@ public object GetParameterValueByName(string parameterName)
444445
return Revit.Elements.InternalUtilities.ElementUtils.GetParameterValue(param);
445446
}
446447

448+
/// <summary>
449+
/// Set one of the element's parameters.
450+
/// </summary>
451+
/// <param name="parameterName">The name of the parameter to set.</param>
452+
/// <param name="value">The value.</param>
453+
public Element SetParameterByName(string parameterName, object value)
454+
{
455+
var param = GetParameterByName(parameterName);
456+
457+
if (param == null)
458+
throw new Exception(Properties.Resources.ParameterNotFound);
459+
460+
TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument);
461+
462+
var dynval = value as dynamic;
463+
Revit.Elements.InternalUtilities.ElementUtils.SetParameterValue(param, dynval);
464+
465+
TransactionManager.Instance.TransactionTaskDone();
466+
467+
return this;
468+
}
469+
#endregion
470+
471+
#region Overrides & Hidden In ActiveView
447472
/// <summary>
448473
/// Override the element's color in the active view.
449474
/// </summary>
@@ -509,29 +534,7 @@ public bool IsHiddeninView(Revit.Elements.Views.View view)
509534
return InternalElement.IsHidden(view.InternalView);
510535
}
511536

512-
/// <summary>
513-
/// Set one of the element's parameters.
514-
/// </summary>
515-
/// <param name="parameterName">The name of the parameter to set.</param>
516-
/// <param name="value">The value.</param>
517-
public Element SetParameterByName(string parameterName, object value)
518-
{
519-
var param = GetParameterByName(parameterName);
520-
521-
if (param == null)
522-
throw new Exception(Properties.Resources.ParameterNotFound);
523-
524-
TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument);
525-
526-
var dynval = value as dynamic;
527-
Revit.Elements.InternalUtilities.ElementUtils.SetParameterValue(param, dynval);
528-
529-
TransactionManager.Instance.TransactionTaskDone();
530-
531-
return this;
532-
}
533-
534-
537+
#endregion
535538

536539
/// <summary>
537540
/// Get all of the Geometry associated with this object
@@ -819,6 +822,7 @@ protected bool IsAlive
819822
}
820823
}
821824

825+
#region Get Child Elements
822826
/// <summary>
823827
/// Gets the child Elements of the current Element.
824828
/// </summary>
@@ -930,7 +934,9 @@ private static List<Element> GetChildElementsFromStairs(Autodesk.Revit.DB.Elemen
930934
.ToList();
931935
return stairComponentElements;
932936
}
937+
#endregion
933938

939+
#region Get Parent Elemnt
934940
/// <summary>
935941
/// Gets the parent element of the Element.
936942
/// </summary>
@@ -1025,15 +1031,23 @@ private static Autodesk.Revit.DB.Element GetParentElementFromStructuralFraming(A
10251031
private static Autodesk.Revit.DB.Element GetParentComponentFromStairElements(Autodesk.Revit.DB.Element element)
10261032
{
10271033
Autodesk.Revit.DB.Element parent;
1028-
var stairElement = element as Autodesk.Revit.DB.Architecture.StairsLanding;
10291034

1030-
if (stairElement == null)
1035+
if(element is Autodesk.Revit.DB.Architecture.StairsLanding)
1036+
{
1037+
var stairElement = element as Autodesk.Revit.DB.Architecture.StairsLanding;
1038+
parent = stairElement.GetStairs();
1039+
}
1040+
else if(element is Autodesk.Revit.DB.Architecture.StairsRun)
1041+
{
1042+
var stairElement = element as Autodesk.Revit.DB.Architecture.StairsRun;
1043+
parent = stairElement.GetStairs();
1044+
}
1045+
else
10311046
throw new InvalidOperationException(Properties.Resources.NoParentElement);
10321047

1033-
// For StairLandings and StairRuns we use the GetStairs() to retrive the parent Stair
1034-
parent = stairElement.GetStairs();
10351048
return parent;
10361049
}
1050+
#endregion
10371051

10381052
#region Geometry Join
10391053
/// <summary>

0 commit comments

Comments
 (0)