Hobbs
03-17-2009, 05:44 PM
I'm trying to make a simple script where, when the checkbutton is activated, the first vert you select while holding shift, it stores the position, and then next vert you select while hold shift moves it to that first position
example..
shift select vert 1 -- stores position
shift select vert 2 -- moves to vert 1 position
shift select vert 3 -- stores position
shift select vert 4 -- moves to vert 3 position
etc.
I've always had problems trying to get callbacks to work in these instances because i don't know which ones to pick..
And i'm sure this could be done far more efficiently but i'm not sure how.. also i have to use mesh for reasons i can't go into...
here's what i have so far, help would be appreciated. thanks
(
global AlignVertCallback
rollout AlignVertCallback "" width:134 height:26
(
checkButton run "Run" pos:[19,5] width:101 height:16
local MasterPos
local pressed = 1
-- Function for getting vert position
-- ====================================
fn getMeshVert obj =
(
VertArray = getVertSelection(obj) as array
return( getVert obj VertArray[1] )
);
-- Function for moving vert position
-- ====================================
fn moveMeshVert obj pos =
(
VertArray = getVertSelection($) as array
for vert in VertArray do
meshOp.moveVert obj vert pos
);
-- Function for helping with aligning verts
-- ====================================
fn Select_nMove obj =
(
if obj != undefined then
(
if keyboard.SHIFTpressed and subobjectLevel == 1 do
(
-- first pressed
if pressed == 1 then
(
MasterPos = ( getMeshVert obj )
pressed = 2
)
-- second pressed
else
(
moveMeshVert obj MasterPos
pressed = 1
)
)
)
)
-- While loop to make sure button is running.
-- ====================================
on run changed state do
(
if state == on then
callbacks.addScript #selectionSetChanged "AlignVertCallback.Select_nMove $" id:#SHIFTalignVerts
else
callbacks.removeScripts id:#SHIFTalignVerts
)
)-- end rollout
createDialog AlignVertCallback style:#(#style_toolwindow, #style_sysmenu, #style_resizing)
)
example..
shift select vert 1 -- stores position
shift select vert 2 -- moves to vert 1 position
shift select vert 3 -- stores position
shift select vert 4 -- moves to vert 3 position
etc.
I've always had problems trying to get callbacks to work in these instances because i don't know which ones to pick..
And i'm sure this could be done far more efficiently but i'm not sure how.. also i have to use mesh for reasons i can't go into...
here's what i have so far, help would be appreciated. thanks
(
global AlignVertCallback
rollout AlignVertCallback "" width:134 height:26
(
checkButton run "Run" pos:[19,5] width:101 height:16
local MasterPos
local pressed = 1
-- Function for getting vert position
-- ====================================
fn getMeshVert obj =
(
VertArray = getVertSelection(obj) as array
return( getVert obj VertArray[1] )
);
-- Function for moving vert position
-- ====================================
fn moveMeshVert obj pos =
(
VertArray = getVertSelection($) as array
for vert in VertArray do
meshOp.moveVert obj vert pos
);
-- Function for helping with aligning verts
-- ====================================
fn Select_nMove obj =
(
if obj != undefined then
(
if keyboard.SHIFTpressed and subobjectLevel == 1 do
(
-- first pressed
if pressed == 1 then
(
MasterPos = ( getMeshVert obj )
pressed = 2
)
-- second pressed
else
(
moveMeshVert obj MasterPos
pressed = 1
)
)
)
)
-- While loop to make sure button is running.
-- ====================================
on run changed state do
(
if state == on then
callbacks.addScript #selectionSetChanged "AlignVertCallback.Select_nMove $" id:#SHIFTalignVerts
else
callbacks.removeScripts id:#SHIFTalignVerts
)
)-- end rollout
createDialog AlignVertCallback style:#(#style_toolwindow, #style_sysmenu, #style_resizing)
)
