View Full Version : Calculate spline length
chrleon 09-29-2002, 05:07 PM Hi..
is there a way to calculate the length of a spline?
If you want to make for example a necklace, and you use the arrange command to arrange the beads on the spline, it would be nice to be able to calculate the length of the spline so that it would be possible to use the right amount of beads, at once instead of trial and error.
I have tried the Splinelength.cof plugin from maxon, but it doen't seem to work in r7 :(
All tips wanted.
|
|
Per-Anders
09-29-2002, 05:52 PM
use Ditools instancer to place your beads at the vertex points around a spline, just set the spline to have a set number of vertex points in the first place... i'll see if i can get this darn script to work in the meanwhile (if only there was some decent documentation instead of the incomprehensible plugin cafe coffee sdk):rolleyes: if i can i'll post the script here for you... it shouldn't be difficult as spline length is apparently one of the standard functions in coffee...
Per-Anders
09-29-2002, 06:44 PM
i got this after searching around in the maxon developer forums, all you do is make a coffeee expression with the following and put it on your spline object, complie & execute, then open the console window to see the result.
main(doc,op)
{
//If the expression isn't on a spline object, don't do anything
if(!instanceof(op,SplineObject)) return;
//The number should be the segment of the spline you want
op->InitLength(0);
//Print the length of the spline to the console
println(op->GetLength());
}
what i would like to say though is that if you were to follow the COFFEE SDK you would be confused as hell by getting strange errors due to the complete lack of documentation... i did try the same as the above, but due to there being no document stating that there needed to be a value in the initlength brackets i was getting errors... the sdk documentation states that you also need to call a GetSplineObject reference as distinct from a standard GetActiveObject reference, of course for newbies it doesn't state that by having "op" or whatever variable in the second position in the main function you're automatically doing this, so you can waste a frustrating few hours trying to work out what the hells going on there, and why it seems impossible to make this GetSplineObject call without the program throwing an eppy. grrrr... i hope the v8 sdk's will be better than this. it's no wonder that the other packages have millions of scripts and c4d has so few... the documentation actually hinders those who might wish to learn... it shouldn't be a nightmare to do three lines of simple code.... grrrrrrrrrrr... ok, now i've finished with my rant.
chrleon
09-29-2002, 07:52 PM
Holy crap!
pardon my language, but that is amazing!!
You programmed that to help me?
I know its only three lines of code, and I know some scriting myself, I am impressed at the help.
GRATEFUL!
This is THE best board, people.
Thanks, mdme_sadie
Per-Anders
09-29-2002, 08:27 PM
no i didn't code that, that was taken verbatim from a thread in the maxon developers forum and it was written by Donovan Keith
all i did originally was open up the little script that you talked about in the first post, took it apart, looked at it, looked at the sdk, tried to do my own, which endedup almost identical to the one above... only one tiny undocumented thing... well actually all the things i stated buggered me up right royal, so i did a search on an offchance that someone would have an example of the code that would be usable... and got lucky, by finding this.
flingster
09-30-2002, 06:51 PM
Aaahhh Modest becomes you!:applause:
this is the best forum for support whether maxon appreciate it or not....believe it.:buttrock:
CGTalk Moderation
01-13-2006, 05:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.