Hi -
Using code, I'm trying to determine if a family with a particular name is in the Revit file, and if so, define a family variable for that family (ex. "Dim m_f as Family = ..." in Visual Basic).
Any ideas?
Thank you!
|
Hi -
Using code, I'm trying to determine if a family with a particular name is in the Revit file, and if so, define a family variable for that family (ex. "Dim m_f as Family = ..." in Visual Basic).
Any ideas?
Thank you!
Last edited by Dr. Emergence; 2014-02-27 at 08:27 PM.
Here's a macro that looks for a family named "Single-Flush" of the Doors category
public void getFamily()
{
Document doc = this.ActiveUIDocument.Document;
string familyName = "Single-Flush";
Family f = new FilteredElementCollector(doc)
.OfClass(typeof(Family))
.Cast<Family>()
.FirstOrDefault(q => q.FamilyCategory.Name == "Doors" && q.Name == familyName);
if (f == null)
TaskDialog.Show("info", familyName + " does not exist");
else
TaskDialog.Show("info", familyName + " found");
}
Hope this helps
Regards
Harry
http://boostyourbim.wordpress.com/
Thanks!! You wouldn't know how to translate the following to VB.net would you? I've tried but can't seem to get it to work:
.OfClass(typeof(Family))
.Cast<Family>()
.FirstOrDefault(q => q.FamilyCategory.Name == "Doors" && q.Name == familyName);
I don't. There are a bunch of free online c# to vb converters you can try.