Hi,
Using the following code I am able to place ceiling based sprinkes on the ceiling but when I try to insert smoke detectors they get placed on the floor.
Totally confused. PLease help:
public static FamilyInstance InsertCeilingElements(Document doc, XYZ location, String FamilyName, Element host)
{
FamilySymbol symbol = null;
foreach (FamilySymbol symbq in fsym)
{
String dd1 = symbq.Name;
String ff = symbq.Category.Name;
Family fm = symbq.Family;
Boolean fnd = false;
String[] Famarr = FamilyName.Split(new string[] { "=>" }, StringSplitOptions.None);
if (dd1 == Famarr[1] && ff == Famarr[0])
{
symbol = symbq;
fnd = true;
break;
}
if (fnd == true)
{
break;
}
}
FamilyInstance Finst = null;
using (Transaction t = new Transaction(doc, "Place Instance"))
{
t.Start();
Ceiling ceil = (Ceiling)host;
Options opt1 = Command.app.Create.NewGeometryOptions();
opt1.ComputeReferences = true;
ceil.get_Geometry(opt1);
GeometryElement geo = ceil.get_Geometry(opt1);
PlanarFace ceilingBottom = null;
foreach (GeometryObject obj in geo.Objects)
{
Solid solid = obj as Solid;
if (null != solid)
{
foreach (Face face in solid.Faces)
{
PlanarFace pf = face as PlanarFace;
if (null != pf)
{
ceilingBottom = pf;
break;
}
}
}
}
Finst = doc.Create.NewFamilyInstance(ceilingBottom, location, XYZ.BasisX, symbol);
t.Commit();
}
return door;
}
Dear Intecinfocom,
As always when working with the Revit API, one good method to proceed to explore this is to create the desired situation through the user interface and explore that in detail using RevitLookup or more detailed exploration using one of the Python or Ruby shells:
In this case, there seems to be some difference in behaviour between the two types of family instances that you are inserting.
Check and compare their host properties, and whether there are any offset parameters that are being used somehow.
Meanwhile, I will ask my colleagues whether they have any other suggestions for you.
Thank you and good luck,
Jeremy
Dear Intecinfocom,
This is what the development team suggest for you:
There are different types of hosting that need to be considered:
Based on your description, you are placing ceiling based sprinklers, so there is probably some logic in the family definition to find the ceiling automatically for them.
You need to be aware what kind of hosting the smoke detector uses. If they are unhosted smoke detectors, Revit won’t assume an elevation/host. If they are face hosted, there may be a separate method you need to call to specify which face to host the element.
Here are some discussions on family instance placement on The Building Coder:
http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.25
Best regards,
Jeremy