Home » Support » 3D Applications » Maya - custom scripts - more maya users?
Search Search  
Show: Today's Messages    Show Polls    Message Navigator
Maya - custom scripts - more maya users? [message #75469] Wed, 25 September 2013 15:14 UTC
avatar vileraisin  is currently offline vileraisin
Messages: 14
Registered: September 2013
Go to my shop
Junior Member
Hello,

I'm not sure how many Maya users are out there, but if there are any I figured it might be useful to exchange any custom scripts etc. people use specifically for 3D printing / Shapeways. Perhaps this could turn out into a nice collection thread.

Anyone have any custom scripts or workflow that is invaluable to the process?

I don't have much myself, but I'll start, perhaps this will be to use to someone.

I have a command on my shelf that finds all open border edges on a mesh, using selection constraint:
(select a mesh and then run this command)
polySelectConstraint -mode 3 -type 0x8000 -where 1;
resetPolySelectConstraint;


Also found another script to measure the distance between 2 nodes/vertices:
(select two nodes / vertices and run getDistance()Wink
// from: http://www.montu.biz/2010/03/measure-distance.html
// select 2 nodes / vertices, run getDistance()

global proc getDistance(){
    string $currentsel[] = `ls -sl -fl`;
    if ($currentsel[0] == "") error "You must select two nodes or vertex to measure the distance";
    else {
        int $numofvertex = size($currentsel);
        if($numofvertex > 2) error "More than 2 nodes selected. Make selection again with only two nodes to measure distance between them";
        else {
            if(`objectType -isType "mesh" $currentsel[0]` || `objectType -isType "nurbsCurve" $currentsel[0]`) {
    
                vector $va = `pointPosition $currentsel[0]`;
                vector $vb = `pointPosition $currentsel[1]`;
                vector $distpos = $va - $vb;
                float $d = `mag <<$distpos.x, $distpos.y, $distpos.z>>`;
                string $unit= `currentUnit -query -linear`;
                print ($d + " " + $unit + "\r");
    
            }
            else if (`objectType -isType "transform" $currentsel[0]`) {
    
                vector $va = `xform -q -ws -a -rp $currentsel[0]`;
                vector $vb = `xform -q -ws -a -rp $currentsel[1]`;
                vector $distpos = $va - $vb;
                float $d = `mag <<$distpos.x, $distpos.y, $distpos.z>>`;
                string $unit= `currentUnit -query -linear`;
                print ($d + " " + $unit + "\r");
    
            }
    
        }
    }
};


Measure the volume of a mesh:
computePolysetVolume;


Also because I like to make full use of the grid, I have 1 command that centers the pivot to absolute 0,0,0 (center of the scene), and another to move the mesh to absolute 0,0,0

Move pivot to center of the scene:
xform -a -ws -piv 0 0 0;


Move mesh to center of the scene:
proc moveToZero(int $option)
{
string $selObj[] = `ls -sl`;
for($obj in $selObj)
{
    float $startingCoord[] = `xform -q -ws -rp $obj`;
    float $xOffset = $startingCoord[0] * -1;
    float $yOffset = $startingCoord[1] * -1;
    float $zOffset = $startingCoord[2] * -1;

move -rpr -x ($startingCoord[0] + $xOffset) -y ($startingCoord[1] + $yOffset) -z ($startingCoord[2] + $zOffset) $obj;
    
    if($option == 1)
    {
        makeIdentity -apply 1 -t 1 $obj;
        move -rpr $startingCoord[0] $startingCoord[1] $startingCoord[2] $obj;
    }
}

}

moveToZero(0);



Anyone else?

 
   
Previous Topic:making hollow
Next Topic:Model showing black on upload

Logo

Hello.

We're sorry to inform you that we no longer support this browser and can't confirm that everything will work as expected. For the best Shapeways experience, please use one of the following browsers:

Click anywhere outside this window to continue.