Maxscript transformation buttons

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 04 April 2013   #1
Maxscript transformation buttons

Hello,

I am trying to learn Maxscript and I am also new to any type of programming.

I am stuck with making a script to just control the position, rotation and scale of objects.

I have 3 spinners, representing x, y, z values and 3 check buttons under it. I want to assign for the first check button a translation function, for the second rotation and for the third a scale. The translation, rotation and scale values will be set by the spinners. In this way I don't need to create 3 sets of spinners each with a xyz value.

Here is what I have now:

group "Translate"
(
spinner TrsSpinnerX "X:" range:[-1000,1000,0] type:#float scale: 1 width:80 across: 3 align:#center
spinner TrsSpinnerY "Y:" range:[-1000,1000,0] type:#float scale: 1 width:80 align:#center
spinner TrsSpinnerZ "Z:" range:[-1000,1000,0] type:#float scale: 1 width:80 align:#center
)

on TrsSpinnerX entered do
(
$.pos.X = TrsSpinnerX.value
)

on TrsSpinnerY entered do
(
$.pos.Y = TrsSpinnerY.value
)

on TrsSpinnerZ entered do
(
$.pos.Z = TrsSpinnerZ.value
)

checkbutton TranslationB "Translation" checked:true tooltip:"Enables translation" across: 3
on TranslationB changed state do
if state == on then

else


checkbutton RotationB "Rotation" checked:false tooltip:"Enables rotation"
on RotationB changed state do
if state == on then

else


checkbutton ScaleB "Scale" checked:false tooltip:"Enables scaling"
on ScaleB changed state do
if state == on then

else

The problem I do not know what to add to the 'if' statement at the checkbuttons. For example, when I click on the 'translate' button I want this code to be enabled:

on TrsSpinnerX entered do
(
$.pos.X = TrsSpinnerX.value
)

and when I uncheck the button to disable it.

I hope you can uderstand. Any suggestions please?
 
Old 04 April 2013   #2
Here is a basic snippet for you to look at.

Code:
rollout transRollout "" width:259 height:73 ( mapped fn applyTransform obj axis val = ( -- includes a catch for Bezier scale controllers tmPart = case of ( (transRollout.TranslationB.checked):obj.position.c ontroller (transRollout.RotationB.checked):obj.rotation.cont roller (transRollout.ScaleB.checked):obj.scale.controller ) -- check for bezier scale if classof tmPart == bezier_scale then ( case axis of ( 1:(tmPart.value = [val/100,tmPart.value[2],tmPart.value[3]]) 2:(tmPart.value = [tmPart.value[1], val/100, tmPart.value[3]]) 3:(tmPart.value = [tmPart.value[1],tmPart.value[2],val/100]) ) ) else tmPart[axis].value = val ) groupBox grpHeader "Translate" pos:[4,2] width:249 height:41 spinner TrsSpinnerX "X:" pos:[19,20] width:68 height:16 range:[-1000,1000,0] type:#float scale:1 across:3 spinner TrsSpinnerY "Y:" pos:[99,20] width:68 height:16 range:[-1000,1000,0] type:#float scale:1 across:3 spinner TrsSpinnerZ "Z:" pos:[179,20] width:68 height:16 range:[-1000,1000,0] type:#float scale:1 across:3 checkbutton TranslationB "Translation" pos:[6,48] width:82 height:21 toolTip:"Enables translation" checked:true across:3 checkbutton RotationB "Rotation" pos:[91,48] width:77 height:21 toolTip:"Enables rotation" checked:false across:3 checkbutton ScaleB "Scale" pos:[170,48] width:84 height:21 toolTip:"Enables scaling" checked:false across:3 local ckbUi = #(TranslationB,RotationB,ScaleB) on TranslationB changed state do ( if state then ( for i in ckbUi where not i== TranslationB do i.checked = false grpHeader.text = "Translate" ) else TranslationB.checked = true --the else here makes sure you cant disable all the checkbuttons, so one must always be enabled. ) on RotationB changed state do ( if state then ( for i in ckbUi where not i== RotationB do i.checked = false grpHeader.text = "Rotate" ) else RotationB.checked = true ) on ScaleB changed state do ( if state then ( for i in ckbUi where not i== ScaleB do i.checked = false grpHeader.text = "Scale" ) else ScaleB.checked = true ) on TrsSpinnerX changed val do applyTransform (selection as array) 1 val on TrsSpinnerY changed val do applyTransform (selection as array) 2 val on TrsSpinnerZ changed val do applyTransform (selection as array) 3 val ) createdialog transRollout
__________________
Regards,
Pete

Read my technical blog - lonerobot.net
 
Old 04 April 2013   #3
it think that the spinners have to have separate set for every transform. also all transformations has to be undoable, and work for any type of controller... is it possible?
 
Old 04 April 2013   #4
Thread automatically closed

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.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 10:36 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.