MEL BSc2 library
Contents
Introduction
This is the documentation for lib_bsc2.mel, a library with MEL functions provided for the MEL workshop in Bachelor 2. The library can be downloaded at [downloads BSc2].
rebuildCurveZeroToOne
rebuildCurveZeroToOne ( $object );
Synopsis
This function rebuilds a given curve to a zero to one (0-1) parameter range.
Examples
rebuildCurveZeroToOne ("curve1");
parameterDivision
parameterDivision ( $numspans );
Synopsis
This function returns an array of number between 0 and 1, dividing that range in numspans. It can be used to specify points on a curve by their parameter range value, provided that the curve has a 0-1 parameter range.
Examples
parameterDivision(5); // Result: 0 0.2 0.4 0.6 0.8 1 //
parameterDivision(7); // Result: 0 0.142857 0.285714 0.428571 0.571429 0.714286 0.857143 1 //
// given a curve "curve1" // rebuild it to a 0-1 parameter range rebuildCurveZeroToOne ("curve1"); // get world positions of 8 points distributed along that curve // get 8 parameter values between 0-1 float $parameters[] = parameterDivision(7); float $current_parameter; float $world_pos[]; //position is returned as an float array, holding X Y and Z for ( $current_parameter in $parameters ) { $world_pos = pointOnCurve -position -pr $current_parameter "curve1"; print ( "point on curve1 at X " + $world_pos[0] + "\n"); print ( "point on curve1 at Y " + $world_pos[1] + "\n"); print ( "point on curve1 at Z " + $world_pos[2] + "\n"); }
halfwayParameterDivision
halfwayParameterDivision ( $numspans );
Synopsis
This function returns an array of number between 0 and 1. It's aim is to be used to provide the parameter values for points on a curve. It's similar to parameterDivision(), but this function returns the values of points that are exactly in between.
It can be used to construct trusses for example.
Examples
halfwayParameterDivision(5); // Result: 0.1 0.3 0.5 0.7 0.9 // // compared to: parameterDivision(5); // Result: 0 0.2 0.4 0.6 0.8 1 //
tubeExtrude
tubeExtrude( $profile, $path );
Synopsis
This function performs a tube extrude of the curve $profile along curve $path. It saves you to bother with all the necessary flags.
Examples
tubeExtrude ( "curve1", "curve2");
extrudeTube
extrudeTube( string $path, float $mainTubeSize);
Synopsis
This function performs a tube extrude, automatically creating a circular tube with the specified size.
Examples
extrudeTube( "curve1", 2.4 );
parameterYRotation
parameterYRotation( string $curve, float $parameter );
Synopsis
Calculates the rotation around the Y-axis that is needed to rotate an object to align it with the given curve on a point specified by it's parameter value.
Examples
float $parameter = 0.25; // set the parameter // create a polygon cube. The name is returned in a string array string $object[] = `polyCube -w 1 -h 4 -d 1`; // create a curve. The name is returned in a string string $curve = `curve -d 3 -p -5.92437 0 4.831933 -p -4.754902 0 2.107843 -p -2.415966 0 -3.340336 -p 5.04902 0 -3.998599 -p 8.781513 0 -4.327731`; // get the rotation float $rotation = parameterYRotation($curve, $parameter ); // get the position float $pos[] = `pointOnCurve -position -pr $parameter $curve`; rotate 0 $rotation 0 $object[0]; move -a $pos[0] $pos[1] $pos[2] $object[0];
getObjectsByName
getObjectsByName ( $name );
Synopsis
Returns a string array with all objects which name starts with the specified string.
Examples
string $columns = getObjectsByName ( "column" );
getSelectedObjects
getSelectedObjects ();
Synopsis
Returns a string array with all selected objects.
getSelectedCurves
getSelectedCurves ();
Synopsis
Returns an array with the names of all selected nurbsCurves.
isNurbsCurve
isNurbsCurve ( $object );
Synopsis
Returns 1 (int) if the specified object is a nurbsCurve. Otherwise 0 is returned.