PDA

View Full Version : Urgent MEL quesion...


Anchuvi
07-17-2002, 01:22 PM
I need a series of variables to go into an expression during a script being executed.

The line is something like this but I need it to start and end with the quotes ""

($shapeNode[0] + ".pnts[" + $vertNumber[$currVertNum] + "].pntz")

This is part of the line but I have no idea where I insert the "\" to make it work...

Can someone help and even explain how this is done...

i would be very grateful...

svenip
07-17-2002, 01:32 PM
Originally posted by Anchuvi

($shapeNode[0] + ".pnts[" + $vertNumber[$currVertNum] + "].pntz")


don't know exactly what you wanna da :hmm: you wanna throw this into a string ? then it's this way

string $temp = "($shapeNode[0] + \".pnts[" + $vertNumber[$currVertNum] + "].pntz\")";

Anchuvi
07-17-2002, 01:37 PM
Yeh something liek that, except when I print the $temp variable it should return with the correct names from the variables...

i.e.

"($shapeNode[0] + \".pnts[" + $vertNumber[$currVertNum] + "].pntz\")";

should come out as this -

pSphere1shape.pnts[56].pntz

svenip
07-17-2002, 01:42 PM
pSphere1shape.pnts[56].pntz

string $temp = ""+$shapeNode[0] + ".pnts[" + $vertNumber[$currVertNum] + "].pntz)";


this should do it

Anchuvi
07-17-2002, 01:53 PM
Thanks...problem now is the expression won't take it...

Here is what I am trying to do -

expression -s ""+$shapeNode[0] + ".pnts[" + $vertNumber[$currVertNum] + "].pntz" + "="+$shapeNode[0] + ".pnts[" + $currentVert + "].pntz" + "/2";

The print command works fine but the expression doesn't like it...

svenip
07-17-2002, 02:02 PM
can you try this one ?

expression -s $shapeNode[0] + ".pnts[" + $vertNumber[$currVertNum] + "].pntz = "+$shapeNode[0] + ".pnts[" + $currentVert + "].pntz/2";

the only error for me here is that he doesn't know the variable shapeNode[0]

Anchuvi
07-17-2002, 02:05 PM
That didn't work either...I imagined it should look like this -

$renderCmd = ("start render -cam \"" + $renCam + "\" -of \"" + $saveType + "\" -iw \"" + $width + "\" -ih \"" + $height + "\" -eaa highest -ss 1 -mss 4 -rd \"" + $saveDir + "\" -im \"" + $saveName + "\" \"" + $filename + "\"");

I ripped this out of another script, but it demonstrates what i am after.

svenip
07-17-2002, 02:09 PM
ok we will get it :)

string $command = "expression -s \"\"+$shapeNode[0] + \".pnts[\" + $vertNumber[$currVertNum] + \"].pntz = "+$shapeNode[0] + \".pnts[\" + $currentVert + \"].pntz/2\";";

eval $command;

trial number 6 :)

Anchuvi
07-17-2002, 02:15 PM
// Error: Syntax error //

Didn't work either...:thumbsdow

svenip
07-17-2002, 02:17 PM
it should tell you where the syntax error is. can you mark the position please ?

Anchuvi
07-17-2002, 02:19 PM
This is what it spits out -


// Error: string $command = "expression -s \"\"+$shapeNode[0] + \".pnts[\" + $vertNumber[$currVertNum] + \"].pntz = "+$shapeNode[0] + \"€ //
// Error: Line 37.122: Syntax error //

svenip
07-17-2002, 02:28 PM
so it's somewhere around this

".pnts[\" + $currentVert + \"]

don't know exactly what it is for. so what is the .pnts ??? is it a maya given value for the polyShape (it is a polyShape or ?)

Anchuvi
07-17-2002, 02:32 PM
I am trying to create a script that will mimic the soft selection in Max...

The sphereShape.pts[4].pntz is the vertex that I am trying to move.

alexx
07-17-2002, 02:49 PM
sorry not much time to answer:
but as from what i have read so far one of the problems is to get the string in the form that is is accepted for an expression.

have a look in the following mel command:
encodeString

that should help some at least

cheers

alexx

svenip
07-17-2002, 03:00 PM
hmm nice mel command :) after years of thinking about quotes in strings :D someone tells me that there is a command to do this :thumbsup:

alexx
07-17-2002, 03:08 PM
DONT ask me how many times i did it by hand before i found that one.. a nearly as bad looked for command i guess is:

filterExpand

(took me days to write a script that does the same and then i found it)

;)

Anchuvi
07-17-2002, 03:46 PM
Even that doesn't seem to work...I tried the example -

string $s = print("Hello\n");
encodeString $s;

and all I got was - Hello ?

stunndman
07-17-2002, 04:34 PM
Originally posted by Anchuvi
Even that doesn't seem to work...I tried the example -

string $s = print("Hello\n");
encodeString $s;

and all I got was - Hello ?


string $s = "print(\"hello\n\")";
print("*with encode\n");
print("<" + `encodeString $s` + ">");
print("\nwithout encode\n");
print("<" + $s + ">");


the output shows the difference

*with encode:
<print(\"hello\n\")>
*without encode:
<print("hello
")>

let me add that you have to be aware that with print you won't get the actual string - because print is already interpreting all the stuff

e.g. before we encode $s in this example the string (in memory) looks like

print("hello\n")

after we encode it it will be

print(\"hello\\n\")

Anchuvi
07-18-2002, 08:32 AM
Thanks for that explanation, one thing though...appologies if I am sounding dim but I am trying to get my head around all this.

If you start off with the command encoded i.e.

print(\"hello\n\")

Why would you need to put it through encodeString?

All I really want to know is how the backslashes work in such a command that involves strings and variables...Like in this example -

$renderCmd = ("start render -cam \"" + $renCam + "\" -of \"" + $saveType + "\" -iw \"" + $width + "\" -ih \"" + $height + "\" -eaa highest -ss 1 -mss 4 -rd \"" + $saveDir + "\" -im \"" + $saveName + "\" \"" + $filename + "\"");

CGTalk Moderation
01-13-2006, 11:00 AM
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.