[Closed] SetSelection with Edit_Poly Modifier
This is driving me crazy…
theObject = modPanel.getCurrentObject()
thePolys = ( theObject.GetSelection #Face node:selection[1] ) as array
i = 1
theObject.SetSelection #Face #{thePolys[i]}
Just doesn’t select anything! and no errors…
And can’t seem to set Material IDs with an Edit Poly Modifier either…
I don’t particularily want to collapse the stack…
this one took me a while it’s this
theSelectedFaces = ($.Edit_Poly.getSelection #Face) as array
will return the numbers of the selected faces in an edit_poly modifier.
-Colin
My code happily returns the faces as an array, i’m then trying to set the selection so it’s just the nth number of the array.
If the array was #(1,5,6,7,8,) I’d like to be able to say ok 3rd array item = 6, so select the face with the ID of 6.
Delving into what I was getting at a bit further in the maxscript reference you will find “Edit_Poly.Select”
convert your regular array #(1,4,6) to a bitarray with a for loop
arr = #(1,4,6)
bitarr = #{}
for i=1 to arr.count do bitarr[(arr[i])] = true
-- bitarr now holds the bitarray of the faces you want to select, pass this to the below command
$.Edit_Poly.Select #Face bitarr
yes?
it appears to be waiting for another argument… press escape to get interupted
This even happens with just
$.editpoly.setSelection #face #{1}
Seems to work for me except for the “node:selection[1]” part. Max (2009, SP1) complains with:
-- Error occurred in anonymous codeblock; filename: none; position: 0
-- Frame:
-- Argument count error: GetSelection wanted 1, got 1
If I remove that part, it ends up selecting the first face in the selected faces array. It does throw an error if I didn’t have anything selected initially, of course.
I get that If i run it on an collapsed object, but I’m using an edit_poly modifier, try it with that instead. See if you get the none-selection problem I get.
Right just to make clear…
I’m using 3dsmax 9 32bit, no sp.
I’ve got a plane, some polys selected.
A greeble modifier which selects some faces.
and then an Edit_Poly on top.
The edit_poly on top is what I want to edit.
theObject = modPanel.getCurrentObject()
thePolys = ( theObject.GetSelection #Face node:selection[1]) as array
for i = 1 to thePolys.count do
(
theObject.SetSelection #Face #{thePolys[i]}
--setmaterialID to 10
theObject.MaterialIDtoSet = 10
)
I’ve striped all my other code out so i’m just trying to get this to work…
You can cut that down by using something as
#(1,5,10,11,12,13) as bitArray
--and vice versa
#{1..3, 5..7, 9, 11} as Array
Doesn’t work here either…usinjg 2008.
But as I said before even a simple
$.modifiers[#Edit_Poly].setSelection #face #{1}
doesn’t work. Whatever the number in the bitarray it always returns true, even if that number is higher than face count. It also still says interrupted if escape is pressed, which suggests to me that it’s missing an argument or something?