Form and Space

creating CG 3D since 2001

  • Connect @
  • Linked in
  • Vimeo
  • Twitter

Pivot to Point and Object to Point

Matthew | May 13, 2014

No Comments

Here’s a couple of small scripts created for a student interested in moving the pivot point to a selected vertex.

global proc mls_pivotToVertex()
{
    string $object[] = `ls -hl`;
    string $component[] = `ls -sl`;
    int $amount = size($component);
    
    if($amount != 1)
    {    
        error "Select only one vertex.";       
    }
    
    vector $v = `xform -q -ws -t $component[0]`;
    xform -ws -piv ($v.x) ($v.y) ($v.z) $object[0];
}

The second script is a variation of the former script. It allows you to created an object at selected vertices. I recommend using the Replace Add Randomize tool to swap out the cubes with the object of your choice.

global proc mls_objectToVertex()
{
    string $object[] = `ls -hl`;
    int $amount[] = `polyEvaluate -vc $object`;
    string $vertices[] = `filterExpand -sm 31`;
    
    for($i=0; $i<$amount[0]; $i++)
    {
        string $obj[] = `polyCube`;
        vector $v = `xform -q -ws -t $vertices[$i]`;
        
        xform -ws -t ($v.x) ($v.y) ($v.z) $obj[0];
   
    }
}

Leave a Reply

Twitter

Subscribers

    396