Using variables in Rhinoscript rs.Command()

What is the syntax for using variables in rs.Command()?
Here is a sample of what I have been trying to do:

import rhinoscriptsyntax as rs
p1 = rs.GetPoint(“First point”)
p2 = rs.GetPoint(“Second point”)
rs.Command ("_Line" p1 p2)

This works:

import rhinoscriptsyntax as rs
p1 = rs.GetPoint("First point")
p2 = rs.GetPoint("Second point")
rs.Command ("_Line " + str(p1) + " " + str(p2))

p1 and p2 are Point3d objects, you need to turn them into strings to get them to be read at the command line. You also need spaces at the right spots.

But, why bother? Just use:

import rhinoscriptsyntax as rs
p1 = rs.GetPoint("First point")
p2 = rs.GetPoint("Second point")
rs.AddLine(p1,p2)

Much simpler!

1 Like

Thank you.