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: 

Wall.Create throwing exception

2 REPLIES 2
Reply
Message 1 of 3
joesferrazza2589
407 Views, 2 Replies

Wall.Create throwing exception

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?

 

2 REPLIES 2
Message 2 of 3

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);

 

Message 3 of 3

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.

 

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community