How to get geometrical parameters of a generic model element

Anonymous

How to get geometrical parameters of a generic model element

Anonymous
Not applicable

Hi everyone,

 

I’m trying to make an API able to get different instance parameters of an element in a family. In my case, I want to catch the value of  « hauteur » , « Epaisseur » and « longueur » parameters of the element « mur de front » wich is a genreic model. After that i would like to store thoses parameters into variables to make a calcul.

 

I highlighted in yellow values i want to getI highlighted in yellow values i want to get

 

 

I succeeded to make a code to store the parameters value for a classic wall with thoses commands


Parameter l = e.get_Parameter(BuiltInParameter.FAMILY_HEIGHT_PARAM);
Parameter h = e.get_Parameter(BuiltInParameter.WALL_USER_HEIGHT_PARAM);

 

but i can’t find the solution for a generic model element … I found some codes on differents forums but i’m not able to compil them correctly in my program. Obvoiusly i’m a beginner...


If anyone can give me suggestions or a sample code to catch thoses parameters it would be nice and helpfull for me to understand😊.

0 Likes
Reply
Accepted solutions (2)
898 Views
3 Replies
Replies (3)

Sean_Page
Collaborator
Collaborator
Accepted solution

Maybe try something like this?

 

            List<double> hauteur = new List<double>();
            using (FilteredElementCollector fec = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_GenericModel).WhereElementIsNotElementType())
            {
                foreach (Element e in fec.ToElements())
                {
                    if (doc.GetElement(e.GetTypeId()).Name == "Mur de front")
                    {
                        Parameter h = e.LookupParameter("hauteur");

                        hauteur.Add(h.AsDouble());
                    }
                }
            }
Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect
0 Likes

Anonymous
Not applicable

Hi spage thanks for your repply,

 

I did what you said and it seems to work to catch parameters of this type of elements so thank you for that. But there is still something i don’t understand… To control, I made a quick textbox wich return the value of the parameters « hauteur », « longueur » and « largeur » I caught with the programl : the values were not the same beetwen what i see in the textbox and what see in the proprieties of the element...

 

Here is a part of my code :

 

//create list

            List<double> donnees = new List<double>();

//Select element

            Element element = SelectElement(uidoc, doc);

//***************filter***************

            //using (FilteredElementCollector filtre = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_GenericModel).WhereElementIsNotElementType())
            {

//get parameters

                Parameter h = element.LookupParameter("hauteur");
                donnees.Add(h.AsDouble());
                Parameter l = element.LookupParameter("longueur");
                donnees.Add(l.AsDouble());
                Parameter b = element.LookupParameter("epaisseur");
                donnees.Add(b.AsDouble());

//textbox test

                double x = donnees[0];
                double y = donnees[1];
                double z = donnees[2];

                TaskDialog.Show("résultat = ", x.ToString());
                TaskDialog.Show("résultat = ", y.ToString());
                TaskDialog.Show("résultat = ", z.ToString());
            }
         return Result.Succeeded;
} //***************Selection method*************** public Element SelectElement(UIDocument uidoc, Document doc) { Reference reference = uidoc.Selection.PickObject(ObjectType.Element); Element element = uidoc.Document.GetElement(reference); return element; }

 

 

 

The results were :

« hauteur » = 13.57 (instead of 4.1371)

« Longueur » = 38.84 (11.84)

« Epaisseur » = 2.28 (0.6974)

 

Maybe something with the unit ?

 

 

0 Likes

Sean_Page
Collaborator
Collaborator
Accepted solution

And keep in mind that Revit's internal units are Ft/In so you may need to do a conversion on the values received if your using Metric.

Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect
0 Likes