Extracting Start and End Points from Lines for RSA API by using python

Hello everyone,

I have a list of lines for which I need to obtain the start and end point coordinates. My goal is to create these lines in RSA using the RSA API. Below is the logic I’m planning to use:


# Import the RSA API libraries
import clr
clr.AddReference('RobotOM')
import RobotOM

# Function to translate Dynamo lines to RSA nodes and bars
def translate_line_to_rsa(line, rsa_model):
    start_point = line.StartPoint
    end_point = line.EndPoint
    
    # Create nodes at the start and end of the line
    start_node_id = rsa_model.Project.Structure.Nodes.Create(start_point.X, start_point.Y, start_point.Z)
    end_node_id = rsa_model.Project.Structure.Nodes.Create(end_point.X, end_point.Y, end_point.Z)
    
    # Create a bar between the start and end nodes
    bar_id = rsa_model.Project.Structure.Bars.Create(start_node_id, end_node_id)
    
    # Set the section for the bar (example section name)
    rsa_model.Project.Structure.Bars.Get(bar_id).SetSection('EXAMPLE_SECTION_NAME')
    
    return bar_id

# Connect to RSA
robot_app = RobotOM.RobotApplicationClass()
robot_app.Interactive = False
robot_project = robot_app.Project
robot_structure = robot_project.Structure

# Assume 'lines' is a list of Dynamo lines passed into the script
for line in IN[0]:  # IN[0] is where Dynamo inputs are accessed
    translate_line_to_rsa(line, robot_project)

# Finalize changes in RSA
robot_structure.FinishEdition()

# Return something if needed
OUT = "Script completed"

However, I believe there is no command like line.StartPoint . Can anyone suggest an alternative or provide guidance on this matter?"

@ugur_yavan_61 Quickstart Guide for Dynamo in RSA 2023 - Robot Structural Analysis - Dynamo (dynamobim.com)

Did u read this ??

i don’t have the RSA documentation but in revit api startpoint and end point work in this manner with this method of “GetEndPoint” , Here if need startpoint passing indes as 0 and 1 for the endpoint so u could see if there’s something similar to this exist in RSA Api.

Thanks,
BM

Thank you for your reply.
Is there any way to do it by using Autodesk design script Geometry ? We can use the code in code block as in the figure. Can’t we use same command in python ?

hey @ugur_yavan_61

Here i have brokendown what u asked for in multiple scenarios and kept 3 ways however the scenario u encounter during execution, please go though it and hopefully it resolves your query and help u meet your goal


Thanks
BM