<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Samiam's Scribble Pad &#187; maya curve</title>
	<atom:link href="http://www.hodge.net.au/sam/blog/tag/maya-curve/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hodge.net.au/sam/blog</link>
	<description>Random Thoughts of Sam Hodge, about Life, Art and Technology</description>
	<lastBuildDate>Mon, 01 Dec 2025 07:20:55 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>length of a curve in Maya</title>
		<link>http://www.hodge.net.au/sam/blog/2009/06/09/length-of-a-curve-in-maya/</link>
		<comments>http://www.hodge.net.au/sam/blog/2009/06/09/length-of-a-curve-in-maya/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 06:10:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[maya curve]]></category>

		<guid isPermaLink="false">http://www.hodge.net.au/sam/blog/?p=128</guid>
		<description><![CDATA[I found a reasonable solutionhere: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 [...]]]></description>
				<content:encoded><![CDATA[<p>I found a reasonable solution<a href="http://www.edvardtoth.com/wp-content/content/source/mel/curveLength.mel">here</a>:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
</pre></td><td class="code"><pre class="c" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//=================================</span>
<span style="color: #666666; font-style: italic;">// curveLength v1.0 (08/2004)</span>
<span style="color: #666666; font-style: italic;">// by Edvard Toth</span>
<span style="color: #666666; font-style: italic;">// </span>
<span style="color: #666666; font-style: italic;">// The script is freeware. Non-commercial redistribution is permitted as long as this header remains included and unmodified.</span>
<span style="color: #666666; font-style: italic;">// Your feedback is always appreciated - if you find the script useful or if you have questions, comments, suggestions, requests, </span>
<span style="color: #666666; font-style: italic;">// bug-reports, if you created an updated version, to check for updates or to make a donation please contact me at:</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">// http://www.edvardtoth.com</span>
<span style="color: #666666; font-style: italic;">// </span>
<span style="color: #666666; font-style: italic;">//==================================</span>
<span style="color: #666666; font-style: italic;">// INSTALLATION: Copy the script into your Maya script-directory and start it with the curveLength; command.</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">// COMPATIBILITY NOTE: Tested with Maya 4.0 - 4.5 - 5.0 - 6.0 - 7.0</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">// DESCRIPTION:</span>
<span style="color: #666666; font-style: italic;">// This tiny but very straightforward utility measures the length of a curve without all the hassle that comes with </span>
<span style="color: #666666; font-style: italic;">// using Maya's implementation of the &quot;Arc Length Tool&quot;.</span>
<span style="color: #666666; font-style: italic;">//</span>
&nbsp;
global proc curveLength <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
&nbsp;
string $CL_curve<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> `ls <span style="color: #339933;">-</span>sl`<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>size<span style="color: #009900;">&#40;</span>$CL_curve<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
	confirmDialog <span style="color: #339933;">-</span>t <span style="color: #ff0000;">&quot;Oops...&quot;</span> <span style="color: #339933;">-</span>m <span style="color: #ff0000;">&quot;Please select a valid curve.&quot;</span> <span style="color: #339933;">-</span>b Continue<span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	string $CL_curvea<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> `ls <span style="color: #339933;">-</span>l $CL_curve<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span>`<span style="color: #339933;">;</span>
	string $CL_curveb<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> `listRelatives <span style="color: #339933;">-</span>f <span style="color: #339933;">-</span>ni <span style="color: #339933;">-</span>s $CL_curvea<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span>`<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>nodeType<span style="color: #009900;">&#40;</span>$CL_curveb<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">!=</span><span style="color: #ff0000;">&quot;nurbsCurve&quot;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
	confirmDialog <span style="color: #339933;">-</span>t <span style="color: #ff0000;">&quot;Oops...&quot;</span> <span style="color: #339933;">-</span>m <span style="color: #ff0000;">&quot;Please select a valid curve.&quot;</span> <span style="color: #339933;">-</span>b Continue<span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>    
&nbsp;
        <span style="color: #993333;">int</span> $CL_spans <span style="color: #339933;">=</span> `getAttr <span style="color: #009900;">&#40;</span>$CL_curve<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #ff0000;">&quot;.spans&quot;</span><span style="color: #009900;">&#41;</span>`<span style="color: #339933;">;</span>
&nbsp;
        string $CL_arclengthnode <span style="color: #339933;">=</span> `arcLengthDimension <span style="color: #009900;">&#40;</span>$CL_curve<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #ff0000;">&quot;.u[&quot;</span> <span style="color: #339933;">+</span> $CL_spans <span style="color: #339933;">+</span> <span style="color: #ff0000;">&quot;]&quot;</span><span style="color: #009900;">&#41;</span>`<span style="color: #339933;">;</span>
        string $CL_nodeparent<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> `listRelatives <span style="color: #339933;">-</span>p $CL_arclengthnode`<span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #993333;">float</span> $CL_curvelength <span style="color: #339933;">=</span> `getAttr <span style="color: #009900;">&#40;</span>$CL_arclengthnode <span style="color: #339933;">+</span> <span style="color: #ff0000;">&quot;.al&quot;</span><span style="color: #009900;">&#41;</span>`<span style="color: #339933;">;</span>
&nbsp;
        delete $CL_nodeparent<span style="color: #339933;">;</span>
&nbsp;
        confirmDialog <span style="color: #339933;">-</span>t $CL_curve<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span>m <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;curvelength:  &quot;</span> <span style="color: #339933;">+</span> $CL_curvelength<span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span>b OK<span style="color: #339933;">;</span>    
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>but since I hate Mel I have ported it to python</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="python" style="font-family:monospace;">&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> lengthOfCurve<span style="color: black;">&#40;</span>dagPathToCurve<span style="color: black;">&#41;</span>:
	<span style="color: #483d8b;">&quot;&quot;&quot;
	Assume that the Shape path is given, error checking is for upstream
	&quot;&quot;&quot;</span>
	<span style="color: #ff7700;font-weight:bold;">import</span> maya
	numSpans <span style="color: #66cc66;">=</span> maya.<span style="color: black;">cmds</span>.<span style="color: black;">getAttr</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%s.spans&quot;</span> % dagPathToCurve<span style="color: black;">&#41;</span>
	arcLengthTemp<span style="color: #66cc66;">=</span> maya.<span style="color: black;">cmds</span>.<span style="color: black;">arcLengthDimension</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%s.u[%s]&quot;</span> % <span style="color: black;">&#40;</span>dagPathToCurve<span style="color: #66cc66;">,</span>numSpans<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
	nodeParent <span style="color: #66cc66;">=</span> maya.<span style="color: black;">cmds</span>.<span style="color: black;">listRelatives</span><span style="color: black;">&#40;</span>arcLengthTemp<span style="color: #66cc66;">,</span>parent<span style="color: #66cc66;">=</span><span style="color: #008000;">True</span><span style="color: black;">&#41;</span>
	curveLength <span style="color: #66cc66;">=</span> maya.<span style="color: black;">cmds</span>.<span style="color: black;">getAttr</span> <span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%s.al&quot;</span> % arcLengthTemp<span style="color: black;">&#41;</span>
	maya.<span style="color: black;">cmds</span>.<span style="color: black;">delete</span><span style="color: black;">&#40;</span>nodeParent<span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">return</span> curveLength
&nbsp;
&nbsp;
<span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> maya.<span style="color: black;">cmds</span>.<span style="color: black;">ls</span><span style="color: black;">&#40;</span>selection<span style="color: #66cc66;">=</span><span style="color: #008000;">True</span><span style="color: black;">&#41;</span>:
	shapeNodes <span style="color: #66cc66;">=</span> maya.<span style="color: black;">cmds</span>.<span style="color: black;">listRelatives</span><span style="color: black;">&#40;</span>i<span style="color: #66cc66;">,</span>shapes<span style="color: #66cc66;">=</span><span style="color: #008000;">True</span><span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">for</span> shape <span style="color: #ff7700;font-weight:bold;">in</span> shapeNodes:
		<span style="color: #ff7700;font-weight:bold;">if</span> maya.<span style="color: black;">cmds</span>.<span style="color: black;">nodeType</span><span style="color: black;">&#40;</span>shape<span style="color: black;">&#41;</span> <span style="color: #66cc66;">==</span> <span style="color: #483d8b;">&quot;nurbsCurve&quot;</span>:
			<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Curve: %s is %s units long&quot;</span> % <span style="color: black;">&#40;</span>shape<span style="color: #66cc66;">,</span> lengthOfCurve<span style="color: black;">&#40;</span>shape<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
		<span style="color: #ff7700;font-weight:bold;">else</span>:
			<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Wrong: %s is a %s&quot;</span> % <span style="color: black;">&#40;</span>shape<span style="color: #66cc66;">,</span> maya.<span style="color: black;">cmds</span>.<span style="color: black;">nodeType</span><span style="color: black;">&#40;</span>shape<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>As Nick so rightly pointed out the following makes a lot more sense</p>
<p>sometimes rtfm > google</p>
<p><a href="http://download.autodesk.com/us/maya/2009help/Commands/arclen.html">arclen docs</a></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> maya
&nbsp;
<span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> maya.<span style="color: black;">cmds</span>.<span style="color: black;">ls</span><span style="color: black;">&#40;</span>selection<span style="color: #66cc66;">=</span><span style="color: #008000;">True</span><span style="color: black;">&#41;</span>:
	shapeNodes <span style="color: #66cc66;">=</span> maya.<span style="color: black;">cmds</span>.<span style="color: black;">listRelatives</span><span style="color: black;">&#40;</span>i<span style="color: #66cc66;">,</span>shapes<span style="color: #66cc66;">=</span><span style="color: #008000;">True</span><span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">for</span> shape <span style="color: #ff7700;font-weight:bold;">in</span> shapeNodes:
		<span style="color: #ff7700;font-weight:bold;">if</span> maya.<span style="color: black;">cmds</span>.<span style="color: black;">nodeType</span><span style="color: black;">&#40;</span>shape<span style="color: black;">&#41;</span> <span style="color: #66cc66;">==</span> <span style="color: #483d8b;">&quot;nurbsCurve&quot;</span>:
			<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Curve: %s is %s units long&quot;</span> % <span style="color: black;">&#40;</span>shape<span style="color: #66cc66;">,</span> arcLen<span style="color: black;">&#40;</span>shape<span style="color: #66cc66;">,</span>constuctionHistory<span style="color: #66cc66;">=</span><span style="color: #008000;">False</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
		<span style="color: #ff7700;font-weight:bold;">else</span>:
			<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Wrong: %s is a %s&quot;</span> % <span style="color: black;">&#40;</span>shape<span style="color: #66cc66;">,</span> maya.<span style="color: black;">cmds</span>.<span style="color: black;">nodeType</span><span style="color: black;">&#40;</span>shape<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.hodge.net.au/sam/blog/2009/06/09/length-of-a-curve-in-maya/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
