[Closed] isPointSelected – unexpected results
Greetings
I’m writing a simple spline alignment tool, but was hoping to add the option of restricting the alignment to selected vertices by checking isPointSelected.
However in testing, I’m getting unexpected results.
I.E. draw a spline, select it, enter sub object vertex selection mode and select a vertex, for instance the second one.
isPointSelected $ 2
returns false.
…in fact i can’t get it to return true, unless I select all the vertices?
Any idea what I’m doing wrong?
Cheers
Mikie
Seems there are there 3 points per vertex fpor some reason?
I.E. vertex 2 is referenced by isPointSelected $ 4 or 5 or 6 ?
isPointSelected() is a NURBS method. So if you are drawing a Spline (Line), when you call the method, it converts it to a NURBS curve implicitly and returns the result from that.
To see what is going on, convert your Line to NURBS curve and you will see that for each segment, it creates two additional CVs (control vertices).
To get the selection from a Line/EditableSpline, you should use the SplineShape methods, e.g.
getKnotSelection $ 1
where the second argument is the Spline Index, and the result is an Array of all selected knots. So if you select all 3 knots in a Line, you will get #(1,2,3) back. You could easily convert it to a bitArray and query by index like this:
((getKnotSelection $ 1) as bitarray)[2] --> returns true if knot 2 is selected
Thanks bobo!
I was hoping to write something that would be more multi-use later on and was lead astray by the maxscript documentation…
Found under Node: Miscalaneous Node Methods
isPointSelected <node> <point_index>
Returns true if the specified point is selected, false if not. The definition of a’point’varies depending on the object type. For meshes, it is the mesh vertex. For a spline, it is the knot. For NURBS objects, it is the vertex or control point.
isPointSelected works right for me. At least how I expect it. For splines the method counts all spline points including in-tangent, knot itself, and out-tangent.
It means the first knot will be 2nd point, the second knot will be 5th point…
That seems quite wrong, glad I did not write that paragraph
Will add it to the list of things to fix. It does work correctly for Meshes though, just the Spline implementation (or documentation) seems wrong.
thanks for clearing that up so quickly!
I was stumped for literally minutes
Hi Dennis
That’s what I came up with as well at first… But the behaviour seems to change when to go into subobject mode 2 or 3. With 2 points per knot? Again… Unless I’m confused, which is almost a permanent state for me
for every knot and every knot type are always 3 points. It can’t be 2.
how does the behavior change?
my semi-random test spline has 1 spline 3 knots, roughly U shaped.
with subobjectlevel == 3, and whole spline selected
or
with subobject level == 2, it doesn’t seem to matter if segment 1, or segment 2 is selected
for n = 1 to 9 do print (isPointSelected $ n)
returns 0,0,0,1,1,1,1,1,1
(most likey answer is that it is only meant to work in subObjectLevel 1)?
if any segment selected it doesn’t mean that all its verts automaticaly selected. Selection of a segment or a spline of the editable spline doesn’t effect point selection. isPointSelected has to give the same result for every sub-object level.