
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I'm creating a sort of "Property Editor" dialog for user selected elements. In my dialog, the user may pick from a list of non read-only parameters, and specify an alternate value that my application will use later on under particular circumstances (see dialog image below).
The challenge is to provide a list of relevant alternate "Element Id Values" based on the selected parameter. So far, my approach is to explicitly exam the "Current Value (ElementId)" of selected parameter and create alternate value list accordingly. For some "Current Values" I use the "GetSimilarTypes" function, while others I simply filter the document for elements of same category (see code below image).
So far I have two questions...
- Can someone suggest a less explicit, more elegant way of populating the alternate ElementId values?
- Based on my current approach, if the "Current Value" is NULL, I have no way of getting alternate values.
Thanks,
Jon
if (request == EditPropertyOptRequest.GetAvailableValues) {
cond.SelElemValue = null; cond.PropertyOpt.ElementValues = new ObservableCollection<Element>(); try { dynamic CurrentElem = doc.GetElement(cond.SelProperty.AsElementId); if ((CurrentElem) is WallType) { WallType obj = CurrentElem; foreach (void ElemId_loopVariable in obj.GetSimilarTypes) { ElemId = ElemId_loopVariable; cond.PropertyOpt.ElementValues.Add(doc.GetElement(ElemId)); } } else if ((CurrentElem) is FloorType) { FloorType obj = CurrentElem; foreach (void ElemId_loopVariable in obj.GetSimilarTypes) { ElemId = ElemId_loopVariable; cond.PropertyOpt.ElementValues.Add(doc.GetElement(ElemId)); } } else if ((CurrentElem) is FamilySymbol) { FamilySymbol obj = CurrentElem; foreach (void ElemId_loopVariable in obj.GetSimilarTypes) { ElemId = ElemId_loopVariable; cond.PropertyOpt.ElementValues.Add(doc.GetElement(ElemId)); } } else if ((CurrentElem) is Level) { FilteredElementCollector collector = new FilteredElementCollector(doc); collector.OfCategory(BuiltInCategory.OST_Levels).WhereElementIsNotElementType(); foreach (void elem_loopVariable in collector) { elem = elem_loopVariable; cond.PropertyOpt.ElementValues.Add(elem); } } else if ((CurrentElem) is Phase) { FilteredElementCollector collector = new FilteredElementCollector(doc); collector.OfCategory(BuiltInCategory.OST_Phases).WhereElementIsNotElementType(); foreach (void elem_loopVariable in collector) { elem = elem_loopVariable; cond.PropertyOpt.ElementValues.Add(elem); } } cond.SelElemValue = cond.PropertyOpt.ElementValues(0); } catch (Exception ex) { } }
Solved! Go to Solution.