• 0 Vote(s) - 0 Average
• 1
• 2
• 3
• 4
• 5

# Drawing a line between points in sim

I'm trying to use the Python API to draw a visible line between a point that is at a fixed offset between the active tool's TCP and the origin of a reference frame. I can't seem to find a function that would accomplish this. Any thoughts?

Note: The end of the line tied to the TCP should follow the tool as it moves though a simulated program.
I attached a sample project that shows how to draw a line between the TCP and the origin of your coordinate system (or your desired coordinates with respect to this coordinate system).

You should follow these steps to run this example:
1. Double click on ShowLine Frame2Tool to run the script
2. Move the robot or run a program
The main loop looks like this:
Code:
```pose_tcp = tool.PoseTool() pose_frame_abs = frame.PoseAbs() pose_part_abs = part.PoseAbs() # Calculate the inverse (invariant) pose_part_abs_inv = pose_part_abs.inv() # Calculate the absolute coordinate of points, then the relative coordinates # P1 is static, it does not move p1_abs = pose_frame_abs * frame_coords p1_rel = pose_part_abs_inv * p1_abs # p2 is attached to the TCP and it is moving, iteratively update p2 # p2_abs = tool.PoseAbs() * pose_tcp.Pos() # moving p2_abs_last = p1_abs while True:    # Calculate p2 absolute coordinates    p2_abs = tool.PoseAbs() * pose_tcp.Pos() # moving    # Check if the point has changed    if robomath.distance(p2_abs_last, p2_abs) < 0.001:        continue    # Calculate the distance between the 2 points    distance = robomath.distance(p1_abs, p2_abs)    print("Distance: %.3f mm" % distance)    # Calculate the relative coordinates    p2_rel = pose_part_abs_inv * p2_abs    # Clear all object curves    part.setParam("Reset", "Curve")    # Add a line through 2 points    part.AddCurve([p1_rel, p2_rel], True, robolink.PROJECTION_NONE)    p2_abs_last = p2_abs    ```

Attached Files
That worked, thank you!

Follow up question, is there a way to adjust the line weight of a curve or set it's color via the API?
Yes, you can change the color of curves with the API.