Home Technical Talk

FBcombine MELscript

polycounter lvl 17
Offline / Send Message
Funky Bunnies polycounter lvl 17
I know this is tiny :P, but tacit math reminded me that I've always hated the default behavior of maya's polygonal combine tool, so I wrote this script to have more options - specifically for the pivots. Maybe some of you guys will find it useful :)

grab it here: FBcombine.mel
just drop it in mydocuments/maya/X.X/scripts and type FBcombine in the commandline like always. It'll pop up to a FBtools menu that you can disable if you want.

here's a screen of the options I have so far:
FBcombine.jpg

Delete history deletes history afterward, duh

Toggle behavior will set up a toggle so that it will run FBcombine if multiple objects are selected, but a modified polySeparate if only one object is selected

Position:
  • retain - will keep pivot position of first selected object
  • zero - will set pivot to origin (like default maya)
  • center - will center pivot
Rotation:
  • retain - will keep pivot rotation from first selected object
  • zero - will zero rotation (like default maya)
Parent:
  • retain - will keep original parent of first selected object
  • ignore - will ignore original parent (like default maya)

sorry if it has any errors, i haven't noticed any but let me know if you do find anything or want something else added :poly122:

Replies

  • MoP
    Offline / Send Message
    MoP polycounter lvl 18
    Haha, this is exactly the same as something I wrote for work, because as you said, the default Combine behaviour is just stupid and annoying for the vast majority of everyday uses.
    Mine doesn't have fancy options like yours though, I just always assumes that you want to preserve the final object's pivot/rotation/position etc., and also always deletes history and empty groups.

    Nice work! It'll be a good timesaver for sure ;)

    The next thing on the list is a proper Align tool, more like Max's, with all the options and useful functions in one easy options window, instead of having about 10 different tools all scattered at random around the Maya interface.
  • Funky Bunnies
    Offline / Send Message
    Funky Bunnies polycounter lvl 17
    haha thanks MoP
    and I hear that with the align tools, man!
  • solar
    Offline / Send Message
    solar polycounter lvl 18
    Nice FB! an align tool would be ace, for me a simple 1 click align translations and rotations would be perfect.
  • Rob Galanakis
    MoP wrote: »
    Haha, this is exactly the same as something I wrote for work, because as you said, the default Combine behaviour is just stupid and annoying for the vast majority of everyday uses.
    Mine doesn't have fancy options like yours though, I just always assumes that you want to preserve the final object's pivot/rotation/position etc., and also always deletes history and empty groups.

    Nice work! It'll be a good timesaver for sure ;)

    The next thing on the list is a proper Align tool, more like Max's, with all the options and useful functions in one easy options window, instead of having about 10 different tools all scattered at random around the Maya interface.

    I can do the math if you do the MEL and we can release it on TAO.
  • tacit math
    Offline / Send Message
    tacit math polycounter lvl 17
    the script rules Bunnies. much thanks
  • MoP
    Offline / Send Message
    MoP polycounter lvl 18
    I can do the math if you do the MEL and we can release it on TAO.

    You're on! I like writing UIs and MEL stuff, and I'm not too good at the maths stuff yet ;)
  • Rob Galanakis
    MoP wrote: »
    You're on! I like writing UIs and MEL stuff, and I'm not too good at the maths stuff yet ;)

    Contact me via MSN, we can knock it out in a couple hours. Some of the rotation stuff can be tricky (not sure I'll get it on the first pass).
  • tacit math
    Offline / Send Message
    tacit math polycounter lvl 17
    cool to see you guys hooking up on this. let us know how you get on
  • Funky Bunnies
    Offline / Send Message
    Funky Bunnies polycounter lvl 17
    why wouldn't you guys just apply/delete constraints to find the position/rotation etc.?

    if you're afraid of hijacking the animation you could just constrain a locator and store those transformations?
    is there another problem that could create?
  • claydough
    Offline / Send Message
    claydough polycounter lvl 10
    Do it Funky B! I iz to lazy :poly142:
    jez copy paste the code.

    hacking a maya command( constraints ) solution is almost always faster than mel math ( time to learn py ).
    Aligning objects is not expensive but if u extend to components interpreted mel math may be slow.
  • Funky Bunnies
    Offline / Send Message
    Funky Bunnies polycounter lvl 17
    ahh I decided to make a really simple one that just snaps to the position and rotation of the last selected object

    you can set it up to a hotkey or something until MoP+Rob finish a more fleshed out one

    [edit: alright I'll just post the code with wonky formatting. It's pretty simple anyway]


    {
    //snaps to last selected object

    //store selected transforms
    string $selection[] = `ls -sl -l -tr`;
    int $lastIndex = (`size $selection`-1);

    //create a locator to parent constrain
    string $pivLocator[] = `spaceLocator -p 0 0 0 -n pivLocator`;
    string $constraintTemp[] = `parentConstraint -weight 1 $selection[$lastIndex] $pivLocator[0]`;
    float $initPos[] = `xform -q -ws -rp $pivLocator[0]`;
    float $initRot[] = `xform -q -a -ro $pivLocator[0]`;

    delete -constraints $constraintTemp[0];
    delete $pivLocator;

    //reapply selection of just the things I care about
    select -r $selection;
    select -d $selection[$lastIndex];

    //move them foos
    move -a -ws -xyz $initPos[0] $initPos[1] $initPos[2];
    //rotate them foos
    rotate -a -ws -xyz $initRot[0] $initRot[1] $initRot[2];



    if (`size $selection`>1)
    warning ( (`size $selection`-1) + " objects snapped to last selected object");
    }
Sign In or Register to comment.