Failed to Edit the sketches of the walls using C#
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Revit users.
I was trying to see how can I create walls and edit their sketches(Profile) via C# . I have written this code .
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
// Get Document and UIDocument
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Autodesk.Revit.DB.Document doc = commandData.Application.ActiveUIDocument.Document;
FilteredElementCollector collector = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Levels).WhereElementIsNotElementType();
Level lev = collector.Where(e => e.Name.Contains("1")).First() as Level;
IList<Curve> curves = new List<Curve>();
XYZ p1 = new XYZ(0, 0, 0);
XYZ p2 = new XYZ(50, 50, 0);
XYZ p3 = new XYZ(0, 0, 20);
XYZ p4 = new XYZ(50, 50, 10);
XYZ referencevector = new XYZ(0, 0, 1);
Curve l1 = Line.CreateBound(p1, p2);
Curve l2 = Line.CreateBound(p2, p3);
Curve l3 = Line.CreateBound(p3, p4);
Curve l4 = Line.CreateBound(p4, p3);
curves.Add(l1);
curves.Add(l2);
curves.Add(l3);
curves.Add(l4);
Transaction transaction1 = new Transaction(doc);
transaction1.Start("Create Wall");
Wall w1 = Wall.Create(doc, curves, true);
transaction1.Commit();
return Result.Succeeded;
}
}
I am getting this error
What am I doing wrong ? and how can I edit these sketches. I'd appreciate any answer.