Trouble with MCOMMAND_JOIN [SOLVED]

On 19/11/2014 at 14:39, xxxxxxxx wrote:

I'm trying to create a spline that is made up of many segments.
In the first generation, it creates a simple spline. In the following generations, I was trying to perform a "Connect" command between the first spline created and the newly created ones.
It is not working. I only get a single spline :-(
Here is my code:

**
first=True

set an empty spline

old_branch_spline=c4d.BaseObject(c4d.Ospline)
old_branch_spline.ResizeObject(0)

for br in range(branches) :
     # my spline calculation routine. It returns a list of vectors
     spline_points=Calculate_Spline()
     n_points=len(spline_points)

branch_spline=c4d.BaseObject(c4d.Ospline)
     branch_spline.ResizeObject(n_points)

for i,pt in enumerate(spline_points) :
          branch_spline.SetPoint(i,pt)

branch_spline.Message(c4d.MSG_UPDATE)

if first==True:
          old_branch_spline=branch_spline.GetClone()
          first=False
     else:
result=utils.SendModelingCommand(command=c4d.MCOMMAND_JOIN,list=[branch_spline,old_branch_spline],mode=c4d.MODIFY_ALL,bc=c4d.BaseContainer())
          if result is not False:
               old_branch_spline=result[0]
**

What could be wrong. Any help would be great.

Rui Batista

On 20/11/2014 at 10:38, xxxxxxxx wrote:

Hello,

the list argument is not used by MCOMMAND_JOIN. To define the objects you want to merge you have to create a parent/child hierarchy:

  
  nullObject = c4d.BaseObject(c4d.Onull)  
    
  spline_a.InsertUnder(nullObject)    
  spline_b.InsertUnder(nullObject)  
  
  res = c4d.utils.SendModelingCommand(command=c4d.MCOMMAND_JOIN,list=[nullObject])  

best wishes,
Sebastian

On 20/11/2014 at 13:48, xxxxxxxx wrote:

Thank you very much, Sebastian.
That should be stated clearly in the SDK.
I ended up doing the creation of the splines and segments by hand.
But I will have that information into account, next time.