How to Create Hanging Cables in Maya

I created this basic tool to simplify the process. With this you can create nice hanging cables between two points. This tool is useful when you need precise control (using clusters) over the start and end points.

First script (this will generate the Curves, the Clusters, the dynamic system and set some basic attributes – including the cluster selection priority 🙂 )
Please read the script comments as well.

//First Script - use this to generate a curve
// After that you can modify the start and end point
{
//Create a linear curve with two points
curve -d 1 -p 0 0 100 -p 0 0 -100 -k 0 -k 1 ;
string $selCurve[] = `ls -sl`;
//Convert the curve to Cluster Curve
ClusterCurve;
select $selCurve;
//If you need more detailed curves, increase the umber of spans: -s 4 
rebuildCurve -ch 1 -rpo 1 -rt 0 -end 1 -kr 0 -kcp 0 -kep 1 -kt 0 -s 4 -d 3 -tol 0.01 $selCurve;
currentTime -edit 1;
makeCurvesDynamic 2 { "1", "0", "1", "1", "0"};

//Global Settings
//Set the Cluster Selection Priority. This way you can select the clusters over everything else.
selectPriority -cluster 100;

//Set a few nucleus attribute to get the result faster
string $selNucleus[] = `ls -type "nucleus"`;
for ($item in $selNucleus)
{
setAttr ($item + ".visibility") 0;
setAttr ($item + ".timeScale") 10;
setAttr ($item + ".spaceScale") 0.01;
}
    
//Hide the hairSystemFollicles group
select -r "hairSystem*Follicles";
doHideObjects true;

//Hide the hairSystem node
string $selHairSys[] = `ls -type "hairSystem"`;
//print $selHairSys;
select $selHairSys;
pickWalk -direction up;
doHideObjects true;

//Clear the selection
select -cl;
}

Second script (to set the dynamic attributes for everything)

//Second Script - use this to set all the necessary attributes for all dynamic curves
//run this script every time if you generated new dynamic curve(s)
{
string $selFollicle[] = `ls -type "follicle"`;
for ($item in $selFollicle)
{
//Set the Sample Density – The default is 1
setAttr ($item + ".sampleDensity") 0.8;
}

//Set the Physical Attributes for everything – recommended values to get nice hanging curves
string $selHairSys[] = `ls -type "hairSystem"`;
for ($item in $selHairSys)
{
setAttr ($item + ".stretchResistance") 1;
setAttr ($item + ".compressionResistance") 1;
setAttr ($item + ".bendResistance") 0;
}
}

Create the geometry: you need the really nice and totally free Wire plug-in to generate polygons from the curves.

A few things:

  • Put the two script into a Shelf
  • It’s a simulation so don’t forget to set the Playback Speed type to Play Every Frame.
  • It’s not recommended to use this tool if you already have other nucleus based dynamic systems in your scene (in that case you need to separate and/or modify a few things).
  • If you need to generate a lot of hanging cables and you don’t have to be super precise your best tool for that is Houdini.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.