Behaviour of MCOMMAND_JOIN diffrnt in R18 [SOLVED]



  • On 21/06/2017 at 06:19, xxxxxxxx wrote:

    Hi! The scene that you can download below contains a Null object with a bunch of polygon objects under it.
    I want to merge them into a single polygon object using MCOMMAND_JOIN, which works fine in R17, in
    R18 however, the result contains only the very first object instead of all objects.

    import c4d
      
    def join_objects(objs, doc) :
        print 'Joining', len(objs), 'objects'
        settings = c4d.BaseContainer()
        settings[c4d.MDATA_JOIN_MERGE_SELTAGS] = True
        result = c4d.utils.SendModelingCommand(
            c4d.MCOMMAND_JOIN, objs,
            c4d.MODELINGCOMMANDMODE_ALL, settings, doc)
        if not result:
            return None
        return result[0]
      
    obj = join_objects(op.GetChildren(), doc)
    doc.InsertObject(obj)
    c4d.EventAdd()
    

    Download 2017-06-21-plugincafe-jointest.c4d.

    Any idea what's going wrong in R18?



  • On 21/06/2017 at 08:38, xxxxxxxx wrote:

    Hi!
    In R18 MCOMMAND_JOIN works in a different manner than pre-R18.

    For more details see:
    https://plugincafe.maxon.net/topic/9836/13246_python-sendmodelingcommand&KW=&PID=52423#52423



  • On 21/06/2017 at 10:46, xxxxxxxx wrote:

    Thank you, no photo. Should've used the forum search first :-)

    Here's the updated join_objects() function

    def join_objects(root, doc) :
        children = root.GetChildren()
        set_status("Joining %d objects ..." % len(children), 50)
        # Pre-R18 we need to pass the list of objects to join.
        if c4d.GetC4DVersion() < 18000:
            source = children
        else:
            source = [root]
      
        settings = c4d.BaseContainer()
        settings[c4d.MDATA_JOIN_MERGE_SELTAGS] = True
        result = c4d.utils.SendModelingCommand(
            c4d.MCOMMAND_JOIN, source,
            c4d.MODELINGCOMMANDMODE_ALL, settings, doc)
        if not result:
            return None
        return result[0]
    

Log in to reply