returning the names of smoothNodes

Become a member of the CGSociety

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

THREAD CLOSED
 
Thread Tools Display Modes
  12 December 2003
returning the names of smoothNodes

In the script I'm writing there is a polySmooth node created and I was wondering if there was a way to catch the name of the node as it's created so I can control it later.


if ($type == "transform") {
           polySmooth  -mth 0 -dv 2 -c 1 -kb 0 -ksb 1 -khe 0 -kt 1 -kmb 1 -suv 1 -sl 1 -dpe 1 -ps 0.1 -ro 1 -ch 1 $obj;
           select -cl;
}
__________________

 
  12 December 2003
why doesn't the -name flag on the create polySmooth node seem to do anything?
__________________

 
  12 December 2003
hi,
I don't know why -n doesn't work but,
string $nnn[] = `polySmooth....`;
should catch the name of the new node(s).
 
  12 December 2003
Hey thanks for your reply! I'm almost there but I'm not sure why it's not quite working. Maybe anyone out there could just take a quick look and eyeball what going wrong here. Here's the section of code that I'm having a fit with:


string $obj[] = `ls -sl`;
string $winName = "smoothUndo";

if ($obj[0] != "") {
	string $type = `objectType $obj`;	
	if ($type == "transform") {
		string $smoothNode[] = `polySmooth -mth 0 -dv 2 -c 1 -kb 0 -ksb 1 -khe 0 -kt 1 -kmb 1 -suv 1 -sl 1 -dpe 1 -ps 0.1 -ro 1 -ch 1`;
		select -cl;

		//create the undo window
		if ( `window -exists $winName `) {
			deleteUI $winName;
			}
		window -menuBar true -t "" $winName;
		columnLayout -adjustableColumn true;
		iconTextButton -style "textOnly"
			-label "Undo Smooth"
			-c ("print $smoothNode[0]; deleteUI $winName;");
		showWindow;
		print $obj" was smoothed twice over.";
	} else {
		error "Current selection doesn't match required selection type. Polygonal objects required.";
	}
} else {
	error "You must first select the geometry to smooth.";
};


The issue is that when the button is called the $smoothNode string comes back as undeclared or empty but if I put a print statement right after the smooth command it prints it fine. It's like I'm losing the variable somehow. Any Ideas?? Thanks All!

Scott
__________________

 
  12 December 2003
Hi,

Check the mel user guide 'variables and constants->variables' section for an understanding of global and local variables. In this case you need to use a global variable because by the time the button is actually pushed, $smoothNode[] no longer exists.
 
  12 December 2003
I will do this for sure and I thank you, but at what point or why does the $smoothNode die? Also when it's turned to a global string it alerts me that a global string must be a constant. If I'm dynamically aquiring this string then it will never be a constant, correct?
__________________


Last edited by Scott212 : 12 December 2003 at 02:54 AM.
 
  12 December 2003
Hi,

It's lifetime or 'scope' is local to the block it's declared in.

string $winName=...; // this is outside any blocks which is global

if ($type == "transform") {

string $smoothNode[] = ...; // this is local which is only valid for the encasing {} brackets

}

// $winName is still good
// $smoothNode[] is no longer valid.

The code assigned to the button is only defined within your script. When the button is pressed, the code is executed in the context of a seperate script containing only this,

{
print $smoothNode[0];
deleteUI $winName;
}

If you change your script to

string $smoothNode[];
string $winName = ...;
string $obj=...;
{
$smoothNode = `polySmooth...`;
}

you should be ok as far as your variables are concerned, and hopefully this makes more sense.
 
  12 December 2003
Thanks for all of your help sbp, I got it finished and working. It's a simple polySmooth checker if you don't want to use a proxy or subd.

Feel free to put it on your shelf


// Simple PolySmooth Checker v1.0
// ANY questions or comments send to wokontheotion@hotmail.com
// Scott Willman 2003

string $obj[] = `ls -sl`;
string $smoothNode[];
string $winName = "smoothUndo";
string $smoothCommand = ($smoothNode[0] + ".divisions");
print $smoothNode[0];

if ($obj[0] != "") {
	string $type = `objectType $obj`;
	if ($type == "transform") {
		//create the undo window
		if ( `window -exists $winName `) {
			deleteUI $winName;
			}
		window -t "" $winName;
		columnLayout -adjustableColumn true;
		$smoothNode = `polySmooth -mth 0 -dv 2 -c 1 -kb 0 -ksb 1 -khe 0 -kt 1 -kmb 1 -suv 1 -sl 1 -dpe 1 -ps 0.1 -ro 1 -ch 1`;
		print $smoothNode[0];
		select -cl;

		iconTextButton -style "textOnly"
			-label "Undo Smooth"
			-c ("print $smoothNode[0]; setAttr ($smoothNode[0] + \".divisions\") 0; deleteUI $winName; select $obj[0];");
		showWindow;
		print $obj" was smoothed twice over.";
	} else {
		error "Current selection doesn't match required selection type. Polygonal objects required.";
	}
} else {
	error "You must first select the geometry to smooth.";
};
Attached Files
File Type: zip polysmooth.zip (2.1 KB, 0 views)
__________________

 
  01 January 2006
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



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 12:00 PM.


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