Create Planes Around Another Selected Cube Help

Can someone point me the direction to create a mel script, that would allow me to get the selection objects ( mostly cubes ), and create a 4 new planes around each selected object.
Also, is it possible to know if the created planes are aligned to the Z or X axis ( because I need to set some attributes based on that ) ?

Thank you very much for any help.

Anyone? Any ideas?

i would start by finding the bounding box of your object, then creating a new poly plane at the midpoint of each side of the bounding box.
then its just a matter of rotating each plane so it aligns along the correct axis.

QUOTE(rgkovach @ 04/14/09, 09:09 AM) [snapback]305734[/snapback]
i would start by finding the bounding box of your object, then creating a new poly plane at the midpoint of each side of the bounding box.
then its just a matter of rotating each plane so it aligns along the correct axis.

You can actually specify the facing direction of the plane when you create it. That'll save you a step of having to rotate and freeze things then too. Should be the -axis flag.

QUOTE(molemansd7 @ 04/14/09, 03:14 PM) [snapback]305739[/snapback]
You can actually specify the facing direction of the plane when you create it. That'll save you a step of having to rotate and freeze things then too. Should be the -axis flag.

Well, so far I can only get the objects boundingbox. I have no idea of how to make a new poly plane and to set its positions. Can you show me some example to do that? I am still a newbie with mel scripting.

thank you very much.

If you open the MEL command reference from the Help menu in Maya, search for polyPlane.
it will give some examples.

Thanks, one less thing. I can make the planes now.

But I still need to know their positions. So, how do I found out how to make the plane around each side of a cube?

Ok. This is what I have and I think that it is working.

CODE
string $sel[] = ls -sl -tr;
for ($obj in $sel) {
    float $bbnx = getAttr ($obj + ".bbnx" ); $bbnx = floor $bbnx;
    float $bbny = getAttr ($obj + ".bbny" ); $bbny = floor $bbny;
    float $bbnz = getAttr ($obj + ".bbnz" ); $bbnz = floor $bbnz;

    float $bbxx = getAttr ($obj + ".bbxx"); $bbxx = floor $bbxx;
    float $bbxy = getAttr ($obj + ".bbxy"); $bbxy = floor $bbxy;
    float $bbxz = getAttr ($obj + ".bbxz"); $bbxz = floor $bbxz;

polyCreateFacet -p $bbnx $bbny $bbnz -p $bbxx $bbny $bbnz
                -p $bbxx $bbxy $bbnz -p $bbnx $bbxy $bbnz;

polyCreateFacet -p $bbnx $bbny $bbxz -p $bbnx $bbxy $bbxz
          -p $bbxx $bbxy $bbxz  -p $bbxx $bbny $bbxz;

polyCreateFacet -p $bbxx $bbxy $bbxz -p $bbxx $bbxy $bbnz
          -p $bbxx $bbny $bbnz -p $bbxx $bbny $bbxz;

polyCreateFacet -p $bbnx $bbxy $bbxz -p $bbnx $bbxy $bbnz
          -p $bbnx $bbny $bbnz -p $bbnx $bbny $bbxz;

}

Theres actually a easier way to do this, what you do is a strategic split and polycipoff on a duplicate obejct if you must. Thisway even if you cube was slanted it would work

QUOTE(Joojaa @ 04/15/09, 10:12 AM) [snapback]305818[/snapback]
Theres actually a easier way to do this, what you do is a strategic split and polycipoff on a duplicate obejct if you must. Thisway even if you cube was slanted it would work

Well, I thought about that, but this is for my collision system and right now, it only works with Axis aligned planes. So, for now, this won't do it for me. But hey it is working now.

So thank you.

QUOTE(alexmbra @ 04/15/09, 08:51 AM) [snapback]305812[/snapback]
Ok. This is what I have and I think that it is working.

CODE
string $sel[] = ls -sl -tr;
for ($obj in $sel) {
    float $bbnx = getAttr ($obj + ".bbnx" ); $bbnx = floor $bbnx;
    float $bbny = getAttr ($obj + ".bbny" ); $bbny = floor $bbny;
    float $bbnz = getAttr ($obj + ".bbnz" ); $bbnz = floor $bbnz;

    float $bbxx = getAttr ($obj + ".bbxx"); $bbxx = floor $bbxx;
    float $bbxy = getAttr ($obj + ".bbxy"); $bbxy = floor $bbxy;
    float $bbxz = getAttr ($obj + ".bbxz"); $bbxz = floor $bbxz;

polyCreateFacet -p $bbnx $bbny $bbnz -p $bbxx $bbny $bbnz
                -p $bbxx $bbxy $bbnz -p $bbnx $bbxy $bbnz;

polyCreateFacet -p $bbnx $bbny $bbxz -p $bbnx $bbxy $bbxz
          -p $bbxx $bbxy $bbxz  -p $bbxx $bbny $bbxz;

polyCreateFacet -p $bbxx $bbxy $bbxz -p $bbxx $bbxy $bbnz
          -p $bbxx $bbny $bbnz -p $bbxx $bbny $bbxz;

polyCreateFacet -p $bbnx $bbxy $bbxz -p $bbnx $bbxy $bbnz
          -p $bbnx $bbny $bbnz -p $bbnx $bbny $bbxz;

}

All that work and face is not working right with my collision system. So, does anyone knows how can I change this to create cubes instead of planes ?