Creating Curves for Walls


As a training exercise, I’m trying to create a Revit Wall using Python inside Dynamo.

I found the Wall.Create Method in the API and am trying to create all the parts to generate a wal:

Wall.Create(Document, Curve, ElementId, Boolean)

I’m stuck on the requirement for a Curve.

To create the curve I’ve created a start and end point using Autodesk.Revit.DB.XYZ:
startxyz = Autodesk.Revit.DB.XYZ(0, 0, 0)
endxyz = Autodesk.Revit.DB.XYZ(1000, 1000, 0)

I’ve then passed this to a line:

wallpointsline = Autodesk.Revit.DB.Line.CreateUnbound(startxyz, endxyz)

and I now want to create a curve: (which I think MakeUnbound is the one to use??)

wallpoints = Autodesk.Revit.DB.Curve(wallpointsline)

I get this error:

TypeError: Cannot create instances of Curve because it has no public constructors

I’d appreciate some advice on what I’m doing wrong, I’m struggling to find out what ‘No public constructors’ means.


Line, which you already created is a Curve, so you can pass that directly into Wall.Create(). This is semantics of how classes are structured and what they inherit from. In this case Curve is an abstract class hence cannot be instantiated because it doesn’t have a constructor. You can read more about it here:

1 Like

OK, thanks, when I try a transaction I get a ‘Serious Error’ from Revit:

Note that the IN variable is from a Level node > Get Level ID node in Dynamo

dataEnteringNode = IN

IN = UnwrapElement(IN[0])
levelid = IN.Id
startxyz = Autodesk.Revit.DB.XYZ(0, 0, 0)
endxyz = Autodesk.Revit.DB.XYZ(1000, 1000, 0)

wallpointsline = Autodesk.Revit.DB.Line.CreateUnbound(startxyz, endxyz)

transaction = Transaction(doc, “Random Walls”)
newwall = Autodesk.Revit.DB.Wall.Create(doc, wallpointsline, levelid, 0)

OUT = 0

Perhaps I’m messing up the transation - nonetheless, Dynamo gives no errors…

  1. You’ll need to create a bound line. That means it’ll have a fixed start and end points. Unbound lines are indefinitely long. Consider reusing the dynamo geometry instead of re-constructing new geometry from scratch. After you create a line in dynamo, you can then convert it to a Revit curve with the .ToRevitType() method. You’ll learn more about that from the link at the bottom.

  2. Revit works in feet internally, so your wall might end up being very long. (1000 feet! )

  3. Try to use Dynamo’s built in transaction manager until you get a hand of how transactions work. You’ll find more example on this and other python related stuff here:

4)Consider wrapping the wall element at the end so that you don’t end up creating duplicates every time you re-run the graph.

1 Like

Great - thanks.

It works fine if used with a BoundLine… that was the problem.