problem with global string


#1

Hello
I have this two funtion. i want the second function can read some string from the first bu every time i have two error start by " No match for …". the problem is that the script can’t read the two string $skinClusterOne and $getName from the first proc and use it in the second one.


global proc PickObject()
{
string $selObject[] = `ls -sl`;
textField -e -tx $selObject[0] SelectedObject;
global string $getName;
$getName = `textField -q -tx $selObject[0] pCube1`;
string $skinCluster;
string $history[] = `listHistory $selObject[0]`;
for($historyNode in $history)
if(`nodeType $historyNode` == "skinCluster")
$skinCluster = $historyNode;
global string $skinClusterOne;
$skinClusterOne = $skinCluster;
//print $skinCluster;

}

global proc BindItMan ()
{
global string $skinClusterOne;
global string $getName;
    //Get Joint Name
string $JointName[]=`ls -sl`;
//string $getValue = `textField -q -text SelectedJoint`;
//Set vertex Vlue
skinPercent -tv $JointName[0] 1 $skinClusterOne $getName.vtx[8:11];
}

Any help please


#2

In theory the global variables should work because this works fine:

global proc PickObject()
{
    global string $getName;
    $getName = "Hello";
    global string $skinClusterOne;
    $skinClusterOne = "someOtherValue";
}

global proc BindItMan ()
{
    global string $skinClusterOne;
    global string $getName;
    
    print("getName:" + $getName + "
");
    print("skinClusterOne:" + $skinClusterOne + "
");
}

PickObject();
BindItMan();

So I suppose the problem is something else and it would help to see the whole script and the whole error message because the interesting part comes directly after the “No match for…”.


#3

Hello Haggi
So this is the whole script



string $window = `window  -title "windowTitle" "mainWindow"`;
string $form = `formLayout -numberOfDivisions 100`;



global proc PickObject()
{
string $selObject[] = `ls -sl`;
textField -e -tx $selObject[0] SelectedObject;
// Get Name of selected Object
global string $getName;
$getName = `textField -q -tx SelectedObject`;

// Get skinCluster Name
string $skinCluster;
string $history[] = `listHistory $selObject[0]`;
for($historyNode in $history)
if(`nodeType $historyNode` == "skinCluster")
$skinCluster = $historyNode;
global string $skinClusterOne;
$skinClusterOne = $skinCluster;

}

global proc BindItMan ()
{
global string $skinClusterOne;
global string $getName;
string $JointName[]=`ls -sl`;
skinPercent -tv $JointName[0] 1 $skinClusterOne $getName.vtx[8:11];
}



// Creating Element PickObject
string $object = `button -command "PickObject" -label "Pick Selected Object" -w 68 -h 34`;
formLayout -edit -attachForm $object "top" 27 -attachForm $object "left" 12 $form;
//=========================================
// Creating Element Bind_It
string $object = `button -command "BindItMan" -label "Bind It" -w 68 -h 34`;
formLayout -edit -attachForm $object "top" 77 -attachForm $object "left" 10 $form;
//=========================================
// Creating Element ObjectName
string $object = `textField -editable false -w 214 -h 34 SelectedObject`;
formLayout -edit -attachForm $object "top" 28 -attachForm $object "left" 88 $form;
//=========================================

setParent..;
showWindow( $window );
window -edit -widthHeight 320.0 320.0 "mainWindow";


and this is the error i have “” // Error: line 30: No object matches name: .vtx[8:11] // “” and this is the line 30 “” skinPercent -tv $JointName[0] 1 $skinClusterOne $getName.vtx[8:11]; “”


#4

Oh yes. This expression:

skinPercent -tv $JointName[0] 1 $skinClusterOne $getName.vtx[8:11];

Does not work because maya tries to find an object called “$getName.vtx[8:11]”. It cannot simply expand variables here. You will have to build a string from the varibles:


skinPercent -tv $JointName[0] 1 $skinClusterOne ($getName + ".vtx[8:11]");


#5

Thank you so much haggi. works fine now. i have now one last thing i shoul see how can i do it. as you see in this script i shoul each time enter manually the range number of selected vertex as mention here for exemple vtx[8:11]. i want that the script read the vertex i selected automatically


#6

Hmm… if you select vertices, the “ls -sl” command should return the selcted verictes as well.


#7

I have this idea
I add my selected vertex to a scroll list and now its just to figure out how can i call it to the famous Line 30 :slight_smile:


global proc AddToVertexList()
{
    
	string $SmartName [] = `ls -sl`;
	for ($Smart in $SmartName )
    {    
	textScrollList -e -a $Smart VertexList;
    }
    
	
}



#8

In theory this should work if you query all items:

string $items[] = `textScrollList -q -ai scrollListObject`;

and use the $items as argument

skinPercent -tv $JointName[0] 1 $skinClusterOne $items;

But I have on idea how the skinPercent command works.


#9

Thank you so much Haggi. works very well now.