Skip to content

Instantly share code, notes, and snippets.

@kHigasa
Created November 25, 2018 14:01
Show Gist options
  • Save kHigasa/c87cbb2517e91ce25163d32917986d52 to your computer and use it in GitHub Desktop.
Save kHigasa/c87cbb2517e91ce25163d32917986d52 to your computer and use it in GitHub Desktop.
fibers with spline curve, python tag
import c4d
def main():
spline = op.GetObject()
emitter = spline[c4d.ID_USERDATA, 1]
if emitter == None:
return
if emitter.GetType() != 5109:
spline[c4d.ID_USERDATA, 1] = None
return
pData = emitter.GetCache().GetChildren()
pCount = len(pData)
pos = []
for p in pData:
pos.append(p.GetAbsPos())
minD = 0
maxD = 70
find = []
for i, p1 in enumerate(pos[:-1]):
for j, p2 in enumerate(pos[i+1:]):
dis = (p1-p2).GetLength()
if dis > minD and dis < maxD:
find.append([p1, p2])
findCount = len(find)
spline.ResizeObject(findCount * 2)
spline.MakeVariableTag(c4d.Tsegment, findCount)
p1id = 0
p2id = 1
for i, j in enumerate(find):
spline.SetPoint(p1id, j[0])
spline.SetPoint(p2id, j[1])
spline.SetSegment(i, 2, False)
p1id += 2
p2id += 2
spline.Message(c4d.MSG_UPDATE)
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment