Message 1 of 5
Failed to create a wall by modeling orientation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to create a wall using the Wall.Create method https://www.revitapidocs.com/2020/6c247699-c8e5-91df-67f7-470d10fa7ba3.htm. with the following code.
UIApplication uiApp = commandData.Application;
UIDocument uiDoc = uiApp.ActiveUIDocument;
Document doc = uiDoc.Document;
Reference reference = uiDoc.Selection.PickObject(ObjectType.Element,"Seleccione el elemento");
Element elemento = doc.GetElement(reference);
Wall wall = elemento as Wall;
WallType wallType = ColectoresEntrada.TipoElementoMuro(doc,"Encofrado") as WallType;
ElementId levelId = elemento.get_Parameter(BuiltInParameter.WALL_BASE_CONSTRAINT).AsElementId();
IList<Reference> sideReferenceFaces = HostObjectUtils.GetSideFaces(wall,ShellLayerType.Interior);
Face faceWithoutIntersection = doc.GetElement(sideReferenceFaces[0]).GetGeometryObjectFromReference(sideReferenceFaces[0]) as Face;
PlanarFace planarFace = faceWithoutIntersection as PlanarFace;
XYZ normal = planarFace.FaceNormal.Normalize();
IList<CurveLoop> curveLoopList = planarFace.GetEdgesAsCurveLoops();
//curves list
List<Curve> curves= new List<Curve>();
foreach (CurveLoop curveLoop in curveLoopList)
{
foreach (Curve curve in curveLoop)
{
XYZ firstPoint = curve.GetEndPoint(0);
XYZ endPoint = curve.GetEndPoint(1);
Curve newCurve = Line.CreateBound(firstPoint, endPoint) as Curve;
curves.Add(newCurve);
}
}
using (Transaction trans = new Transaction(doc))
{
trans.Start("Crear Muro");
try
{
Wall wallCreated = Wall.Create(doc, curves, wallType.Id, levelId, true);
trans.Commit();
}
catch (Exception ex )
{
TaskDialog.Show("Error",ex.Message);
trans.RollBack();
}
}
I have tried it with different ways, but I have a problem when there are windows inside my wall and the wall was drawn from right to left.
I show an image so you can see when the error happens.
I would appreciate a guide to know what could be the error I have.