0

Can any one tell me how to get Type Parameters of structural beam? Parameters like section height, width, area?

I suppose I should start something like this:

    Selection sel = uidoc.Selection;

    Reference pickedRef = null;

    pickedRef = sel.PickObject(ObjectType.Element, "Please select beam");

    Element e = doc.GetElement(pickedRef);

    ElementType type = doc.GetElement(e.GetTypeId()) as ElementType;

    BuiltInParameter height = BuiltInParameter.FAMILY_HEIGHT_PARAM;

    Parameter h = type.get_Parameter(height);

    //OR
    Parameter hh = type.LookupParameter("Height");

    //Then don't know what to do
    double h1 = h.AsDouble(); //Or what?

But I don't get required type parameters, I get null exception.

Can anyone tell me what I am doing wrong? Am I using wrong BuiltInParamater, or something else?

Thanks! Milos

3 Answers3

2

Your code seems correct, I believe the parameter is not available for this type of element. Try download the Revit Lookup and inspect the element.

Augusto Goncalves
  • 8,493
  • 2
  • 17
  • 44
2

Whenever you hit an exception like that, you should debug your code. If you step through it line by line you will see exactly what is causing the problem. You are not checking whether the parameter exists at all. Whoever created the family decides what parameters exist and how they are named. You need to check what parameter you need depending on the family definition.

Just like Augusto says, you can use RevitLookup for this, or look at the type properties in the user interface. You might also want to take a look at the (pretty) new StructuralSection class. It was designed specifically to alleviate the issues you are now facing.

skeletank
  • 2,880
  • 5
  • 43
  • 75
Jeremy Tammik
  • 7,333
  • 2
  • 12
  • 17
0

thanks for both answers. I needed to spend more time looking for type parameter name.

This is how code should looks like:

    Element e = doc.GetElement(pickedRef);
    Element e = doc.GetElement(pickedRef);
    ElementType type = doc.GetElement(e.GetTypeId()) as ElementType;
    //to get height of section
    Parameter h = type.LookupParameter("h");
    double height = h.AsDouble();
    //to get width of section
    Parameter b = type.LookupParameter("b");
    double width = b.AsDouble();
    //and so on...

Thanks!