PDA

View Full Version : Aligning objects on push of a Button


Guibou
05-27-2008, 03:50 PM
Hi everyone, I'm new to maxscript and here's what i'd like to do.

Setting:
- two Point Helpers (PT_01 and PT_02)
- one Shape (Shape)
- one Bone (Bone)

PT_01, PT_02 and Shape are linked to Bone.
One the press of a button i'd like to ALIGN in position Shape to either PT_01 or PT_02. So Shape switches position on the press of a button.

I've done this before by using two buttons. I'd like to simplify my UI by just having one button this time.
My Bone will be animated. So the Transform of my Point Helpers is always changing.

I hope this is clear enough. I've tried different things so far, but it's not working like i'd like to.

If someone could give me a hint it would be really appreciated. Thanks a lot.

decapitator
05-27-2008, 04:01 PM
Hi everyone, I'm new to maxscript and here's what i'd like to do.

Setting:
- two Point Helpers (PT_01 and PT_02)
- one Shape (Shape)
- one Bone (Bone)

PT_01, PT_02 and Shape are linked to Bone.
One the press of a button i'd like to ALIGN in position Shape to either PT_01 or PT_02. So Shape switches position on the press of a button.

I've done this before by using two buttons. I'd like to simplify my UI by just having one button this time.
My Bone will be animated. So the Transform of my Point Helpers is always changing.

I hope this is clear enough. I've tried different things so far, but it's not working like i'd like to.

If someone could give me a hint it would be really appreciated. Thanks a lot.Something like a simple caption on the buttons like PT_01 then if caption is PT_01 change caption to PT_02 and set 02 position and an else if for the other way around.
Or otherwise a simple variable on/off(bool) or whatever?

global PT
on btn pressed do
(
if PT == true then
(
.... = PT_02.pos
PT = false
)
else
(
.... = PT_01.pos
PT = true
)
)Something like this out the back of my head..
Or even a bit more like using index to cycle through based on the amount of $PT_*'s in your scene..

SyncViewS
05-27-2008, 08:34 PM
Hi guys,
you can check the current spline position with points position, since Shape and Points are all linked to the bone.


on btAlignButton pressed do
(
if (oShape.position == PT_01.position) then
(
oShape.position = PT_02.position
)
else
(
oShape.position = PT_01.position
)
)


Cheers

Guibou
05-28-2008, 12:20 AM
Hi guys thanks for your response,

Here is what i tried after reading your posts. I already tried it before. It works the first time i press the button, my Shape actually changes position but the second time i push it, nothing happens. It's like the "if then else" statement doesn't fully work. Thanks a lot guys.

Shape : s_eyelids_controls
PT_01 : h_eyelids_ancre_bones
PT_02 : h_eyelids_ancre_mesh
on switch_meshTorig pressed do

(

if ($s_eyelids_controls.position == $h_eyes_eyelids_ancre_bones.position)
then ($s_eyelids_controls = $h_eyes_eyelids_ancre_mesh)
else ($s_eyelids_controls.position = $h_eyes_eyelids_ancre_bones.position)
)

decapitator
05-28-2008, 10:39 AM
Hi guys thanks for your response,

Here is what i tried after reading your posts. I already tried it before. It works the first time i press the button, my Shape actually changes position but the second time i push it, nothing happens. It's like the "if then else" statement doesn't fully work. Thanks a lot guys.

Shape : s_eyelids_controls
PT_01 : h_eyelids_ancre_bones
PT_02 : h_eyelids_ancre_mesh
on switch_meshTorig pressed do

(

if ($s_eyelids_controls.position == $h_eyes_eyelids_ancre_bones.position)
then ($s_eyelids_controls = $h_eyes_eyelids_ancre_mesh)
else ($s_eyelids_controls.position = $h_eyes_eyelids_ancre_bones.position)
)



The then expression doesnt change position..?

Guibou
05-28-2008, 01:44 PM
The then expression doesnt change position..?


If == h_eyelids_ancre_bones (PT_01)
then = h_eyelids_ancre_mesh (PT_02)
else = h_eyelids_ancre_bones (PT_01)

Right now those are the positions that i'm trying to pass to my s_eyelids_controls (Shape).

Thanks for replying

erilaz
05-28-2008, 02:09 PM
I think what decapitator means is you're not defining a position in your then statement:


on switch_meshTorig pressed do

(

if ($s_eyelids_controls.position == $h_eyes_eyelids_ancre_bones.position) then
(
$s_eyelids_controls.position = $h_eyes_eyelids_ancre_mesh.position
)
else
(
$s_eyelids_controls.position = $h_eyes_eyelids_ancre_bones.position
)

)

decapitator
05-28-2008, 02:33 PM
Exactly and if you only define one position, it would only go to one position so you cant toggle it like you asked on how the button would do.

Guibou
05-28-2008, 03:14 PM
Well that was dumb lol

Thanks a lot guys for opening my eyes. This is a small part of a bigger script. Clearly i was looking at it with my eyes shut.

Really appreciate your time. Have a good day!

Guibou
05-28-2008, 11:55 PM
Hey guys! So i looked at my script again and added the .position to all of my states. It works the first time i push the button my shape moves to the other position, but when i push it again it doesn't go back to the first position. Here is what i have. If you guys can help me it would be appreciated. Thanks again :)

if
(
$s_eyelids_controls.position == $h_eyelids_ancre_bones.position
)
then
(
$s_eyelids_controls.position = $h_eyelids_ancre_mesh.position
)
else
(
$s_eyelids_controls.position = $h_eyelids_ancre_bones.position
)

CGTalk Moderation
05-28-2008, 11:55 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.