Revit Architecture Forum
Welcome to Autodesk’s Revit Architecture Forums. Share your knowledge, ask questions, and explore popular Revit Architecture topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Annotation Tag Gets Family Elevation

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Duy.Hoa
2776 Views, 5 Replies

Annotation Tag Gets Family Elevation

Hi there,

 

I am attempting to create a family of Annotation Tag which I hope it to be able to retrieve

the elevation value of families in the project model, but I seem to get stuck now

 

Please take a look at the attachments to better understand how my problem is

 

Hope someone can help me out

 

Thank you,
Nguyen Duy Hoa

5 REPLIES 5
Message 2 of 6
tuuletin
in reply to: Duy.Hoa

Hello, dear,

it is impossible to take parameter "elevation" from generic family to a tag. Thanks, autodesk! Cat Indifferent

But you can create shared parameter "elevation mirror", and copy the value from "elevation" to "elevation mirror" by means of dynamo script (very-very easy to do this).

Message 3 of 6
Duy.Hoa
in reply to: tuuletin

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:

 

Annotation Tag Gets Family Elevation.png

 

 

Message 4 of 6
rodrigo.bezerra
in reply to: Duy.Hoa

@Duy.Hoa, congratulations on your accomplishment.

 

Do you mind explain in details how to make it work? Is it a macro? Is it C#? Not everyone of us understand programming.

 

Thanks

Rodrigo Bezerra

EESignature

Message 5 of 6
Sabne
in reply to: Duy.Hoa

Thanks to share the code. I tried few ways but not working. Can you please explain more when and how run this API code? Cheers 

Message 6 of 6
Nisreenki
in reply to: Duy.Hoa

hello, i used this method and i am having an error in the message box like the picture below. anyway i can solve this please?

Tags (3)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report


Autodesk Design & Make Report