Check Family Symbol Host

Check Family Symbol Host

Anonymous
Not applicable
2,367 Views
12 Replies
Message 1 of 13

Check Family Symbol Host

Anonymous
Not applicable

Hi,

 

How do I check wheather a  familysymbol requires a host or not. ie its hosted or not.

 

Thanks & Regards

0 Likes
Accepted solutions (1)
2,368 Views
12 Replies
Replies (12)
Message 2 of 13

Anonymous
Not applicable

Hi,

 

If a family is hosted it has a builtin parameter HOST_ID_PARAM.

 

This blog might be usefull :

http://adndevblog.typepad.com/aec/2012/10/determining-if-a-family-was-created-using-wall-floor-face-...

 

0 Likes
Message 3 of 13

Anonymous
Not applicable

fsym = new FilteredElementCollector(doc)

.OfClass(typeof(FamilySymbol))

.Cast<FamilySymbol>().ToList();

foreach (FamilySymbol symbq in fsym)
{
Parameter pr = symbq.get_Parameter(BuiltInParameter.HOST_ID_PARAM);
if (pr!=null)
{
MessageBox.Show("");
}
}

This is the code to loop the family symbols . but no message box shows up. that means no symbol has any host. 

0 Likes
Message 4 of 13

Anonymous
Not applicable
I believe you are looking one level to deep. You need to ask the familyinstance.getparameter.
You can double check this with Revit Lookup or BIPChecker. So a window for instance will report the host_ID_Param back when placed in a wall.
0 Likes
Message 5 of 13

Anonymous
Not applicable

Let me rephrase.

 

I want a list  with the names of family which does not require a host. For example  a chair does not require a host but a door requires a host[Wall]. 

 

 

0 Likes
Message 6 of 13

Anonymous
Not applicable
I know, that's why I gave you all the suggestions 🙂 Hosted families have a value for the builtinparameter BuiltInParameter.HOST_ID_PARAM.
0 Likes
Message 7 of 13

Anonymous
Not applicable

then why this code always gives null for parameter pr even if I change the line from 

Parameter pr = symbq.get_Parameter(BuiltInParameter.HOST_ID_PARAM);

To

Parameter pr =symbq.Family.get_Parameter((BuiltInParameter.HOST_ID_PARAM);

 

 

fsym = new FilteredElementCollector(doc)

.OfClass(typeof(FamilySymbol))

.Cast<FamilySymbol>().ToList();

foreach (FamilySymbol symbq in fsym)
{
Parameter pr = symbq.get_Parameter(BuiltInParameter.HOST_ID_PARAM);
if (pr!=null)
{
MessageBox.Show("");
}
}

0 Likes
Message 8 of 13

Anonymous
Not applicable

Like I said, you have made a collection of family symbols, but you need to go one level higher. Try this code :

 

FilteredElementCollector collector1 = new FilteredElementCollector(doc);
ICollection<Element> collection = collector1.WhereElementIsNotElementType().ToElements();

foreach (Element el in collection)
{
if (el.get_Parameter(BuiltInParameter.HOST_ID_PARAM) != null)
{
Parameter par = el.get_Parameter(BuiltInParameter.HOST_ID_PARAM);
if (par.AsElementId().IntegerValue != -1)
{
MessagBox.Show("This Family has got a host");
}
}

}

0 Likes
Message 9 of 13

Anonymous
Not applicable

Remy firstly thanks for bearing up with me.

Tried your code but no message popped up.

Sorry if I wasn't able to make things clear. Here it goes again;

When you open a .rvt or a new file. In the project browser we can see Families tree as follows:

families.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Now from this family tree I want to populate only those items which doesn'r require a host. Like list should be populated with entries marked in red and not entries marked in green as entries marked in green requires a host[container]. A door alike plant cannot be placed anywhere as it requires a wall.

marked.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I hope I was able to make things clear.

0 Likes
Message 10 of 13

Anonymous
Not applicable

okay, now I understand. Ofcourse the messagebox doesn't pop up, since those loaded doors aren't placed yet so they are not in a host yet, so they still have a value of -1 for the HOST_ID_PARAM. I think the only thing you can do is to make a list of all the families and check their category. If it is door, window ect. you can assume these are families that require a host. 

0 Likes
Message 11 of 13

Anonymous
Not applicable

So you mean to say that the API doesn't provide any method/function/property by which we can know that whether this family requires a  host or not. The only way is to assume.

 

Is there any  hosted and unhosted family list somewhere.

0 Likes
Message 12 of 13

Anonymous
Not applicable
Accepted solution

You're on the right track, I think you're just looking for the wrong parameter.  For a family that hasn't been instantiated yet, you can check BuiltInParameter.FAMILY_HOSTING_BEHAVIOR instead of the BuiltInParameter.HOST_ID_PARAM of the Family, not the FamilySymbol or FamilyInstance.  One thing to note, every family will have this parameter so you may want to check for the value instead of whether the parameter is null or not.  If you check instead for whether the integer value of the parameter is greater than 0, that should trigger the messagebox only when the family needs a host. You can use the link that Remy posted earlier to see what host type each integer value (0-5) relates to.

 

fsym = new FilteredElementCollector(doc)

.OfClass(typeof(FamilySymbol))

.Cast<FamilySymbol>().ToList();

foreach (FamilySymbol symbq in fsym)
{
Parameter pr = symbq.Family.get_Parameter(BuiltInParameter.FAMILY_HOSTing_BEHAVIOR);
if (pr.AsInteger() > 0)
{
MessageBox.Show("");
}
}

Message 13 of 13

Anonymous
Not applicable

Wooooo..WSmiley Very Happy    That was Terrefic tlogan_lmn Thanks a ton.

0 Likes