Revit Dynamo - Wall.Create / From Profile Question

Hello Everyone,

I have an issue with Wall.Create(Document, IList(Curve), ElementId, ElementId, Boolean) in Revit Dynamo. Right now, I am trying to create a script that can draw a wall using outlines from faces of other geometry.

This is the primary actionable code:
new_wall = Wall.Create(doc, cur, wallType.Id, level.Id, False)

doc is simply generated through the pythonic script (similar boilerplate to other examples here
image

cur is an input of curves (Lines) in this case:
image

The other inputs (ignoring IN[0] which is unused) are the components required for the rest of the function, these are unwrapped before implementation
image
image

I had seen other instances of question like this reference the directionality of the curves of the list, but the lack of description in the error makes it hard for me to identify what the exact problem is. I am also uncertain as to how exactly I could consistently control for that parameter.

This would be easier for me to set up in C#, but for this purpose I need it to run through Dynamo. Based on my given script, what did you think that the error could be? I know that the API limits wall creation through surfaces not from Masses, is this a similar case of just a limitation of the API or is there something I should fix?

Any help would be great thank you,

Have you converted the Dynamo curves to Revit curves? And the list to a C# list?

Likely need you to post the full code to help as we are just guessing otherwise.

Code is pretty straight foward, I wasn’t having success with the code and the conversion with .ToRevitType as that continually gave me errors:


#----------------------------------#
# Load the Python Standard and DesignScript Libraries
import sys
#----------------------------------#
import clr
# Import Element wrapper extension methods
clr.AddReference("RevitNodes")
#----------------------------------#
import Revit
clr.ImportExtensions(Revit.Elements)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
#----------------------------------#
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Import RevitAPI
clr.AddReference("RevitAPI")
#----------------------------------#
import Autodesk
from Autodesk.Revit.DB import *
#----------------------------------#
import System
from System.Collections.Generic import *
from System.Collections.Generic import List
#----------------------------------#


#----------------------------------#
doc = DocumentManager.Instance.CurrentDBDocument 

reference = IN[0]
wallType = UnwrapElement(IN[1])
level = UnwrapElement(IN[2])
cur = IN[3]

TransactionManager.Instance.EnsureInTransaction(doc)
  
  

try:
    new_wall = Wall.Create(doc, cur, wallType.Id, level.Id, False)
    if new_wall is not None:
            OUT = "Wall created successfully"
    else:
            OUT = "Wall.Create returned None. Check your input parameters."
except Exception as e:
    OUT = f"An error occurred: {str(e)}"



TransactionManager.Instance.TransactionTaskDone() 

#OUT = cur

you need to import the GeometryConversion tools (extension methods)


#----------------------------------#
# Load the Python Standard and DesignScript Libraries
import sys
#----------------------------------#
import clr
# Import Element wrapper extension methods
clr.AddReference("RevitNodes")
#----------------------------------#
import Revit
clr.ImportExtensions(Revit.Elements)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
#----------------------------------#
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Import RevitAPI
clr.AddReference("RevitAPI")
#----------------------------------#
import Autodesk
from Autodesk.Revit.DB import *
#----------------------------------#
import System
from System.Collections.Generic import *
from System.Collections.Generic import List
#----------------------------------#
clr.AddReference("RevitNodes")
import Revit

# Import ToProtoType, ToRevitType geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)

#----------------------------------#
doc = DocumentManager.Instance.CurrentDBDocument 

reference = IN[0]
wallType = UnwrapElement(IN[1])
level = UnwrapElement(IN[2])
cur = IN[3]
listDBCurves = List[Curve]([i.ToRevitType() for i in cur])

TransactionManager.Instance.EnsureInTransaction(doc)

try:
    new_wall = Wall.Create(doc, listDBCurves, wallType.Id, level.Id, False)
    if new_wall is not None:
            OUT = "Wall created successfully"
    else:
            OUT = "Wall.Create returned None. Check your input parameters."
except Exception as e:
    OUT = f"An error occurred: {str(e)}"

TransactionManager.Instance.TransactionTaskDone()
1 Like

I had to import both of those additional extensions, but I have something functional now.


# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)

# Import Element wrapper extension methods
clr.ImportExtensions(Revit.Elements)

That said THANK YOU SO MUCH.

This is great, I want to play with this script a bit more then I will post the end results.

2 Likes