{"id":96,"date":"2009-12-17T17:26:04","date_gmt":"2009-12-17T22:26:04","guid":{"rendered":"http:\/\/darkvertex.com\/wp\/?p=96"},"modified":"2009-12-17T17:29:13","modified_gmt":"2009-12-17T22:29:13","slug":"selfcontained-curvelength-operator","status":"publish","type":"post","link":"http:\/\/darkvertex.com\/wp\/2009\/12\/17\/selfcontained-curvelength-operator\/","title":{"rendered":"Softimage: A Self-Contained CurveLength Operator"},"content":{"rendered":"<p>Sometimes you need to know the length of a curve for some setups; for a while I sometimes used an addon called <a href=\"http:\/\/www.xsibase.com\/forum\/index.php?board=11;action=display;threadid=35052\">jsCurveLength<\/a>.<\/p>\n<p>However, the way it&#8217;s designed relies on the existance of the addon to evaluate. Without it, your rig is broken. I&#8217;ve made a version which is self-contained, so when you export your rig you don&#8217;t need to tell people to install any addon.<!--more--><\/p>\n<p>Select your curve(s) and run this code from either a button or the <em>Script Editor<\/em>. Here&#8217;s the JavaScript:<\/p>\n<pre lang=\"javascript\">\r\n\/\/ Self-Contained CurveLength Op -- http:\/\/darkvertex.com\/\r\n\r\nfunction CurveLengthOp_Update( In_UpdateContext, Out, Incrvlist ) {\r\n\tOut.Value = Incrvlist.Value.Geometry.Curves(0).Length;\r\n\treturn true;\r\n}\r\n\r\nfunction ApplyCurveLengthProp() {\r\n\toEnum = new Enumerator( Application.Selection ) ;\r\n\tfor (;!oEnum.atEnd();oEnum.moveNext() )\r\n\t{\r\n\t\tvar sel = oEnum.item();\r\n\t\tif (sel.Type == \"crvlist\") {\r\n\t\t\tvar oProp = sel.AddProperty( \"Custom_parameter_list\", false, \"CurveLength\" );\r\n\t\t\tvar p = oProp.AddParameter2(\"CurveLength\",siDouble,0,-8000,8000,-8000,8000,siClassifUnknown,siPersistable | siAnimatable, \"Length\");\r\n\t\t\tvar crvList = sel.ActivePrimitive;\r\n\t\t\tvar newOp = AddScriptedOp( p, CurveLengthOp_Update.toString(), crvList, \"CurveLengthOp\", \"JScript\" );\r\n\t\t\t\r\n\t\t\tnewOp.Debug = 0;\r\n\t\t\tnewOp.AlwaysEvaluate = true;\r\n\t\t\tnewOp.Connect();\r\n\t\t\t\r\n\t\t\tLogMessage(\"Added CurveLengthOp to: \"+sel.FullName, siVerbose);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nApplyCurveLengthProp();\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you need to know the length of a curve for some setups; for a while I sometimes used an addon called jsCurveLength. However, the way it&#8217;s designed relies on the existance of the addon to evaluate. Without it, your rig is broken. I&#8217;ve made a version which is self-contained, so when you export your [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[3],"tags":[8,30,9],"class_list":["post-96","post","type-post","status-publish","format-standard","hentry","category-softimage","tag-scripts","tag-softimage","tag-tools"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2xH1Z-1y","_links":{"self":[{"href":"http:\/\/darkvertex.com\/wp\/wp-json\/wp\/v2\/posts\/96","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/darkvertex.com\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/darkvertex.com\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/darkvertex.com\/wp\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/darkvertex.com\/wp\/wp-json\/wp\/v2\/comments?post=96"}],"version-history":[{"count":18,"href":"http:\/\/darkvertex.com\/wp\/wp-json\/wp\/v2\/posts\/96\/revisions"}],"predecessor-version":[{"id":114,"href":"http:\/\/darkvertex.com\/wp\/wp-json\/wp\/v2\/posts\/96\/revisions\/114"}],"wp:attachment":[{"href":"http:\/\/darkvertex.com\/wp\/wp-json\/wp\/v2\/media?parent=96"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/darkvertex.com\/wp\/wp-json\/wp\/v2\/categories?post=96"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/darkvertex.com\/wp\/wp-json\/wp\/v2\/tags?post=96"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}