4
$\begingroup$

I'm attempting to write an addon that will perform multiple extrusions along a curve. Perhaps there is a simpler way that already exists but in case there isn't I am trying to do the following:

Suppose I have a triangle (so 3 vertices). I would like to extrude it 10 times along a curve so that it merges to a single point. There could be some 'apex' (forgive me if I'm not using the correct terminology) that I could move along the curve and 'up' and 'down'. So it could be, for instance, from 0 to 1 where .5 would be in the middle and also a linear curve, AKA a straight line :)

I need some formula to calculate the vertex XYZ coordinates for this.

I hope that makes sense. Any help would be greatly appreciated.

enter image description here

$\endgroup$
2

1 Answer 1

4
$\begingroup$

The last few weeks I developed all sort of spline evaluation stuff for my Animation Nodes addon. For that I created a small library that deals with curves. (Bezier and Poly splines for now only)

When you want to use this package for your addon, you should make a multifile addon. To explain how that works isn't the topic here. You may want to google it, look at other multifile addons or ask another question here on stackexchange.

Then create a new folder in your addon directory called 'splines' or whatever. And copy the content of this folder inside: https://github.com/JacquesLucke/animation_nodes/tree/curve-sockets/data_structures/splines (I hope this link will still be available after I removed the branch, otherwise tell me in the comments)

Here is how to use this library:

from . spline import from_blender

# the object can be any blender object, but should be of type CURVE obviously
# it returns a list of splines, because one curve object can contain multiple splines
user_splines = from_blender.createSplinesFromBlenderObject(object)

# choose the spline you want to use
active_spline = user_splines[0]

# only needed when you want the spline in world space
active_spline.transform(object.matrix_world)

# this internally creates the individual segments (at least for Poly and Bezier Splines)
# and prepares everything for evaluation
active_spline.update()

# get 50 points distributes over the spline
samples = active_spline.getSamples(50)

# getting samples with equal distances is a bit more complicated
active_spline.ensureUniformConverter(resolution = 100)
uniformSamples = active_spline.getUniformSamples(50)

# To evaluate individual parameters (what you called apex):
location = active_spline.evaluate(0.5)

# The same applies for evaluating the tangents/derivatives of the spline
tangents = active_spline.getTangentSamples(50)
uniformTangents = active_spline.getUniformTangentSamples(50)
tangent = active_spline.evaluateTangent(0.5)

For more details you may want to take a look at the code

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .