CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 04-13-2013, 11:33 AM   #1
iCip
New Member
portfolio
United Kingdom
 
Join Date: Apr 2013
Posts: 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-18-2013, 12:13 AM   #2
LoneRobot
Swami Lama's Lovechild
 
LoneRobot's Avatar
portfolio
Pete Addington
Technical Director
Nexus
United Kingdom
 
Join Date: Dec 2004
Posts: 1,784
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-18-2013, 02:11 PM   #3
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,500
Send a message via ICQ to denisT
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-18-2013, 02:11 PM   #4
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,480
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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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:41 PM.


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