Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
1039 Views, 3 Replies

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

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,

 

3 REPLIES 3
Message 2 of 4
FaustoMendezcom
in reply to: Anonymous

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
Message 3 of 4
jeremytammik
in reply to: Anonymous

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

Message 4 of 4
Anonymous
in reply to: jeremytammik

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.

Post to forums  

Rail Community


Autodesk Design & Make Report