Skip to content

Instantly share code, notes, and snippets.

@SEVEZ
Created May 5, 2016 12:10
Show Gist options
  • Save SEVEZ/124aac0297736601cc5bb9fce423de2b to your computer and use it in GitHub Desktop.
Save SEVEZ/124aac0297736601cc5bb9fce423de2b to your computer and use it in GitHub Desktop.
Apply scale expression to selected objects. They will scale up as locator1 approximates them.
$sel = `ls -sl`;
for ( $s in $sel )
{
$s = $s;
$loc = "locator1";
$constr = "$dx = " + $loc + ".tx - " + $s + ".tx; $dy = " + $loc + ".ty - " + $s + ".ty; $dz = " + $loc + ".tz - " + $s + ".tz; $vlen = sqrt( $dx * $dx + $dy * $dy + $dz * $dz ); if ( $vlen > 5 ) " + $s + ".scaleX = 1; else " + $s + ".scaleX = ( cos( ( $vlen - 1 ) / 5 * 3.141592 ) + 1 ) / 2 * 0.35 + 1;";
expression -s $constr -o $s -ae 1 -uc all ;
$constr = "$dx = " + $loc + ".tx - " + $s + ".tx; $dy = " + $loc + ".ty - " + $s + ".ty; $dz = " + $loc + ".tz - " + $s + ".tz; $vlen = sqrt( $dx * $dx + $dy * $dy + $dz * $dz ); if ( $vlen > 5 ) " + $s + ".scaleY = 1; else " + $s + ".scaleY = ( cos( ( $vlen - 1 ) / 5 * 3.141592 ) + 1 ) / 2 * 0.35 + 1;";
expression -s $constr -o $s -ae 1 -uc all ;
$constr = "$dx = " + $loc + ".tx - " + $s + ".tx; $dy = " + $loc + ".ty - " + $s + ".ty; $dz = " + $loc + ".tz - " + $s + ".tz; $vlen = sqrt( $dx * $dx + $dy * $dy + $dz * $dz ); if ( $vlen > 5 ) " + $s + ".scaleZ = 1; else " + $s + ".scaleZ = ( cos( ( $vlen - 1 ) / 5 * 3.141592 ) + 1 ) / 2 * 0.35 + 1;";
expression -s $constr -o $s -ae 1 -uc all ;
}
@SEVEZ
Copy link
Author

SEVEZ commented May 5, 2016

Also apply visibility expression. Objects will become visible only near the locator1

$sel = `ls -sl`;
for ( $s in $sel  )
{
    $s = $s;
    $loc = "locator1";
    $constr = "$dx = " + $loc + ".tx - " + $s + ".tx; $dy = " + $loc + ".ty - " + $s + ".ty; $dz = " + $loc + ".tz - " + $s + ".tz; $vlen = sqrt( $dx * $dx + $dy * $dy + $dz * $dz );  " + $s + ".visibility = ( $vlen < 1.5 );"; 
    expression -s $constr -o $s -ae 1 -uc all ;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment