MEL and PyMEL Reference 

Ornatrix exposes a great deal of its functionality through MEL and Python to make it very extensible and flexible during creation of tools that work alongside it. This page provides a reference for some of the useful functionality accessible through MEL.

Some MEL functions are defined through a set of MEL scripts and Attribute Editor templates which are installed with Ornatrix. These are located inside the installation's /scripts directory. For example, scripts/OxQuickHair.mel contains the OxQuickHair() command, and scripts/OxLoadPlugin.mel contains the OxLoadPlugin() command.

This page only documents globally available functions which can be used to query hair information. To see MEL functions available for specific operators or features please check the documentation pages for these features.

 

The functions 

 

Strand Shape Functions 

Most of these functions work on either HairShape or GuidesShape instance. StrandShape refers to either one of these objects and needs to be passed in as the first argument.

// Gets the number of strands in a shape
int OxGetStrandCount( string $strandShape );

// Returns the number of vertices defining the strand shape
int OxGetVertexCount( string $strandShape );

// Determines whether specified hair or guides supports different point counts per each strand, or if all strands have uniform point count
int OxUsesStrandTopology( string $strandShape );

// Determines whether hair has per-strand transforms, or if its vertices are in object space
int OxUsesPerStrandTransformations( string $strandShape );

// Determines whether hair has extra twist data for each strand which can be used to rotate the hairs around their axis
int OxIsUsingPerStrandRotationAngles( string $strandShape );

// Determines whether hair contains information about where it was planted on the mesh
int OxKeepsSurfaceDependency( string $strandShape );

// Determines whether hair contains information about which guides define its shape
int OxKeepsGuideDependency( string $strandShape );

// Determines whether hair will use the underlying distribution mesh to determine its orientation. When true, deformations to the surface will make hair stay "glued" to it
int OxUsesTopologyOrientation( string $strandShape );

// Determines whether hair has the same point count in all strands
int OxUsesGlobalPerStrandPointCount( string $strandShape );

// If OxUsesGlobalPerStrandPointCount(...) return true, this gets the number of points in each strand
int OxGetGlobalStrandPointCount( string $strandShape );

// Returns the number of texture coordinate channels available in the hair, if any. Result of 0 means that hair doesn't have any texture coordinates.
int OxGetMappingChannelCount( string $strandShape );

// Returns the array of strand ids for all strands in the hair.
int[] OxGetStrandIds( string $strandShape );

// Returns the array of strand group indices for all strands in the hair.
int[] OxGetStrandGroups( string $strandShape );

// Returns an array of names for all per-strand data channels in the hair
string[] OxGetRootChannels( string $strandShape );

// Returns an array of names for all per-vertex data channels in the hair
string[] OxGetVertexChannels( string $strandShape );

// Returns a bit-flag array for each strand in the hair, determining if it is currently selected or not
int[] OxGetSelectedStrands( string $strandShape );

// Returns the array of ids for currently selected strands
int[] OxGetSelectedStrandIds( string $strandShape );

// Returns the array of indices for currently selected strands
int[] OxGetSelectedStrandIndices( string $strandShape )

// Returns a bit-flag array for each strand in the hair, determining if it is currently visible (not hidden) or not
int[] OxGetVisibleStrands( string $strandShape );

// Returns the bounding box of the hair represented as its minimum and maximum corner points: [[minX, minY, minZ], [maxX, maxY, maxZ]]
float[][] OxGetBoundingBox( string $strandShape );

// Returns all vertices within the strand shape
// Flag: -os (-objectSpace) When present the vertices will be returned in object space, otherwise they will be in strand space
float[][] OxGetVertices( string $strandShape, -os|-objectSpace );
 

Per-Strand Functions 

These functions return information for a specific strand in a HairShape or GuideShape, given it's index:

// Returns the "topology" of a strand, which is an array containing its first vertex index and point count: [firstVertexIndex, pointCount]
int[] OxGetStrandTopology( string $strandShape, int $strandIndex );

// Returns the "strand to object" transformation matrix components. All strand points must be multiplied by this transform to ensure that they are in object space.
float[] OxGetStrandTransform( string $strandShape, int $strandIndex );

// Returns an optional "twist" value by which the strand transformation is rotated around the surface normal.
float OxGetPerStrandRotationAngle( string $strandShape, int $strandIndex );

// Returns the face on distribution mesh surface and barycentric coordinate position of the strand on this face for the strand: [faceIndex, barycentricX, barycentricY, barycentricZ]
float[] OxGetSurfaceDependency( string $strandShape, int $strandIndex );

// If available, returns the three closest guides information to the strand: [guide1Index, guide2Index, guide3Index, distanceToGuide1, distanceToGuide2, distanceToGuide3]
float[] OxGetGuideDependency( string $strandShape, int $strandIndex );

// Returns number of points in the strand
int OxGetStrandPointCount( string $strandShape, int $strandIndex );

// Returns the index of the first vertex (relative to the global vertex array) in the strand
int OxGetFirstVertexIndex( string $strandShape, int $strandIndex );

// Returns a strand's point array in strand space
float[][] OxGetStrandPoints( string $strandShape, int $strandIndex );
 

Per-Vertex Functions 

These functions return information for a specific vertex in a HairShape or GuideShape, given it's index:

// Returns the XYZ position of specified vertex in strand space
float[] OxGetVertex( string $strandShape, int $vertexIndex );
 

Per-Strand Data Channel Functions 

The following functions are called on a specific per-strand or per-vertex data channel, given its index:

// Returns per-strand values for all strands
float[] OxGetRootValuesForChannel( string $strandShape, int $channelIndex );

// Returns per-vertex values for all vertices
float[] OxGetVertexValuesForChannel( string $strandShape, int $channelIndex );
 

Per-Strand Point Functions 

The following functions return information about a specific strand's point, given the strand's index and the point index on this strand:

// Returns the position of a strand's point in strand space: [X, Y, Z]
float[] OxGetStrandPoint( string $strandShape, int $strandIndex, int $pointIndex );

// Returns the position of a strand's point in object space: [X, Y, Z]
float[] OxGetStrandPointInObjectCoordinates( string $strandShape, int $strandIndex, int $pointIndex );
 

Texture Coordinate Access Functions 

The following functions can be used to get texture coordinate information from hair:

// Returns the UVW texture coordinate for specified strand, point, and texture channel: [u, v, w]
float[] OxGetTextureCoordinate( string $strandShape, int $strandIndex, int $pointIndex, int $textureChannelIndex );

// Returns per-strand texture coordinates for specified texture channel: [[u1, v1], [u2, v2], ...]
float[][] OxGetTextureCoordinates( string $strandShape, int $textureChannelIndex );
 

Editing guides 

OxEditGuides command is used to make some changes to guides inside an EditGuidesShape instance. You can create, delete, modify guides, edit channel data, and perform other operations.

OxEditGuides [flags]
 

Editing clumps 

Clumping can be performed using OxEditClumps command. See more information about it on the clumping page.

OxEditClumps "ClumpNode" [flag1] [flag2] ...
Missing Something? Let us know if this page needs more information about the topic.