Coud u please help me in this issue , after applying the python script make all connection , Run stop working !!!
This is the code ![]()
# Import Revit API
import clr
clr.AddReference(‘RevitAPI’)
clr.AddReference(‘RevitServices’)
from Autodesk.Revit.DB import \*
from Autodesk.Revit.DB.Plumbing import \*
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Assign Dynamo inputs
start_point = IN\[0\] # Start point (Point.ByCoordinates)
end_point = IN\[1\] # End point (Point.ByCoordinates)
pipe_type = IN\[2\] # Pipe type
system_type = IN\[3\] # System type
level = IN\[4\] # Level
diameter = IN\[5\] # Diameter
# Get current document
doc = DocumentManager.Instance.CurrentDBDocument
# Create pipe function
def create_pipe(start_point, end_point, pipe_type, system_type, level, diameter):
try:
# Check if all inputs are provided
if not all(\[start_point, end_point, pipe_type, system_type, level, diameter\]):
raise ValueError(“All inputs are required!”)
# Convert Dynamo points to XYZ in Revit
start_xyz = XYZ(float(start_point.X), float(start_point.Y), float(start_point.Z))
end_xyz = XYZ(float(end_point.X), float(end_point.Y), float(end_point.Z))
# Check if the system type, pipe type, and level exist in the document
if not doc.GetElement(ElementId(system_type.Id)):
raise ValueError(f"System type {system_type.Name} is invalid.")
if not doc.GetElement(ElementId(pipe_type.Id)):
raise ValueError(f"Pipe type {pipe_type.Name} is invalid.")
if not doc.GetElement(ElementId(level.Id)):
raise ValueError(f"Level {level.Name} is invalid.")
# Create the pipe using the provided types and parameters
pipe = Pipe.Create(
doc,
ElementId(system_type.Id),
ElementId(pipe_type.Id),
ElementId(level.Id),
start_xyz,
end_xyz
)
# Set the diameter for the pipe
parameter = pipe.get_Parameter(BuiltInParameter.RBS_PIPE_DIAMETER_PARAM)
parameter.Set(diameter)
return pipe
except Exception as e:
# If an error occurs, raise a ValueError with the error message
raise ValueError(f"An error occurred while creating the pipe: {str(e)}")
# Start the transaction in Revit
TransactionManager.Instance.EnsureInTransaction(doc)
# Try to create the pipe
try:
result = create_pipe(start_point, end_point, pipe_type, system_type, level, diameter)
except Exception as e:
result = str(e)
# End the transaction in Revit
TransactionManager.Instance.TransactionTaskDone()
# Output the result (the created pipe)
OUT = result
Th


