PDA

View Full Version : "Newbie Question ( about sliders )"


ozioz
05-05-2007, 05:46 PM
Hi Guys;

I am a newbie for MEL an ı have been studying it for last 30 days. I have already learned the fundamentals of MEL scripting and recently I started to build something realy basic..

I attempt to create a script that opens up a window containing ona button an a slider. the button for creating a sphere ( ıt is gonno be a polysphere by the way ) The slider will control the radius of this sphere...

Yes I know that it is totaly a stupid script and sound a little bit crazy... I was able to build the UI and button and slider. All of them worked properlly.

What I want to achive is that everytime I hit the button that creates a new sphere,I want my slider to control the last created sphere's radius info. Is that clear??? ( I hope so )

By the way, ı am realy new at this forum ( MEL sub forums ) If I am doing wrong something about asking, please warn me...

Here is What ı have done so far;


//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------

/*Stupid newbie script*/
//-----------------------------------
//1.Usual window stuff
//-----------------------------------

if(`window -exists windowUI`)
deleteUI windowUI;

//------------------------------------------
//2.Create a window...
//------------------------------------------

window
-title "SphereControler"
-mxb off
-wh 500 100
-sizeable off windowUI;

columnLayout
-adjustableColumn on;

button
-label "Sphere"
-command "polySphere";

attrFieldSliderGrp
-attribute "polySphere1.radius"
-fieldMinValue -10
-fieldMaxValue 10 ;

showWindow windowUI;


//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------

This one is only works when a polysphere is allready in the scene.. I tried so many things but I have not been able to fix this problem so far.. I am sure that it is pretty easy..

I hope you are not kidding me. .... :)

You can also suggest me everything you want!

See, you soon;

Ozioz

ozioz
05-06-2007, 02:39 AM
Anybody there??

....That was just a basic question... (I think so....)

sparaig
05-06-2007, 07:59 PM
Hi Guys;
[...]---------------------------------------------------------------------

This one is only works when a polysphere is allready in the scene.. I tried so many things but I have not been able to fix this problem so far.. I am sure that it is pretty easy..

I hope you are not kidding me. .... :)

You can also suggest me everything you want!

See, you soon;

Ozioz

It should be possible to choose the most recent by looking at the list of all such spheres and chose either the first or the last (not sure the order they are listed) in the list and control that one. That assumes they are retrieved in creation-order of some kind, of course. If you can't use that strategy, you'll have to create your own script to make a sphere and always use it. In THAT script, update a global variable with the sphere you just created. Have the slider control control the sphere in the global variable.

Luddy
05-07-2007, 09:41 AM
if(`window -exists windowUI`)
deleteUI windowUI;

window -title "SphereControler" -mxb off -wh 500 100 -sizeable off windowUI;

columnLayout -adjustableColumn on deleteThis;

button -l "Create Sphere" -c makeSphere;

global proc makeSphere()
{
polySphere;
string $selectedObj[] = `ls -sl`;
string $sI[] = `listHistory $selectedObj`;
deleteUI -lay deleteThis;
columnLayout deleteThis;
button -l "Create Sphere" -c makeSphere;
attrFieldSliderGrp -min -10 -max 10 -attribute ($sI[1] + ".radius");
}

showWindow windowUI;




Not sure if there's a better way. The button now creates the polysphere, finds the sphere's input node with the radius, deletes the layout and recreates the layout with a new button and slider for the last created sphere. Hope that helps.

ozioz
05-07-2007, 12:11 PM
Yes man . That is exactly What I am looking for. As I mentioned before, it is a simple command but my purpose is understanding the logic of MEL rather than creating usefull scripts.

I am inventing the script you sent me.. If I cannot figure out what the commands are, I am gonno ask you guys again...

Se you soon.

Ozioz..

Edit: OK.. Here I am again. I took a look at the script. İt is perfect. But When it appears on the screen first, there is no slider that will control the radius of the sphere which is created by the button on the window. I wanna achive this effects.

Hope You can help me on this stuff..

Have nice scripting!!

Ozioz

CGTalk Moderation
05-07-2007, 12:11 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.