First of all thank you ADN DevTech team for the warm welcome. I recently joined DevTech Americas Team at the beginning of July, I was already part of Autodesk and before I was part of the BIM 360 Glue Team. I am very excited about joining this division and looking forward to meet the awesome developers that are part of the Autodesk Developer Network ADN.
During my first week I had the chance to go to the Waltham MA and Manchester NH Autodesk office’s and on my free time I got to take a couple of pictures from a different point of view, an aerial view. I hope you guys like it.
Waltham Autodesk Office
Manchester Autodesk Office
One of my first cases I got my hands on, was using the Revit Family API in order access the value of an instance parameter of a client custom family type. Here is the question submitted.
Question: "I have a Revit model that can have some component families, for example Mechanical Equipment's. These families have an instance parameter called "Maintenance Date" which is a text parameter with value in MM/DD/YYYY format. The maintenance date is different for each equipment.
How can I read the value for that maintenance date parameter, using C#."
Answer: In order to access the value of your parameter the Family API works like this. You start with the FamilyDocument, after the FamilyManager will have access to FamilyParameter and FamilyType classes.
FamilyParameter can be used in order to set the value of the parameter. FamilyType will be used in this case in order to get the value of your custom parameter in this case the Maintenance Date.
Here is a command I put together for you to test it.
[Transaction(TransactionMode.Manual)]
public class Command : IExternalCommand
{
public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Application app = uiapp.Application;
Document doc = uidoc.Document;
FamilyManager familyMgr = doc.FamilyManager;
foreach (FamilyType t in familyMgr.Types)
{
foreach (FamilyParameter p in familyMgr.Parameters)
{
if (p.IsInstance && t.AsString(p) != "")
TaskDialog.Show("Parameters", p.Definition.Name
+ ": " + t.AsString(p));
}
}
return Result.Succeeded;
}
}
And here is a couple of shots on what the outcome would be (click on the image for full size).