Hi, I am trying to create staircase in dynamo using python program.
The code is as below*
import clr
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Debugging
print("Starting Dynamo Python script")
try:
# Get the current Revit document
doc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument.Document
print("Document loaded.")
# Inputs from Dynamo (unwrap the elements)
level_start = UnwrapElement(IN[0]) # Base Level
print(f"Base Level: {level_start}")
level_end = UnwrapElement(IN[1]) # Top Level
print(f"Top Level: {level_end}")
stair_location_curve = UnwrapElement(IN[2]) # Location Curve
print(f"Stair Location Curve: {stair_location_curve}")
stair_type = UnwrapElement(IN[3]) # Stair Type
print(f"Stair Type: {stair_type}")
riser_height = float(IN[4]) # Ensure riser height is a float
tread_depth = float(IN[5]) # Ensure tread depth is a float
# Start a transaction in Revit
TransactionManager.Instance.EnsureInTransaction(doc)
# Create the stairs
stairs = Stairs.Create(doc, stair_type.Id, level_start.Id, level_end.Id)
print("Stairs created successfully.")
# Commit the transaction
TransactionManager.Instance.TransactionTaskDone()
# Output the result
OUT = stairs
except Exception as e:
# Catch and output the error
OUT = f"Error: {e}"
print(f"Error: {e}")
There is error message that is openparenexpected.
Can someone please help me solve this problem?
Thank you in advance.