mayation_

Rotate on Curve

Posted in tools by A. Benjasem on November 13, 2009

I haven’t posted anything for sometime because I’m working on a new script. For now, this is a script I’ve developed a few years ago. It’s a tool to duplicate a nurbs object along a curve while rotating it. There is also the option of lofting the duplicates. Enjoy.

// RotateOnCurve.mel Rotate on Curve.
// The script rotates the object along a curve 'n' number of times with rotations.
// written by Amenah Benjasem.// https://mayation.wordpress.com
group -em -n ronc;
addAttr -ln path -dt "string";
addAttr -ln object -dt "string";
addAttr -ln Repetition -at short;
addAttr -ln xRotation -at short;addAttr -ln yRotation -at short;
addAttr -ln zRotation -at short;
if (`window -exists ronc`) {deleteUI ronc; windowPref -remove ronc;}
window -widthHeight 360 350 -s 1 -title "Rotate on Path" ronc;
columnLayout -columnAttach "right" 10 -rowSpacing 10 -columnWidth 340 columnlayout ;
attrFieldSliderGrp  -min 2 -max 100 -at ronc.Repetition ;
attrFieldSliderGrp  -min 1 -max 360 -fs 10 -at ronc.xRotation ;
attrFieldSliderGrp  -min 1 -max 360 -fs 10 -at ronc.yRotation ;
attrFieldSliderGrp  -min 1 -max 360 -fs 10 -at ronc.zRotation ;
$t_loft = `checkBox -label "Loft" -align "left"`;
setParent ..;setParent ..;
button -label "duplicate on curve" -h 30 -width 200 -command "dupl($t_loft)" dupl;
button -label "exit" -h 30 -width 200 -command "exit()" exit ;
showWindow ronc;
select -cl;
print "\n\n- - - - \nRotateOnCurve.mel:\n========\nPlace object pivot in desired place.";
print " Select 1)Path  2)object. \n amna\n";
global proc dupl(string $t_loft) {
$sel = `ls -sl`;
if (size($sel) > 0) {
$obj = `ls -selection -tail 1`;
setAttr ronc.object -type "string" $obj;
$path = `ls -selection -head 1`;
setAttr ronc.path -type "string" $path;
print ("\nPath: " + $path[0] + ", Object: " + $obj[0] + ".\n");
$knots = `getAttr ronc.Repetition`;
$knots_ = $knots - 1;
rebuildCurve -rt 0 -s $knots_ $path;
$rotx = `getAttr ronc.xRotation`;
$roty = `getAttr ronc.yRotation`;
$rotz = `getAttr ronc.zRotation`;
////duplicate move and rotate object..
 for ($i = 1; $i <= $knots; $i++) {
    $point = $path[0] + ".ep[" + $i + "]";  
     $pos = `getAttr $point`; 
     $newobj = `duplicate -n obj $obj[0] `;
     rotate -r  $rotx $roty $rotz $newobj;   
    move -rpr $pos[0] $pos[1] $pos[2] $newobj;
   $rotx = $rotx + $rotx;
   $roty = $roty + $roty;
   $rotz = $rotz + $rotz;   }
   $loft = `checkBox -q -v $t_loft`;
    string $name;
     if ($loft == 1) {
       for ($i = 0; $i<=($knots-2); $i++) {
         if ($i == 0) { $name = "obj"; }
            if ($i > 0) { $name  =  "obj" + $i;}
              $j = $i+1;
            $name2 = "obj" + $j;
            loft $name $name2;   }  
}    }else{  print "\nError: Select Path then object\n";  } }
global proc exit() {
   delete ronc;
   deleteUI ronc;  }

Wireframe render

Posted in tools by A. Benjasem on September 1, 2009

Many times while designing, I find it more interesting to look at a solid object in wireframe mode. In any 3D software the modeling is done through wireframe. When rendering the model however, it becomes solid. This tool allows you to convert any object made with Nurbs or surfaces in Maya to wireframe. You can change the number of sections or frames in every column and row. You can also change the radius of each frame.

mayation_wireframeCombo

     

global proc wireframe(int $u, float $v) {
  $obj = `ls -sl`;
  rebuildSurface -ch 1 -rpo 1 -rt 0 -end 1 -kr 0 -kcp 0 -kc 0 -su $u -du 3
                                          -sv $v -dv 3 -tol 0.01 -fr 0  -dir 2 $obj;
  int $i;
  string $curIso;
  float $inc_v;
  float $inc_u;
  float $curIsoValue;
  float $j = 0;
  $inc_v = (1.0 / $v);
  $inc_u = (1.0 / $u);
  $profile_radius = 0.05;  //change this value to change the size of the wireframe.
  $profile = `circle -ch on -o on -nr 0 1 0 -r $profile_radius ` ;
  for ($i = 0; $i <= $v; $i++) {
    $curIsoValue = ($inc_v * $j);
    $curIso = $obj[0] + ".v[" + $curIsoValue + "]";
    select -r  $curIso;
    $curve = `duplicateCurve -ch 1 -rn 0 -local 0  $curIso` ;
    extrude -ch true -rn false -po 0 -et 1 -fpt 1 -upn 0
                                  -rotation 0 -scale 1 $profile[0] $curve[0] ;
     $j = $j + 1;
   }
  $j = 0;
 for ($i = 0; $i <= $u; $i++) {
   $curIsoValue = ($inc_u * $j);
   $curIso = $obj[0] + ".u[" + $curIsoValue + "]";
   select -r  $curIso;
   $curve = `duplicateCurve -ch 1 -rn 0 -local 0  $curIso` ;
   extrude -ch true -rn false -po 0 -et 1
                            -fpt 1 -upn 0 -rotation 0 -scale 1 $profile[0] $curve[0] ;
    $j = $j + 1;
 } print "\n written by mayation.wordpress.org\n"  }
 

SolidForm solid to wireframe wireframeForm