Creating walls by profil error

hi everybody,

I keep getting error today when trying to create walls from a set of lines/curves.

# Load the necessary libraries
import clr
clr.AddReference("RevitAPI")
clr.AddReference("RevitServices")
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
from System.Collections.Generic import List

# Dynamo inputs
curves = IN[0]
doc = DocumentManager.Instance.CurrentDBDocument

# Output list of walls created
created_walls = []

# Start a transaction in Dynamo
TransactionManager.Instance.EnsureInTransaction(doc)

# Loop through each polycurve, convert to a curve array and create a wall
for curvelist in curves:
    list = List[Curve]()
    for curve in curvelist:
        list.Add(curve)
    # Create a CurveArray for the polycurv
    try:
        wall = Wall.Create(doc, list, True)
        created_walls.append(wall)
    except Exception as e:
        # Handle exceptions if wall creation fails
        created_walls.append(f"Error creating wall: {e}")
        created_walls.append(curvelist)
        

# End the transaction
TransactionManager.Instance.TransactionTaskDone()

OUT = created_walls

The wierd thing is that yesterday the code seemed to work.
they error right now stades that i’m not using the right arguments, but i pretty sure i am based on the revit api to created a default wall:

public static Wall Create(
	Document document,
	IList<Curve> profile,
	bool structural
)

Are your curves in IN[0] Revit curves or Dynamo ones?

jup :):
The first python node extraces the lines from the intersections between masses.
The second (top) python script is the one above.
The third (rightside) script is one simular to the above but with type and level arguments included.

you need to convert geometry

import clr
import sys
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('RevitAPI')
import Autodesk.Revit.DB as DB
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
# rest of code
for curvelist in curves:
    list_rvt_curves = List[DB.Curve]()
    for curve in curvelist:
        list_rvt_curves.Add(curve.ToRevitType())

# rest of code

some infos here

2 Likes

I’ll check you link, thx for the information.

I do still get an error on the arguments tho:

Probably due to a namespace conflict

I updated the code

It was a speeling mistake and the fact that the Ilist was not needed anymore.
But now it all works!

Super info ont he migration!

1 Like