Revit Architecture Forum
Welcome to Autodesk’s Revit Architecture Forums. Share your knowledge, ask questions, and explore popular Revit Architecture topics.
abbrechen
Suchergebnisse werden angezeigt für 
Anzeigen  nur  | Stattdessen suchen nach 
Meintest du: 

Annotation Tag Gets Family Elevation

5 ANTWORTEN 5
GELÖST
Antworten
Nachricht 1 von 6
Anonymous
3122 Aufrufe, 5 Antworten

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 ANTWORTEN 5
Nachricht 2 von 6
tuuletin
als Antwort auf: Anonymous

Hello, dear,

it is impossible to take parameter "elevation" from generic family to a tag. Thanks, autodesk! Katze (gleichgültig)

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).

Nachricht 3 von 6
Anonymous
als Antwort auf: 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

 

 

Nachricht 4 von 6
rodrigo.bezerra
als Antwort auf: Anonymous

@Anonymous, 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

Nachricht 5 von 6
Sabne
als Antwort auf: Anonymous

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 

Nachricht 6 von 6
Anonymous
als Antwort auf: Anonymous

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)

Sie finden nicht, was Sie suchen? Fragen Sie die Community oder teilen Sie Ihr Wissen mit anderen.

In Foren veröffentlichen  

Autodesk Design & Make Report