THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/08/2012 at 01:48, xxxxxxxx wrote:
Half done. I found the "manual" way to join all spline objects. However currently it creates just one spline using all points I create. Still have to find a way to separate these. Also the first spline point always has the position 0|0|0 (the first points of the input splines are not at 0|0|0).
Think one part is still missing. Currently I think it's the segments. By now I couldn't find out how they work. All the separate splines have a segment count of 0. If I increase segment count on the target object, it will just create points but no splines. Using just one segment it connects all points.
This is the relevant code:
def Join2(lst, targetspline) :
# empty target spline
targetspline.ResizeObject(0)
# add the points of each input spline
for inputspline in lst:
# allocate space for new points
p_targetct = targetspline.GetPointCount()
p_offset = p_targetct
p_inputct = inputspline.GetPointCount()
p_newct = p_targetct + p_inputct
# allocate space for new segments
s_targetct = targetspline.GetSegmentCount()
s_offset = s_targetct
s_inputct = inputspline.GetSegmentCount() + 1
s_newct = s_targetct + s_inputct
t_targetct = targetspline.GetTangentCount()
t_offset = t_targetct
t_inputct = inputspline.GetTangentCount()
print "p_targetct:"+`p_targetct`
print "p_inputct:"+`p_inputct`
print "s_targetct:"+`s_targetct`
print "s_inputct:"+`s_inputct`
print "t_inputct:"+`t_inputct`
targetspline.ResizeObject(p_newct, s_newct)
# add points to target spline
for id in range(0,p_inputct-1) :
p = inputspline.GetPoint(id)
targetspline.SetPoint(p_offset+id, p)
# add segments to target spline
for id in range(0,s_inputct-1) :
s = inputspline.GetSegment(id)
targetspline.SetSegment(s_offset+id, s['cnt'], s['closed'])
# add tangents to target spline
for id in range(0,t_inputct-1) :
t = inputspline.GetTangent(id)
targetspline.SetTangent(t_offset+id, t['vl'], t['vr'])
targetspline.Message(c4d.MSG_UPDATE)
return;