Hello Tuuletin,
Thank you for you answer and sorry for the delay in replying
Yes indeed, as far as I understand, we can programmatically have this task done by means of Dynamo script or Revit API. Just because I wanted to keep it simple possible so that every Revit users can work with. But I seems I have no choice
I finally had it done by Revit API and I think it is worthwhile sharing here for those who are in the same need
And I think this post should be marked as a solution for a conclusion
Procedure:
1. Create a Sharea Parameter named "ELEVATION"
2. Copy value from "Elevation" parameter to "ELEVATION" parameter (this step is programmatically handled by the below code)
3. Create a Tag Family with a label associated with the "ELEVATION" parameter
Thank you,
Nguyen Duy Hoa
Here is the code for handling step 2:
public void TakeElevation(Autodesk.Revit.DB.Document doc)
{
// 1. All Generic Instances
ElementCategoryFilter filter = new ElementCategoryFilter(BuiltInCategory.OST_GenericModel);
IList<Element> instanceList = new FilteredElementCollector(doc).WherePasses(filter).WhereElementIsNotElementType().ToElements();
// To select and count instances at completion
IList<ElementId> toSelect = new List<ElementId>();
long count = 0;
// 2. Conditioned Instances
foreach (Element ins in instanceList)
{
double elevation = 0;
IList<bool> flag = new List<bool>();
bool heightIsAvailable = false;
bool BasedLevelIsAvailable = false;
ParameterSet paramSet = ins.Parameters;
foreach (Parameter param in paramSet)
{
if (param.Definition.Name.Equals("Elevation"))
{
elevation = param.AsDouble();
}
}
// The separation of the two loops is necessary to avoid confusion in taking parameter value
foreach (Parameter param in paramSet)
{
if (heightIsAvailable = BasedLevelIsAvailable = true && param.Definition.Name.Equals("ELEVATION")) // "ELEVATION" is a custom instance parameter"
{
using (Transaction t = new Transaction(doc, "Set parameters value"))
{
t.Start();
param.Set(elevation);
t.Commit();
count += 1;
flag.Add(true);
}
}
}
if (flag.Contains(true))
{
toSelect.Add(ins.Id);
}
}
// 4. Report
if (toSelect.Count > 0)
{
MessageBox.Show("Executed on " + count + " instance(s)", "Information");
}
else
{
MessageBox.Show("No instance executed");
}
UIDocument uidoc = new UIDocument(doc);
uidoc.Selection.SetElementIds(toSelect);
}
Here is the result:
