Preview of line between two points picking

is it possible with python to have the dinamic preview of line when we pick the second point?
like when you create a line in rhino…

i would like to create blacks lines, with in entry the X distance, the first point pickked (0) and the second point picked(1)


GetLine hase a mode=1 to preview the line

import rhinoscriptsyntax as rs


the return is a tuple of the 2 points

does that help?

yes it is!!!
i don’t understand why i didn’t find it!!!

but now if i want to have the preview of the black line during the second point selection, i need to use Rhinocomon, no?

Yes, you will need to calculate the two black lines - I assume based on some reference line or plane - and then set up a custom dynamic draw preview. It is somewhat complicated.

Ok thank you, so i 'll try to script it python…

from Rhino import *
from Rhino.Geometry import *
from Rhino.Commands import *
from Rhino.Input.Custom import *
from scriptcontext import doc
from System.Drawing import *

def RunCommand():
    gp = GetPoint()
    gp.SetCommandPrompt("First point")
    if gp.CommandResult() <> Result.Success:
        return gp.CommandResult()
    c1 = gp.Point()

    gsp = GetSecondPoint(c1)
    gsp.SetCommandPrompt("Second point")
    if gsp.CommandResult() <> Result.Success:
        return gsp.CommandResult()
    c2 = gsp.Point()

    doc.Objects.AddLine(Line(c1, c2))
    return Commands.Result.Success

class GetSecondPoint(GetPoint):
    def __init__(self, c1):
        self.m_c1 = c1

    def OnDynamicDraw(self, e):
        rec = Rectangle3d(Plane.WorldXY, self.m_c1, e.CurrentPoint).ToPolyline()
        e.Display.DrawPoints([self.m_c1, e.CurrentPoint], Display.PointStyle.X, 4, Color.White)
        e.Display.DrawLine(Line(self.m_c1, e.CurrentPoint), Color.Red)
        e.Display.DrawLine(rec.SegmentAt(0), Color.Black, 1)
        e.Display.DrawLine(rec.SegmentAt(2), Color.Black, 1)

if __name__=="__main__":
    RunCommand() (1.2 KB)

1 Like

yes but the Distance X between two black line have to be fixe, 50mm for example…

your black lines stay horizontal, that is not that i want… i don’t have time for the moment, but thank your your script will help me for the “dynamic draw”
i the end i would like to create the green tube:

with only the the selection of 3 points, start, end, and a third point to define the plane.