Python script for dynamo in revit

Hi Guys i would like to replicate the exact python script for Line.Bytangency node which is default node in dynamo
My goal is to write the python script for dynamo in revit for Line.Bytangency node
here is the python script which i wrote but i found error while executing

Importing necessary modules from Revit API

import clr

Import Revit API classes

clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import Line

Inputs

curve = IN[0] # The input curve
parameters = IN[1] # List of parameters

tangent_lines =

Loop through each parameter in the list

for parameter in parameters:
# Evaluate the point on the curve at the given parameter
tangent_point = curve.Evaluate(parameter, True)
# Compute the tangent vector at that point
tangent_vector = curve.ComputeTangent(parameter)

# Define the length of the tangent line (you can set this as desired)
length = 10  # Adjust the length as needed
line_end = tangent_point + tangent_vector * length  # Calculate the end point of the tangent line

# Create the tangent line
tangent_line = Line.CreateBound(tangent_point, line_end)
tangent_lines.append(tangent_line)

Output the list of tangent lines

OUT = tangent_lines
image 1

some one please resolve this issue i am stuck in the issue for past 1 week

Did chatgpt write this? If so maybe telling it some of below may help, but generally I prefer not to fix chatgpt code for people as it sends the message that it’s a suitable tool to replace learning to code.

I don’t believe compute tangent is a method of the line/curve classes.

ComputeDerivatives is generally the method I use for these types of tasks. Its documentation explains the components it returns in its transform object.

3 Likes