Showing posts with label parameters. Show all posts
Showing posts with label parameters. Show all posts

Thursday, March 10, 2011

Order of Parameters

I've been working on a project in which I retrieve all of the Instance and Type Parameters from an object and I've noticed something odd.

foreach (Parameter para in eCoreWall.Parameters)
{
  results += Util.GetParameterInformation(para, m_doc);
} 

Each time I pull the parameters, they are listed in a different order.  Anyone know why?
Here's an abbreviated example:

1st Time- 
Area: 27.72 SF
Length: 59.00
Function: Exterior


2nd Time-
Length: 59.00
Area: 27.72 SF
Function: Exterior

Thursday, January 13, 2011

Door Functions and Names

Another part of my material collection process it to gather all doors and group them by Exterior and Interior. I had a bit of trouble getting the door functions- it wasn't the same as the walls. Doors are family instances inside the project document, so in addition to the base family parameters, each has its own family type instance parameters.

By default, a door has its function set to 0 which is Interior (1 is Exterior). If you ever create a type catalog for a door family, remember to use 0 and 1 instead of Interior/Exterior!




Again, this doesn't work and results in an error:
Parameter doorFunc = e.get_Parameter(BuiltInParameter.FUNCTION_PARAM);

This returns the door's function- Interior or Exterior:
static public string GetDoorFunction(Element e)
{
 Parameter param = e.ObjectType.get_Parameter(BuiltInParameter.FUNCTION_PARAM);
 string doorFuncVal = param.AsInteger().ToString();
 return doorFuncVal;
}

I noticed that 'ObjectType' is deprecated, but I'm not having any luck with using the ElementId/ElementType right now.

And to get a door's family name:
static public string GetDoorType(Element e)
{
 FamilyInstance fi = e as FamilyInstance;
 string value = fi.Symbol.Family.Name;
 return value;
}

And the result:
BASE Interior Doors:
**********
Single swing, 2468
Single swing, 2468
Bi-Fold 2 Panel (TC), 2068
Double bifold, 4068
Single swing, 1668
Single Swing, 2068 

BASE Exterior Doors:
**********
double slider, 6068 SGD
garage door_16ft, 1680

Tuesday, January 11, 2011

Retrieving a wall's Function Parameter (BuiltInParameter.FUNCTION_PARAM)

For part of a large Revit material-gathering project I'm working on, I need to retrieve a wall's function. Walls can be assigned six functions from within their type properties:

  • Interior
  • Exterior
  • Foundation
  • Retaining
  • Soffit
  • Core-Shaft

At first I thought it would be fairly straight-forward, and I'd just do this grab the valuestring of the 'FUNCTION_PARAM' like so:

eWall.get_Parameter("Function").AsValueString()

But that gave me a NULL value and crashed Revit. The approach that worked for me was this:

static public string IsExterior(Element e, Document doc)
{
    ElementId id = e.GetTypeId();
    ElementType wallType = doc.get_Element(id) as ElementType;

    Parameter wallFunction = wallType.get_Parameter
        (BuiltInParameter.FUNCTION_PARAM);
    WallFunction value  = (WallFunction)wallFunction.AsInteger();

    return value.ToString();
}
Thanks to Jeremy Tammik's SDK example for setting me straight.