Place the doors on existing wall with some point in REVIT API

This widget could not be displayed.

Place the doors on existing wall with some point in REVIT API

Anonymous
Not applicable

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.

 

wallerror1.JPGwallerror2.JPGwallerror3.JPGwallerror4.JPGwallerror5.JPG

 

Can anyone suggest/help, where i done mistake or have to update.

 

Thanks,

Somu,

 

0 Likes
Reply
1,053 Views
3 Replies
Replies (3)

FaustoMendezcom
Enthusiast
Enthusiast

you need a host and a level for a wall.

use this method.

NewFamilyInstance(location, symbol, host, host.Level, StructuralType.NonStructural);

Hope it helps 🙂

Hope it helps 🙂
-------------------------------------------------------------------------------------
www.faustomendez.com

jeremytammik
Autodesk
Autodesk

The error message tells you what is wrong.

 

Have you fixed that?

 

Is your family placement type workplane based?

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes

Anonymous
Not applicable

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.

 

 

 

0 Likes