Problem with selection
Hi
I made a little script to random in z selected edges. ( like random boards )
It works fine but after using it I can't select another edges and run script as script use selection done before running script.
( a = $ selE = a.EditablePoly.getSelection #Edge as array try destroyDialog rlslice catch() global rlslice = rollout rlslice "RDM edges on Z" ( button butconnect "GO" pos:[2,2] spinner spX "MIN " width:90 range:[-10000,10000,-0.5] type:#float pos:[55,5] spinner spY "MAX " width:90 range:[-10000,10000,0.5] type:#float pos:[55,25] on butconnect pressed do ( undo on ( for ss in selE do ( pp = polyop.getEdgeVerts a ss as array ppx1 = a.verts[pp[1]].pos.z ppz2 = a.verts[pp[2]].pos.z ppx3 = ppx1 + random spx.value spy.value polyOp.setVert a pp[1] [ a.verts[pp[1]].pos.x , a.verts[pp[1]].pos.y , ppx3] polyOp.setVert a pp[2] [ a.verts[pp[2]].pos.x , a.verts[pp[2]].pos.y , ppx3] ) ) ) ) createDialog rlslice 160 50 )
I made a button to get selection to "reset" selection.
But it don't work... anybody can help ?
It is certainly a "$", "selection","$selection","GetCurrentSelection",.... problem ???
Thanks :-)
( try destroyDialog rlslice catch() global rlslice = rollout rlslice "RDM edges on Y" ( button butget "get" spinner spX "MIN " width:90 range:[-10000,10000,0] type:#float spinner spY "MAX " width:90 range:[-10000,10000,0] type:#float button butconnect "GO" on butget pressed do ( a=$ selE = a.EditablePoly.getSelection #Edge as array ) on butconnect pressed do ( undo on ( for ss in selE do ( pp = polyop.getEdgeVerts a ss as array ppx1 = a.verts[pp[1]].pos.z ppz2 = a.verts[pp[2]].pos.z ppx3 = ppx1 + random spx.value spy.value polyOp.setVert a pp[1] [ a.verts[pp[1]].pos.x , a.verts[pp[1]].pos.y , ppx3] polyOp.setVert a pp[2] [ a.verts[pp[2]].pos.x , a.verts[pp[2]].pos.y , ppx3] ) ) ) ) createDialog rlslice 160 150 )
Comments
my script :move edge
my script :
move edge randomly on z
move each vextex's edge randomly on z
:-)
.
To make it a little bit faster move the polyop.getEdgeVerts and polyop.setVert outside of the
on butconnect pressed do
and make them local variables to the rollout.Tools and Scripts for Autodesk 3dsMax
.
it seems like you overcomplicate things without a reason
Hi jahman , yes perhaps,but I
Hi jahman ,
yes perhaps,but I have in mind the possibility ( in futur ) to move randomly the vertex of same edge. :-)
.
Do you see why your script is not working?
You get the selected edges when you run the script and the roolout is created. After that every time when you press the GO button it will work with edges, selected when the script was executed.
The second version not works because the variables "a" and "selE" are local for the "GET" button and are not accessable by the GO button. This will solve the problem:
Tools and Scripts for Autodesk 3dsMax
Hi, Miauu Thanks again and
Hi, Miauu
Thanks again and again...
I knew that the first version have the problem, it is why I did the second one.
I undestand now the need to define variables locally for the whole script.
It wasn't so obvious to me that my variables was just defined inside the"on get pressed"
:-)