THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 05/08/2012 at 14:06, xxxxxxxx wrote:
Hello everybody. Another problem here. A Phython XPresso node gets three object link inputs. All are spline objects. I want the Python script to merge the content of the first and the second one into number 3. However I don't want the separate splines to be removed.
I was thinking of cloning the objects, then using MCOMMAND_JOIN. But I want to merge them into the given object3 and not into a new object!
Maybe there's a different much easier way, without using MCOMMAND_JOIN?
Thanks for all your help!
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
# 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()
# add points to target spline
for id in range(0,p_inputct-1) :
p = inputspline.GetPoint(id)
# 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'])
On 06/08/2012 at 02:10, xxxxxxxx wrote:
Unfortunately I cannot edit my posts... I did some research on another spline object. Segments are the way to go, however just increasing the segment count and copying the segment0 data from the other splines doesn't work. Think I'm missing something. But currently I have no clue what it is.
On 06/08/2012 at 03:51, xxxxxxxx wrote:
It feels weird to be the only one posting in this thread, however I almost found a solution. When it's working I'll share it here so that everyone who might have this problem in future can use it.
The target spline now contains all separated input splines but now I have to calculate the spline points in relation to the target object's matrix. But I think it shouldn't be too hard to figure that out.
On 26/01/2013 at 02:40, xxxxxxxx wrote:
I got the same problem. Anyone an idea? What I have tried:
LONG splinePointCount= spline->GetPointCount();
LONG splineSegmentCount= spline->GetSegmentCount();
Vector* points = spline->GetPointW();
const Vector* newPoints = spline2->GetPointR();
for (int i = splinePointCount-1, k = 0; k < splinePointCount; k++, i++)
points[i] = newPoints[k];
Segment *segments = spline->GetSegmentW();
const Segment *newSegments = spline2->GetSegmentR();
for (int i = splineSegmentCount-1, k = 0; k < splineSegmentCount; k++, i++)
segments[i] = newSegments[k];
The result is not complete false: