Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Evenly distributed points on a Softimage curve
si = Application
def frange(x, y, jump):
Like range() but with float values.
while x < y:
yield x
x += jump
def evenPositions(crv, quantity):
Get an amount of evenly spaced positions on a given curve.
subcrv = crv.ActivePrimitive.Geometry.Curves(0)
percs = [num for num in frange(0.0, 100.0, 100.0 / quantity)]
ppos = [ subcrv.EvaluatePosition( subcrv.GetUFromPercentage(percs[i]) )[0] for i in xrange(len(percs)) ]
return ppos
def main():
size = float( Application.XSIInputBox("What particle size do you plan on using?", "So I know the spacing...", 1) )
newCurves = []
si.OpenUndo("Make evenly spread linear curves")
for crv in si.Selection:
quantity = int(crv.ActivePrimitive.Geometry.Curves(0).Length / (size*2.0))
positions = evenPositions(crv, quantity)
positions = ["(%s,%s,%s)" % (a.X,a.Y,a.Z) for a in positions]
newCurve = si.CreateCurve( 1, 0, ",".join(positions), False)('Value')
newCurve.Name = crv.Name+'_evenlySpaced'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.