Is there a Element.LastObject Node?

I like to auto select the last Revit Object added by the user.
Is there such a Node?

No, I don’t think there is a node such as this. However, revit auto-increments the ElementIDs of elements, so you could collect all Elements, these should be sorted by ElementID by default but you could sort them after by key (ElementID), and then get the last element in that list.

1 Like

@mdhutchinson @Daniel_Woodcock1 “All Elements In Active View” will give always list based on the elements created order. So you can take the last object by “List.LastItem”.

That won’t catch view hosted elements like detail components or lines. Or views. Sheets. Viewports. Phases. Renderings. Sketch lines. Element types. Revisions. Or any of the many other types of elements which don’t show in 3D views.

A while loop grabbing items by Element Id backwards from 100,000,000 might be the best method… depending on what he’s after… Perhaps @mdhutchinson can clarify his purpose so we can understand what types of elements he is ok with letting through the filter?

1 Like

The purpose…
In Revit alone, I’ve not found a way to automate Family Type selection based on a condition. In this case the condition used is very easy to check on, so I’m looking to Dynamo - to either change the type after the user has placed them, or automatically insert the correct type up front after which the user could move them appropriately.

I’m thinking Dynamo could do either, but I’ve not started down that road just yet.

The family is a Room Tag with various labels having visibility parameters.

Thoughts?

(Note: I tried visibility controlled exclusively by formula, but have not found that Revit could do this, even though it looks like this would work from within the family editor… so I’ve resorted to several Types, one each for each visibility state.)

An IF statement in the family controlling the visibility value won’t work as the value is driven by the tagged element not the value itself. And using multi-parameter labels to not show the null values won’t work long term, as if someone puts in the value and then you decide to change it out you can’t recreate null in the Revit UI.

And changing the value at creation is good, but if you’re gonna automate, then you might as well Automate right? And having to write two tools when a single one could do both is foolhardy.

Sooooooo… I would build a graph that:

  1. Gets all rooms in the active view.
  2. Gets all room tags from the active view.
  3. Gets the host element for each tag in 2.
  4. Gets the parameter value from the rooms in 3 that drives the tag type.
  5. Uses an if function to pull the correct tag type via the family name.
  6. Sets the tag type in 2 to the new family type in 5.
  7. Finds rooms in 1 which aren’t in 3.
  8. Gets the parameter value for rooms in 7 to drive the tag type.
  9. Use the same if function in 5 to pull the correct tag type via the family name.
  10. Creates a new tag at the location of the rooms in 7 by the types in 9.

Requires no UI beyond ‘hit run.’ This is a big workflow but it would run via player. Just make sure to clean out any element binding before you save it as read only in your player library.