I have a collection of areas, and want to prompt the user to select additional areas by using PickObjects method. Unfortunately, PickObjects only accepts a list of references, and I cannot find a way to get references to my areas. Thought this might work, but it throws an "object reference not set to an instance of an object" error:
internal IList<Reference> getRefs(List<Area> areas) { IList<Reference> selected = new List<Reference>(); try { foreach (Area area in areas) { selected.Add((area as Object)as Reference); } return selected; } catch(Exception e) { MessageBox.Show(e.ToString()); } return null; }
This thread seemed like it might contain helpful info on a similar problem, but the answer in there did not work for me: https://forums.autodesk.com/t5/revit-api-forum/using-elements-selected-before-a-command-is-started/t...
Help would be greatly appreciated!
Solved! Go to Solution.
Solved by FAIR59. Go to Solution.
try this:
foreach (Area area in areas) { selected.Add(Reference.ParseFromStableRepresentation(doc,area.UniqueId)); }
Hi!
Maybe a little simpler, just new Reference(area) instead of Reference.ParseFromStableRepresentation
Can't find what you're looking for? Ask the community or share your knowledge.