Hi Guys,
We are trying to place the doors on existing wall with some point, we are getting the below error while createfamilyinstance on the wall.
Can anyone suggest/help, where i done mistake or have to update.
Thanks,
Somu,
you need a host and a level for a wall.
use this method.
NewFamilyInstance(location, symbol, host, host.Level, StructuralType.NonStructural);
Hope it helps 🙂
The error message tells you what is wrong.
Have you fixed that?
Is your family placement type workplane based?
Cheers,
Jeremy
Hi Jeremy,
We had updated the "workplanebased" and familysymbol builtincategory("OST_Type") for placing doors in the existing wall, its working.
Please check with below code.
using (Transaction t2 = new Transaction(doc1))
{
t2.Start("create door");
if (family1 != null)
{
FilteredElementCollector familiesCollector = new FilteredElementCollector(doc1);
familiesCollector.OfClass(typeof(Family));
var families = from m_family in familiesCollector
where m_family.Name.ToLower() == name.ToLower()
select m_family;
family1 = families.Cast<Family>().FirstOrDefault();
family1.get_Parameter(BuiltInParameter.FAMILY_WORK_PLANE_BASED).Set(0);
foreach (ElementId id in family1.GetFamilySymbolIds())
{
symbol = doc.GetElement(id) as FamilySymbol;
}
symbol.Activate();
// symbol.Family.get_Parameter(BuiltInParameter.FAMILY_WORK_PLANE_BASED).Set(1);
//TaskDialog.Show("Revit", "2");
FilteredElementCollector collector1 = new FilteredElementCollector(doc1);
ICollection<Element> collection = collector1.OfClass(typeof(Wall)).ToElements();
Wall wall1 = null;
foreach (Element e1 in collection)
{
wall1 = e1 as Wall;
}
FilteredElementCollector col = new FilteredElementCollector(doc1);
col.OfClass(typeof(FamilySymbol)).OfCategory(BuiltInCategory.OST_Doors);
//col.OfClass(typeof(FamilySymbol)).OfCategory(BuiltInCategory.OST_Windows);
Face face = null;
Options geomOptions = new Options();
geomOptions.ComputeReferences = true;
GeometryElement wallgeom = wall1.get_Geometry(geomOptions);
foreach (GeometryObject geomobj in wallgeom)
{
Solid geomsolid = geomobj as Solid;
if (null != geomsolid)
{
foreach (Face geomface in geomsolid.Faces)
{
face = geomface;
break;
}
break;
}
}
var referecn = HostObjectUtils.GetSideFaces(wall1, ShellLayerType.Exterior).First();
// TaskDialog.Show("Revit", "4");
BoundingBoxUV bboxuv = face.GetBoundingBox();
UV center = (bboxuv.Max + bboxuv.Min) / 2.0;
XYZ location = XYZ.Zero;
XYZ refdir = XYZ.BasisZ;
// TaskDialog.Show("Revit", "5");
// TaskDialog.Show("Revit", face.IsInside(center).ToString());
double x = double.Parse(Microsoft.VisualBasic.Interaction.InputBox("x", "Revit", ""));
double y = double.Parse(Microsoft.VisualBasic.Interaction.InputBox("y", "Revit", ""));
double z = double.Parse(Microsoft.VisualBasic.Interaction.InputBox("z", "Revit", ""));
FamilyInstance instance = doc1.Create.NewFamilyInstance(new XYZ(x,y,z), symbol, wall1, StructuralType.NonStructural);
// FamilyInstance instance = doc1.Create.NewFamilyInstance(refdir, symbol, wall1, StructuralType.NonStructural);
} t2.Commit();
symbol.Dispose();
} //Task
Thanks for your support,
Somu.
Can't find what you're looking for? Ask the community or share your knowledge.