I'm having trouble figuring out why the new Wall.Create method is throwing an ArgumentNullException against my curve. What's throwing me off is that the deprecated method of creating a wall works just fine with the same curve.
I'm getting the curve from another element's location property (and previously ensuring it has a curve based location and not a locationpoint)
LocationCurve lCurve = (LocationCurve)elem.Location; curves.Append(lCurve.Curve);
My curve is not null and is of type Autodesk.Revit.DB.Line (see attachment) but throws an exception when I try to create a wall using the static Wall.Create method.
foreach (Curve c in curveArray) {
// This works but is deprecated Wall w = uidoc.Document.Create.NewWall(c, uidoc.ActiveView.GenLevel, false);
// This throws an ArgumentNullException (see attachment) Wall wall = Wall.Create(uidoc.Document, c, uidoc.ActiveView.GenLevel.Id, false); }
Is there something else that changed with the new Wall.Create method or am I missing something else? Has anyone else seen this?
Anyone? Autodesk?
Here is a simple example that throws the same exception when your selection set contains a line or wall.
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIDocument uiDoc = commandData.Application.ActiveUIDocument; Autodesk.Revit.UI.Selection.SelElementSet set = uiDoc.Selection.Elements; foreach (Element e in set) { Wall.Create(uiDoc.Document, (e.Location as LocationCurve).Curve, uiDoc.ActiveView.GenLevel.Id, false); } return Result.Succeeded; }
If I replace Wall.Create with the code below it works fine but this method is obsolete:
uiDoc.Document.Create.NewWall((e.Location as LocationCurve).Curve, uiDoc.ActiveView.GenLevel, false);
Hi Joe,
Please try with Curve.Clone() instead share the same curve between two elements. The Clone() will ensure a copy is used and avoid further problems.