i'm trying to place a family using the API (c#).
When using the NewFamiltInstace overloaded method that takes (location, symbol,host, level, structural) - i'm expecting to get the instance of the hanger family in the level i have inserted, and in the elevation of the host ( the duct).
instead - i get the duct hanger in the ground floor no matter what i'm doing, can any one understand why, and what sholud i do to get it in the desired level?
- tried multiple overloaded methods, tried using the duct as a host, the level as a host etc.. the hangers always show up at the floor of ground level.
the code from my transaction: '''
using (Transaction trans = new Transaction(doc, "Place Family"))
{
trans.Start();
int indx = 0;
foreach (XYZ hanger_xyz in hangerCoordinates)
{
if (!hangerSymbol.IsActive)
{
hangerSymbol.Activate();
}
doc.Create.NewFamilyInstance(hanger_xyz, hangerSymbol,duct,level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
}
trans.Commit();
}
'''
CodePudding user response:
Please study the Revit SDK sample FabricationPartLayout
. That will solve your problem. The samples are available from the Revit Developer Center.
CodePudding user response:
figured it out.
After testing all of the 11 overloaded methods for newFamilyInstance and their required arguments, and snooping around with RevitLookUp, i managed to get the right overloded method which is:
FamilyInstance familyInstance = doc.Create.NewFamilyInstance(face, hanger_xyz, new XYZ(0, 1, 0), hangerSymbol);
face==> as a Referemce object (extracted it from a face Face that i got from a GeoElement that i got from the desired level's floor)
hanger_xyz==>an XYZ location
new XYZ(0,1,0)==> a direction of the family as it is when it's attached to a cielling host ( got it from revitLookUp)
hangerSymbol ==> the familysymbol.
cheers!