Set Parameter Value Based on Sorting of Family Instance X and Y Coordinates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to set a text instance parameter for a detail component based on the instance's location in the active view. I use this for numbering my beams from bottom left to top right, but the starting number will vary based on the view I'm currently in. For example, on the first floor ten beams will have the parameter B-1 through B-10 (this is why the parameter is text and not a number/integer); on the second floor six beams will be B-11 through B-16. I've got this working perfectly in Dynamo without issue but I'd like for my team to be able to run it as a button on our custom ribbon tab. I'd like the button to function as: the user selects instances to number > user sets starting number > parameter is set. The part of the coding that I'm stuck on is how to get the X and Y coordinates of the selected instances, sort them bottom left to top right, then apply the user-set starting number to the first instance in the sorted list. I've seen some code very close to parts of what I'm looking to achieve posted by @jeremytammik, but I'm still very new to the Revit API side of things so I'm unable to put the pieces together on my own.
Key Information: Revit 2018, Visual Studio 2019, C#, Detail Component family with text instance parameter called #, order from bottom left to top right, user sets the start value