spiral
/* spiral V2.0 - Maya2.0
This script may be freely distributed. Modify at your own risk.
Author: Dirk Bialluch (DirkBi@Software2000.de)
Thanks to Duncan Brinsmead and Martin Watt for their first scripts and ideas!
Creation date: 18.09.1998
Last update: 21.04.2000
Description
This script creates a spiral nurbs surface with optional construction history.
Use the tool help window for detailed information.
History
V1.1 NEW
-added fixed spiral subdivision to avoid
sudden changes in geometry when animating
-CH update when Spiral Radius changed
-print recommended spans value behind slider
-switch for automatic span adjusting
-group construction objects
V1.2 CHANGED
-expressions enhanced
-ui layout modified
NEW
-switch for user defined axis
V1.3 ENHANCED
-use pointOnSurface history instead of expression
V1.4 ENHANCED
-replaced set driven keys with expressions
NEW
-added `keep profile tangent` switch and attribute
V1.5 NEW
-set spiral start and end radius (for fixed axis only)
-print degree value behind turns slider
-store UI settings
ENHANCED
-replaced most expressions by connections (noticeable performance gain)
V2.0 CHANGED
-UI completely reprogrammed
-'circleRadius' attribute renamed to 'profileRadius'
-replaced all remaining expressions by node networks
-removed 'keepTangent' attribute
FIXED
-detached curves will now be handled properly including construction history
NEW
-help window
-rebuild construction curves uniformly
-support multiple selected curves
*/
//
// Create UI
//
global proc spiral ()
{
int $uiLabelWidth = 150;
int $uiInputWidth = 80;
int $uiWidth = $uiLabelWidth + $uiInputWidth + 110;
if ( `window -exists sp_ui` )
deleteUI sp_ui;
window
-maximizeButton false
-resizeToFitChildren false
-menuBar true
-menuBarVisible true
-title "Create Spiral V2.0"
-iconName "Create Spiral" sp_ui;
menu
-label "Edit"
-tearOff false;
menuItem
-label "Reset Settings"
-c "sp_storeRecallUI reset; spiral";
menu
-label "Help"
-tearOff false;
menuItem
-label "Help with Spiral tool"
-c "sp_help 1";
menuItem
-divider true;
menuItem
-label "Script Information"
-c "sp_help 2";
string $sp_form = `formLayout -numberOfDivisions 100`;
string $sp_scroll = `scrollLayout -hst 16 -vst 16 -childResizable true -minChildWidth $uiWidth`;
columnLayout -adjustableColumn true -rowSpacing 6;
frameLayout
-label "Spiral Settings"
-labelAlign "center"
-cll true
-lw $uiWidth
-mh 3
-cc "sp_adjustUI"
-ec "sp_adjustUI"
-bs "etchedIn"
-bv true
sp_ssFrame;
columnLayout -adjustableColumn true;
rowLayout
-numberOfColumns 2
-cat 1 "right" 5
-columnWidth 1 $uiLabelWidth
-columnWidth 2 $uiInputWidth;
text -l "Profile Radius";
floatField
-w 80
-precision 3
-value .25
-minValue .001
-cc "sp_adjustUI"
sp_pRadius;
setParent ..;
rowLayout
-numberOfColumns 3
-cat 1 "right" 5
-columnWidth 1 $uiLabelWidth
-columnWidth 2 $uiInputWidth
sp_tangent;
text -l "Keep Profile Tangent";
checkBox
-h 20
-label ""
-value 1
-cc "sp_adjustUI"
sp_tangent;
setParent ..;
separator -h 8;
rowLayout
-numberOfColumns 2
-cat 1 "right" 5
-columnWidth 1 $uiLabelWidth
-columnWidth 2 $uiInputWidth;
text -l "Spiral Start Radius";
floatField
-w 80
-precision 3
-value 1
-minValue .001
-cc "sp_adjustUI"
sp_sStartRadius;
setParent ..;
rowLayout
-numberOfColumns 2
-cat 1 "right" 5
-columnWidth 1 $uiLabelWidth
-columnWidth 2 $uiInputWidth
sp_sEndRadius;
text -l "Spiral End Radius";
floatField
-w 80
-precision 3
-value 1
-minValue .001
-cc "sp_adjustUI"
sp_sEndRadius;
setParent ..;
rowLayout
-numberOfColumns 2
-cat 1 "right" 5
-columnWidth 1 $uiLabelWidth
-columnWidth 2 $uiInputWidth
sp_length;
text -l "Length";
floatField
-w 80
-precision 3
-value 4
-minValue 0
-cc "sp_adjustUI"
sp_length;
setParent ..;
rowLayout
-numberOfColumns 3
-cat 1 "right" 5
-columnWidth 1 $uiLabelWidth
-columnWidth 2 $uiInputWidth;
text -l "Turns";
floatField
-w 80
-precision 3
-value 2
-minValue .001
-cc "sp_adjustUI"
sp_turns;
text -l "720"
sp_turns;
setParent ..;
separator -h 8;
rowLayout
-numberOfColumns 3
-cat 1 "right" 5
-columnWidth 1 $uiLabelWidth
-columnWidth 2 $uiInputWidth
sp_autospan;
text -l "Automatic Span Adjustment";
checkBox
-h 20
-label ""
-value 0
-cc "sp_adjustUI"
sp_autospan;
setParent ..;
rowLayout
-numberOfColumns 3
-cat 1 "right" 5
-columnWidth 1 $uiLabelWidth
-columnWidth 2 $uiInputWidth
sp_spiralSpans;
text -l "Spiral Spans";
intField
-w 80
-value 16
-minValue 4
-cc "sp_adjustUI"
sp_spiralSpans;
text -l "16"
sp_spiralSpans;
setParent ..;
separator -h 8;
rowLayout
-numberOfColumns 2
-cat 1 "right" 5
-columnWidth 1 $uiLabelWidth
-columnWidth 2 $uiInputWidth;
text -l "Axis";
radioButtonGrp
-numberOfRadioButtons 4
-cw 1 40
-cw 2 40
-cw 3 40
-labelArray4 "X" "Y" "Z" "Curve"
-select 1
-cc "sp_adjustUI"
sp_axis;
setParent ..;
separator -h 8;
rowLayout
-numberOfColumns 2
-cat 1 "right" 5
-columnWidth 1 $uiLabelWidth
-columnWidth 2 $uiInputWidth
sp_rebuildCurve;
text -l "Rebuild Curve";
checkBox
-h 20
-label ""
-value 0
-cc "sp_adjustUI"
sp_rebuildCurve;
setParent ..;
rowLayout
-numberOfColumns 2
-cat 1 "right" 5
-columnWidth 1 $uiLabelWidth
-columnWidth 2 $uiInputWidth
sp_curveSpans;
text -l "Curve Spans";
intField
-w 80
-value 16
-minValue 4
-cc "sp_adjustUI"
sp_curveSpans;
setParent ..;
separator -h 8;
rowLayout
-numberOfColumns 2
-cat 1 "right" 5
-columnWidth 1 $uiLabelWidth
-columnWidth 2 $uiInputWidth;
text -l "Keep Construction History";
checkBox
-h 20
-label ""
-value 1
-cc "sp_adjustUI"
sp_history;
setParent ..;
setParent ..;
setParent ..;
setParent ..;
setParent ..;
string $sp_button = `button
-label "Create Spiral"
-command "sp_main"
sp_button`;
string $sp_close = `button
-label "Close"
-command "deleteUI sp_ui"`;
setParent ..;
// set form layouts
formLayout -edit
-attachForm $sp_scroll "top" 2
-attachForm $sp_scroll "left" 2
-attachControl $sp_scroll "bottom" 2 $sp_button
-attachForm $sp_scroll "right" 2
-attachNone $sp_button "top"
-attachForm $sp_button "left" 2
-attachForm $sp_button "bottom" 2
-attachPosition $sp_button "right" 2 50
-attachNone $sp_close "top"
-attachPosition $sp_close "left" 2 50
-attachForm $sp_close "bottom" 2
-attachForm $sp_close "right" 2
$sp_form;
// restore UI settings
sp_storeRecallUI recall;
// sp_adjustUI;
sp_adjustUI;
showWindow sp_ui;
// create spiral script exit scriptJob (delete help window)
scriptJob
-parent sp_ui
-uiDeleted sp_ui sp_exit;
}
//
// quit spiral script
//
global proc sp_exit ()
{
if ( `window -exists sp_help` )
deleteUI sp_help;
}
//
// adjust UI settings
//
global proc sp_adjustUI ()
{
// update recommended spans value and degree display
text -e -label ( string( int( `floatField -q -value sp_turns` * 8 ) ) ) sp_spiralSpans;
text -e -label ( string( `floatField -q -value sp_turns` * 360 ) + " Degree" ) sp_turns;
// enable/disable "auto span adjust" and "keep profile tangent" checkbox
if ( !`checkBox -q -value sp_history` )
{
rowLayout -e -enable 0 sp_autospan;
rowLayout -e -enable 0 sp_tangent;
}
else
{
rowLayout -e -enable 1 sp_autospan;
rowLayout -e -enable 1 sp_tangent;
}
// enable/disable "length" and "spiral end radius" slider when curve axis is selected
if ( `radioButtonGrp -q -select sp_axis` == 4 )
{
rowLayout -e -enable 0 sp_length;
rowLayout -e -enable 0 sp_sEndRadius;
rowLayout -e -enable 1 sp_rebuildCurve;
if ( !`checkBox -q -v sp_rebuildCurve` )
rowLayout -e -enable 0 sp_curveSpans;
else
rowLayout -e -enable 1 sp_curveSpans;
}
else
{
rowLayout -e -enable 1 sp_length;
rowLayout -e -enable 1 sp_sEndRadius;
rowLayout -e -enable 0 sp_rebuildCurve;
rowLayout -e -enable 0 sp_curveSpans;
}
// enable/disable "spans" slider when automatic span adjust is turned on
if ( `checkBox -q -value sp_autospan` && `checkBox -q -value sp_history` )
rowLayout -e -enable 0 sp_spiralSpans;
else
rowLayout -e -enable 1 sp_spiralSpans;
sp_storeRecallUI store;
}
//
// store/recall UI
//
global proc sp_storeRecallUI ( string $mode )
{
string $floatFieldList[] = {
"sp_pRadius",
"sp_sStartRadius",
"sp_sEndRadius",
"sp_length",
"sp_turns"
};
string $intFieldList[] = {
"sp_spiralSpans",
"sp_curveSpans"
};
string $checkBoxList[] = {
"sp_history",
"sp_autospan",
"sp_tangent",
"sp_rebuildCurve"
};
string $radioButtonGrpList[] = {
"sp_axis"
};
string $frameLayoutList[] = {
"sp_ssFrame"
};
int $cnt;
if ( $mode == "store" )
{
for ( $cnt = 0; $cnt < size( $floatFieldList ); $cnt++ )
optionVar -floatValue $floatFieldList[$cnt] `floatField -q -value $floatFieldList[$cnt]`;
for ( $cnt = 0; $cnt < size( $intFieldList ); $cnt++ )
optionVar -intValue $intFieldList[$cnt] `intField -q -value $intFieldList[$cnt]`;
for ( $cnt = 0; $cnt < size( $checkBoxList ); $cnt++ )
optionVar -intValue $checkBoxList[$cnt] `checkBox -q -value $checkBoxList[$cnt]`;
for ( $cnt = 0; $cnt < size( $radioButtonGrpList ); $cnt++ )
optionVar -intValue $radioButtonGrpList[$cnt] `radioButtonGrp -q -select $radioButtonGrpList[$cnt]`;
for ( $cnt = 0; $cnt < size( $frameLayoutList ); $cnt++ )
optionVar -intValue $frameLayoutList[$cnt] `frameLayout -q -collapse $frameLayoutList[$cnt]`;
}
if ( $mode == "recall" )
{
for ( $cnt = 0; $cnt < size( $floatFieldList ); $cnt++ )
if ( `optionVar -exists $floatFieldList[$cnt]` )
floatField -e -value `optionVar -q $floatFieldList[$cnt]` $floatFieldList[$cnt];
for ( $cnt = 0; $cnt < size( $intFieldList ); $cnt++ )
if ( `optionVar -exists $intFieldList[$cnt]` )
intField -e -value `optionVar -q $intFieldList[$cnt]` $intFieldList[$cnt];
for ( $cnt = 0; $cnt < size( $checkBoxList ); $cnt++ )
if ( `optionVar -exists $checkBoxList[$cnt]` )
checkBox -e -value `optionVar -q $checkBoxList[$cnt]` $checkBoxList[$cnt];
for ( $cnt = 0; $cnt < size( $radioButtonGrpList ); $cnt++ )
if ( `optionVar -exists $radioButtonGrpList[$cnt]` )
radioButtonGrp -e -select `optionVar -q $radioButtonGrpList[$cnt]` $radioButtonGrpList[$cnt];
for ( $cnt = 0; $cnt < size( $frameLayoutList ); $cnt++ )
if ( `optionVar -exists $frameLayoutList[$cnt]` )
frameLayout -e -collapse `optionVar -q $frameLayoutList[$cnt]` $frameLayoutList[$cnt];
}
if ( $mode == "reset" )
{
for ( $cnt = 0; $cnt < size( $floatFieldList ); $cnt++ )
optionVar -remove $floatFieldList[$cnt];
for ( $cnt = 0; $cnt < size( $intFieldList ); $cnt++ )
optionVar -remove $intFieldList[$cnt];
for ( $cnt = 0; $cnt < size( $checkBoxList ); $cnt++ )
optionVar -remove $checkBoxList[$cnt];
for ( $cnt = 0; $cnt < size( $radioButtonGrpList ); $cnt++ )
optionVar -remove $radioButtonGrpList[$cnt];
for ( $cnt = 0; $cnt < size( $frameLayoutList ); $cnt++ )
optionVar -remove $frameLayoutList[$cnt];
}
}
//
// Create tube from curve
//
proc string[] sp_crv2Tube (string $crv, float $radius)
{
// get start pos and tan of curve in world space
float $pos[] = `pointOnCurve -top 1 -pr .0001 -position $crv`;
float $tan[] = `pointOnCurve -top 1 -pr .0001 -tangent $crv`;
// create circle at curve matching curve tangent
string $profile[] = `circle -c $pos[0] $pos[1] $pos[2] -nr $tan[0] $tan[1] $tan[2] -r $radius`;
xform -cp $profile[0];
// extrude spiral
string $spiral[] = `extrude -fixedPath 1 -ucp 1 -upn 1 -et 2 -n spiralSurface1 $profile[0] $crv`;
// return spiral surface, profile curve and profile shape
return {$spiral[0], $profile[0], $profile[1]};
}
//
// Main function
//
global proc sp_main ()
{
// choose select tool
global string $gSelect;
setToolTo $gSelect;
// get settings from UI
float $sRadius1 = `floatField -q -value sp_sStartRadius`;
float $sRadius2 = `floatField -q -value sp_sEndRadius`;
float $pRadius = `floatField -q -value sp_pRadius`;
float $length = `floatField -q -value sp_length`;
float $turns = `floatField -q -value sp_turns`;
int $spiralSpans = `intField -q -value sp_spiralSpans`;
int $userAxis = `radioButtonGrp -q -select sp_axis`;
string $scaleDirection[3] = {".sx",".sy",".sz"};
int $keepTangent = `checkBox -q -value sp_tangent`;
int $rebuildCurve = `checkBox -q -value sp_rebuildCurve`;
int $curveSpans = `intField -q -value sp_curveSpans`;
// get selected nurbs curves
string $objList[] = `filterExpand -ex true -sm 9`;
float $axis[3];
switch ( $userAxis )
{
case 1:
$axis = {1,0,0};
break;
case 2:
$axis = {0,1,0};
break;
case 3:
$axis = {0,0,1};
break;
case 4:
if ( !size ( $objList ) )
error "No nurbs curve selected";
break;
}
// create spiral along fixed axis
if ( $userAxis != 4 )
{
// create two nurbs circle
string $startCircle[] = `circle -center 0 0 0
-normal $axis[0] $axis[1] $axis[2]
-radius $sRadius1
-ch true`;
string $endCircle[] = `circle -center $axis[0] $axis[1] $axis[2]
-normal $axis[0] $axis[1] $axis[2]
-radius $sRadius2
-ch true`;
// create cone
string $tube[] = `loft -ch true $startCircle[0] $endCircle[0]`;
inheritTransform -off -p $tube[0];
// set spiral length
setAttr ($tube[0] + $scaleDirection[$userAxis - 1]) $length;
// create spiral curve on surface
string $cos = `curveOnSurface -d 1 -uv 0 0 -uv 1 ( $turns * 8 ) $tube[0]`;
// duplicate and rebuild cos uniformly
string $crv[] = `duplicateCurve -ch true $cos`;
string $rebuild[] = `rebuildCurve -rt 0 -ch true -spans $spiralSpans $crv`;
// get start pos and tan of curve in world space
float $pos[] = `pointOnCurve -pr .0001 -position $crv[0]`;
float $tan[] = `pointOnCurve -pr .0001 -tangent $crv[0]`;
// make circle at start of spiral matching curve tangent
string $profile[] = `circle -c $pos[0] $pos[1] $pos[2] -nr $tan[0] $tan[1] $tan[2] -r $pRadius`;
inheritTransform -off -p $profile[0];
xform -cp $profile[0];
// extrude spiral
string $spiral[] = `extrude -fixedPath true -ucp true -et 2 -n spiralSurface1 $profile[0] $crv[0]`;
if (`checkBox -q -value sp_history`)
{
// add construction history attributes
addAttr -sn crd -ln profileRadius -at "float" -min .001 $spiral[0];
setAttr -keyable on ($spiral[0] + ".profileRadius") $pRadius;
connectAttr ($spiral[0] + ".profileRadius") ($profile[1] + ".radius");
addAttr -sn ssrd -ln spiralStartRadius -at "float" -min .001 $spiral[0];
setAttr -keyable on ($spiral[0] + ".spiralStartRadius") $sRadius1;
connectAttr ($spiral[0] + ".spiralStartRadius") ($startCircle[1] + ".radius");
addAttr -sn serd -ln spiralEndRadius -at "float" -min .001 $spiral[0];
setAttr -keyable on ($spiral[0] + ".spiralEndRadius") $sRadius2;
connectAttr ($spiral[0] + ".spiralEndRadius") ($endCircle[1] + ".radius");
addAttr -sn sln -ln spiralLength -at "float" -min 0 $spiral[0];
setAttr -keyable on ($spiral[0] + ".spiralLength") $length;
addAttr -sn srv -ln spiralTurns -at "float" -min 0.0001 -max 1000 $spiral[0];
setAttr -keyable on ($spiral[0] + ".spiralTurns") $turns;
// set 2nd COS CV yValue (number of turns)
string $multNode = `createNode multiplyDivide`;
setAttr ( $multNode + ".input2X" ) 8;
connectAttr ( $spiral[0] + ".spiralTurns" ) ( $multNode + ".input1X" );
connectAttr ( $multNode + ".outputX" ) ( $cos + ".cv[1].yValue" );
addAttr -sn spn -ln spans -at "long" -min 4 $spiral[0];
setAttr -keyable on ($spiral[0] + ".spans") $spiralSpans;
connectAttr ($spiral[0] + ".spans") ($rebuild[1] + ".spans");
// adjust length when spiral radius changes
connectAttr ($spiral[0] + ".spiralLength") ($tube[0] + $scaleDirection[$userAxis - 1]);
// create point on curve node
string $poc = `pointOnCurve -ch 1 -pr .0001 $cos`;
// adjust spiral cirlce tangent when # of turns change
if ( $keepTangent )
{
connectAttr ( $poc + ".tx" ) ( $profile[1] + ".normalX" );
connectAttr ( $poc + ".ty" ) ( $profile[1] + ".normalY" );
connectAttr ( $poc + ".tz" ) ( $profile[1] + ".normalZ" );
}
// auto adjust spans
if (`checkBox -q -value sp_autospan`)
{
string $multNode = `createNode multiplyDivide`;
string $clampNode = `createNode clamp`;
setAttr ( $multNode + ".input2X" ) 8;
setAttr ( $clampNode + ".minR" ) 4;
setAttr ( $clampNode + ".maxR" ) 1000;
connectAttr ( $spiral[0] + ".spiralTurns" ) ( $multNode + ".input1X" );
connectAttr ( $multNode + ".outputX" ) ( $clampNode + ".inputR" );
connectAttr ( $clampNode + ".outputR" ) ( $spiral[0] + ".spans" );
}
// group and hide construction objects
inheritTransform -off -p $crv[0];
string $group = `group -n spiralConstruction1 $startCircle[0]
$endCircle[0]
$tube[0]
$profile[0]
$crv[0]`;
hide $group;
}
else
// delete construction objects
delete $tube[0] $profile[0] $crv[0] $startCircle[0] $endCircle[0];
// select spiral surface
select -replace $spiral[0];
}
// create spiral along user defined nurbs curve
else
{
for ( $crvCnt = 0; $crvCnt < size( $objList ); $crvCnt++ )
{
string $userCurve = $objList[$crvCnt];
// rebuild curve
if ( $rebuildCurve )
{
// get original degree
int $curveDegree = `getAttr ( $userCurve + ".degree" )`;
string $newCurve[0] = `rebuildCurve
-ch 1
-rpo 0
-rt 0
-end 1
-kr 0
-kcp 0
-kep 1
-kt 0
-s $curveSpans
-d $curveDegree
$userCurve`;
$userCurve = $newCurve[0];
}
// create tube surface along user curve
string $tube[] = sp_crv2Tube ($userCurve, $sRadius1);
string $tubeCircle[] = {$tube[1], $tube[2]};
// get curve max value
float $minValue = `getAttr ( $userCurve + ".minValue" )`;
float $maxValue = `getAttr ( $userCurve + ".maxValue" )`;
// create spiral curve on surface
string $cos = `curveOnSurface -d 1 -uv 0 $minValue -uv ( $turns * 8 ) $maxValue $tube[0]`;
// duplicate and rebuild cos uniformly
string $crv[] = `duplicateCurve -ch true $cos`;
string $rebuild[] = `rebuildCurve -rt 0 -ch true -spans $spiralSpans $crv`;
// create spiral surface
string $spiral[] = sp_crv2Tube ( $rebuild[0], $pRadius );
string $spiralCircle[] = {$spiral[1], $spiral[2]};
if (`checkBox -q -value sp_history`)
{
addAttr -sn crd -ln profileRadius -at "float" -min .001 $spiral[0];
setAttr -keyable on ($spiral[0] + ".profileRadius") $pRadius;
connectAttr ($spiral[0] + ".profileRadius") ($spiralCircle[1] + ".radius");
addAttr -sn srd -ln spiralRadius -at "float" -min .001 $spiral[0];
setAttr -keyable on ($spiral[0] + ".spiralRadius") $sRadius1;
connectAttr ($spiral[0] + ".spiralRadius") ($tubeCircle[1] + ".radius");
addAttr -sn srv -ln spiralTurns -at "float" -min 0.0001 -max 1000 $spiral[0];
setAttr -keyable on ($spiral[0] + ".spiralTurns") $turns;
// set 2nd COS CV xValue (number of turns)
string $multNode = `createNode multiplyDivide`;
setAttr ( $multNode + ".input2X" ) 8;
connectAttr ( $spiral[0] + ".spiralTurns" ) ( $multNode + ".input1X" );
connectAttr ( $multNode + ".outputX" ) ( $cos + ".cv[1].xValue" );
addAttr -sn sln -ln spiralLength -at "float" -min 0.0001 -max 1 $spiral[0];
setAttr -keyable on ($spiral[0] + ".spiralLength") 1;
// set 1st COS CV yValue (spiral start)
connectAttr ( $userCurve + ".minValue" ) ( $cos + ".cv[0].yValue" );
// set 2nd COS CV yValue (spiral end)
string $multNode1 = `createNode multiplyDivide`;
string $multNode2 = `createNode multiplyDivide`;
string $addNode1 = `createNode addDoubleLinear`;
string $addNode2 = `createNode addDoubleLinear`;
setAttr ( $multNode1 + ".input2X" ) -1;
connectAttr ( $userCurve + ".minValue" ) ( $multNode1 + ".input1X" );
connectAttr ( $userCurve + ".maxValue" ) ( $addNode1 + ".input1" );
connectAttr ( $multNode1 + ".outputX" ) ( $addNode1 + ".input2" );
connectAttr ( $spiral[0] + ".spiralLength" ) ( $multNode2 + ".input1Y" );
connectAttr ( $addNode1 + ".output" ) ( $multNode2 + ".input2Y" );
connectAttr ( $multNode2 + ".outputY" ) ( $addNode2 + ".input1" );
connectAttr ( $userCurve + ".minValue" ) ( $addNode2 + ".input2" );
connectAttr ( $addNode2 + ".output" ) ( $cos + ".cv[1].yValue" );
addAttr -sn spn -ln spans -at "long" -min 4 $spiral[0];
setAttr -keyable on ($spiral[0] + ".spans") $spiralSpans;
connectAttr ($spiral[0] + ".spans") ($rebuild[1] + ".spans");
// create point on curve node for spiral curve
string $poc = `pointOnCurve -ch 1 -top 1 -pr .0001 $cos`;
// adjust spiral cirlce tangent when # of turns change
if ( $keepTangent )
{
connectAttr ( $poc + ".tx" ) ( $spiralCircle[1] + ".normalX" );
connectAttr ( $poc + ".ty" ) ( $spiralCircle[1] + ".normalY" );
connectAttr ( $poc + ".tz" ) ( $spiralCircle[1] + ".normalZ" );
}
// auto adjust spans
if (`checkBox -q -value sp_autospan`)
{
string $multNode = `createNode multiplyDivide`;
string $clampNode = `createNode clamp`;
setAttr ( $multNode + ".input2X" ) 8;
setAttr ( $clampNode + ".minR" ) 4;
setAttr ( $clampNode + ".maxR" ) 1000;
connectAttr ( $spiral[0] + ".spiralTurns" ) ( $multNode + ".input1X" );
connectAttr ( $multNode + ".outputX" ) ( $clampNode + ".inputR" );
connectAttr ( $clampNode + ".outputR" ) ( $spiral[0] + ".spans" );
}
// group and hide construction objects
inheritTransform -off -p $crv[0];
string $group = `group -n spiralConstruction1 $tube[0] $tubeCircle[0] $spiralCircle[0] $rebuild[0]`;
if ( $rebuildCurve )
parent $userCurve $group;
hide $group;
}
else
{
// delete construction objects
delete $tube[0] $tubeCircle[0] $spiralCircle[0] $rebuild[0];
if ( $rebuildCurve )
delete $userCurve;
}
// select spiral surface
select -replace $spiral[0];
}
}
}
// end of script
There are no threads for this page.
Be the first to start a new thread.