How to select points by coding

Hello,

I want to select some points of the polyline to move,but I need to select them by coding instead of mouse selecting . How can I do this?
For example , I get position Y data of the polyline points , then I can get the points that the Y value less than 0 , I am confusing how to ‘select’ the point that I need?

Best regards,

Hearts_j

polyline is really just a collection of points
if you need to select vertices that have Y value less than 0 on a polyline you can perhaps try this:

import Rhino.Geometry as rhg
d = rhg.Point3d(0,0,5)
# x is your polyline
selected = [(i,p) for (i,p) in enumerate(x) if p.Y<0]
for i,p in selected:
    x[i] += d

This python code will “select” ones with Y values less than 0 and move them up Z-axis 5 units. variable x has been changed.

Hi Will_Wang,

Thank you for your reply.
I know how to do it in the rough.But it seems doesn’t work,I don’t know what I missed.

   Public Function moveBottomPointDown(ByVal sectionOfstCurve As Curve, ByVal doc As RhinoDoc) As Rhino.Geometry.Curve
        Dim tmpPolyCurve As PolylineCurve
        tmpPolyCurve = sectionOfstCurve.ToPolyline(5, 1, Math.PI, 0.1, 1, 0.1, 0.3, 10, True)
        For i = 0 To tmpPolyCurve.PointCount - 1
            If tmpPolyCurve.Point(i).Z <= 2.02 Then
                Dim xFormMove As Transform
                xFormMove = Transform.Translation(0, 0, -2.5)
                tmpPolyCurve.Point(i).Transform(xFormMove)
                'It seems doesn't work
                Rhino.RhinoDoc.ActiveDoc.Objects.AddPoint(tmpPolyCurve.Point(i))

            End If
        Next
        Return tmpPolyCurve
    End Function

Best regards,

Hearts_j

is there error message or simply nothing happens?

Hi Will_Wang,

There is nothing happens.
Base your advise , I picked up the points needed and moved them directly, then regenerated a new polyline.It works.
I am just confused why " tmpPolyCurve.Point(i).Transform(xFormMove) " couldn’t work?

Best regards,

Hearts_j

If I have to guess it probably has to do with reference type of data. In this case the vertices on a polyline aren’t through reference. Calling point.Transform() is supposed to alter a reference type. In this case it doesn’t. Mine is explicitly assigning a new point at the given vertex index.
Just my wildest guess…