Home Technical Talk

Maya -Xgen MEL - expressions ?

polycounter lvl 6
Offline / Send Message
barmyg polycounter lvl 6
Hello pollycounters .

I have been working on a maya scene specially on Xgen .
and i have a " rand() " expression that i put in my clumping modifier .

The problem is it has a range from (3,7) and i want to combine it with another " rand() " exp. but 
with a negative value (-3,-7) .

But when i do that the " compiler " if i may say , produces range from (-7,-6,-5,-4
,-3,-2,-1,0,1,2,3,4,5,6,7) .

*** and i don't want that mid value from (-2,2) .

I could only find 2 solutions for this problem :

1- an expression that gives a certain values that Xgen only should work with(not a range ) 
like if i write :
$a=(-7,-6,-5,-4,-3,3,4,5,6,7);
only use these values ($a)

2-Excluding a certain amount or a range :

$a=(-7,7);
$b=(-3,3);
$a-$b


although they both didn't work ( i think of my poor expression writing ),
both resulting from the range -7:7 but i hope i sent my idea across .

Help guys and thanks in advance .


Replies

  • Klaudio2U
    Options
    Offline / Send Message
    Klaudio2U polycounter lvl 8
    Not entirely sure how exactly is with expressions but perhaps you can try with a little workaround where you can first run " rand(-8, 8) " which will give you some number between -7 and 7 which then you can check with "if-else" if it is what you want. 
    So maybe like this with expression, you can check it and if the random number is -2, -1, 0, 1, 2 it will simply skip it.

    For example, if you run this MEL script: 
    // get random value between -8 and 8 and store is as Int which will give random between -7 and 7 actually
    int $rands = rand(-8, 8);

    // check if $rands <= -3  (if the number is -7, -6, -5, -4, -3)
    // OR, which is the meaning of "||" sign
    // if $rands >= 3  ( if the number is 3, 4, 5, 6, 7)
    // If true do something ( print it), else skip it. 
    if  (($rands <= -3) || ($rands >= 3))
        print $rands;



    If that helps. Again, not sure how it exactly goes with expressions and if you can use exactly the same thing.
  • barmyg
    Options
    Offline / Send Message
    barmyg polycounter lvl 6
    Klaudio2U said:
    Not entirely sure how exactly is with expressions but perhaps you can try with a little workaround where you can first run " rand(-8, 8) " which will give you some number between -7 and 7 which then you can check with "if-else" if it is what you want. 
    So maybe like this with expression, you can check it and if the random number is -2, -1, 0, 1, 2 it will simply skip it.

    For example, if you run this MEL script: 
    // get random value between -8 and 8 and store is as Int which will give random between -7 and 7 actually
    int $rands = rand(-8, 8);

    // check if $rands <= -3  (if the number is -7, -6, -5, -4, -3)
    // OR, which is the meaning of "||" sign
    // if $rands >= 3  ( if the number is 3, 4, 5, 6, 7)
    // If true do something ( print it), else skip it. 
    if  (($rands <= -3) || ($rands >= 3))
        print $rands;



    If that helps. Again, not sure how it exactly goes with expressions and if you can use exactly the same thing.
    this is very close to what i am looking for , i will try to find a work around in Xgen because it doesn't have the " int " nor the " if " commands .
    thanks alot man .
Sign In or Register to comment.