PDA

View Full Version : isPointSelected - unexpected results


MikieK
03-22-2012, 10:03 PM
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 ?

Bobo
03-22-2012, 10:17 PM
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

MikieK
03-22-2012, 10:20 PM
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.

Bobo
03-22-2012, 10:28 PM
Thanks bobo!

I was hoping to write something that would be more multi-use later on and was lead astray by the maxscript documentation...

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.

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.

MikieK
03-22-2012, 10:31 PM
thanks for clearing that up so quickly!

I was stumped for literally minutes :)

denisT
03-22-2012, 10:51 PM
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...

MikieK
03-22-2012, 10:55 PM
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

denisT
03-22-2012, 11:14 PM
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?

MikieK
03-22-2012, 11:30 PM
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)?

denisT
03-23-2012, 01:48 PM
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.

CGTalk Moderation
03-23-2012, 01:48 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.