Notifications
Clear all
[Closed] select subobject by number
Feb 23, 2011 10:31 pm
Id like to be able to select vertex 50…340 of for example a sphere. The following does this, but only on editable poly base objects. It should also work on edit poly modifiers according to the reference:
In the description of these methods, the first argument [b][b]<editable_poly_node_or_modifier>[/b][/b] should be interpreted as either an Editable Poly node where the modifier stack level is at the base object, or an Edit Poly modifier where the modifier stack level is at the Edit Poly. In all cases, the following methods work at the current sub-object level, but only if that level is appropriate for the invoked operation.
It doesn’t however, giving an error that a poly operation was applied to a nom-poly object.
Here is the code. Im very new to this, so would you kindly explain how to create an event handler that fires whenever an object is selected?
rollout SelectVert "Select Vertices" width:162 height:300
(
label lbl1 "From" pos:[13,8] width:42 height:17
spinner spn3 "" pos:[46,7] width:42 height:16 type:#integer range:[1,10000,1]
label lbl2 "To" pos:[14,30] width:29 height:16
spinner spn4 "" pos:[47,28] width:43 height:16 type:#integer range:[1,10000,1]
button btn2 "Select verts" pos:[16,65] width:99 height:19
fn changeRange =
(
obj=selection[1]
if classof obj==Editable_poly or classof obj == PolyMeshObject then
(
numVerts=polyOp.getNumVerts obj
spn3.range = [1,numVerts,1]
spn4.range = [1,numVerts,1]
print "changed range"
)
)
on selection changed do
(
changeRange() -- doesn't work
)
on btn2 pressed do
(
-- store the selected object
obj=selection[1]
if classof obj==Editable_poly or classof obj== PolyMeshObject then
(
sel = polyop.getVertSelection obj
with undo "select vertices" on
(
for i = spn3.value to spn4.value do
append sel i
polyop.setVertSelection obj sel
)
)
else (
MessageBox "Please select an editable poly (or edit poly modifier)"
)
)
tested with a sphere collapsed to editable poly (works), after which I added edit poly on the stack (error).