Melange_Xpresso Node Data [SOLVED]



  • On 20/10/2016 at 08:03, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   Melange 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    Hi,
    Ive written an application that transfers the UserData from one object to another using Melange.
    I'm copying and pasting the source xpresso tag to the target object. But when I do this the object node loses it's link to the object.

        BaseTag *xTagSource = sourceObject->GetTag(Texpresso);  
      
      //Create a copy of the tag on the target objects  
      BaseTag *xTagTarget = targetObject->MakeTag(Texpresso);  
      
      //Copy the source tag's node data to the new one  
      xTagSource->CopyTo(xTagTarget, COPYFLAGS_0, nullptr);
    

    So I need to go into the tag and reset the object.
    But the problem is I don't see the XPressoTag class. Or anything like it in the Melange SDK that allows me to edit xpresso nodes.

    Is there any way to do this in Melange?
    Would the AliasTransfer option in CopyTo() possibly help me carry over the linked object?

    -ScottA



  • On 24/10/2016 at 02:09, xxxxxxxx wrote:

    Hi ScottA, thanks for writing us.
    I've tried to reproduce your example but I think I don't completely understand what you mean by "the object node loses its link to the object. So I need to get into the tag and reset the object".

    Implementing the code below and using a test scene attached here didn't helped me to reproduce the issue.

      
    int main(int argc, Char* argv[])  
    {  
     // Path to the scene to scan.  
     const String file = ".\\testscenes\\XpressoNodeDataSource.c4d";
      
     // Load the scene document.  
     BaseDocument *c4dDoc = LoadDocument(file, SCENEFILTER_OBJECTS);  
     if (!c4dDoc)  
    return -1;
     BaseObject* currentObj = c4dDoc->GetFirstObject();
     if (nullptr == currentObj)  
    return -1;  
       
     // Retrieve the Xpresso node tag on source.  
     BaseTag *xTagSource = currentObj->GetTag(Texpresso);  
     if (nullptr == xTagSource)  
    return -1;
      
     // Create a new object.  
     BaseObject* newObj = BaseObject::Alloc(Osphere);  
     if (nullptr == newObj)  
    return -1;
      
     //Create a new Xpresso tag on the new object.  
     BaseTag *xTagTarget = newObj->MakeTag(Texpresso);  
     if (nullptr == xTagTarget)  
     {   
    BaseObject::Free(newObj);  
    return -1;  
     }
      
     //Copy the source tag's node data to the new one.  
     xTagSource->CopyTo(xTagTarget, COPYFLAGS_0, nullptr);
      
     // Insert the newly created object.  
     c4dDoc->InsertObject(newObj, nullptr, currentObj);
      
     // Remove the source object from the scene.  
     currentObj->Remove();  
     BaseObject::Free(currentObj);  
     currentObj = nullptr;
      
     // Save the scene with both object on file.  
     SaveDocument(c4dDoc, ".\\testscenes\\XpressoNodeDataDest.c4d", SAVEDOCUMENTFLAGS_0);
     return 0;  
    }  
    

    Beware that although Melange SDK hasn't a speciliazed XpressoTag node class the BaseTag class is still there providing some basic functionalities to manage tags.

    Hoping this shed light on your issue, give best.
    Riccardo



  • On 24/10/2016 at 07:43, xxxxxxxx wrote:

    Hi Riccardo,
    Thanks for the help.

    Using your code and the example file provided. Add one simple User Data item to the cube.
    Something simple like a float slider is enough.
    Then use the Set Driver/Set Driven options to create an xpresso tag that has nodes that connect the host object with that tag to drive the UD slider.
    Then please  try your code again and see what happens.
    When I do this. The Object node in xpresso ends up being empty and broken (yellow colored header).
    It looks like there's a bug with handling UserData in the CopyTo() function. Or maybe it's not yet supported in the SDK?

    If xpresso was supported Melange SDK like it is in the C4D SDK. I could go in there and set the object link to the host object manually. But of course it would be better if the CopyTo() function copied the UD automatically.

    -ScottA

    *Edit
    Here is an example with the copy User Data code in it.
    The problem is that on the new object inside of the new document. The "Object" xpresso node is empty and broken (yellow).
    I don't know if this happening from a bug, or UD not being supported, or if the way I'm copying the User Data from the source object to the target object is wrong?

    int main(int argc, Char* argv[])  
    {  
      // Path to the scene to scan.  
      const String file = "C:\\Users\\user\\Desktop\\source.c4d";  
      
      //Load the scene document  
      BaseDocument *c4dDoc = LoadDocument(file, SCENEFILTER_OBJECTS);  
      if (!c4dDoc) return -1;  
      
      //Load the first object in the scene  
      BaseObject *currentObj = c4dDoc->GetFirstObject();  
      if (nullptr == currentObj) return -1;  
      
      //Get the User Data on the source object  
      DynamicDescription *sourceUD = nullptr;  
      sourceUD = currentObj->GetDynamicDescription();  
      
      //Retrieve the Xpresso node tag on the source object  
      BaseTag *xTagSource = currentObj->GetTag(Texpresso);  
      if (nullptr == xTagSource) return -1;      
      
      //Create a new object  
      BaseObject *newObj = BaseObject::Alloc(Osphere);  
      if (nullptr == newObj) return -1;  
      
      //Copy the UserData from the source object to the target object  
      DynamicDescription *targetUD = newObj->GetDynamicDescription();  
      sourceUD->CopyTo(targetUD);  
      
      //Create a new Xpresso tag on the new object  
      BaseTag *xTagTarget = newObj->MakeTag(Texpresso);  
      if (nullptr == xTagTarget)  
      {  
          BaseObject::Free(newObj);  
          return -1;  
      }  
      
      //Copy the source tag's data to the new one  
      xTagSource->CopyTo(xTagTarget, COPYFLAGS_0, nullptr);  
      
      //Insert the newly created object  
      c4dDoc->InsertObject(newObj, nullptr, currentObj);  
      
      //Remove the source object from the scene  
      currentObj->Remove();  
      BaseObject::Free(currentObj);  
      currentObj = nullptr;  
      
      //Save the scene with both object on file.  
      SaveDocument(c4dDoc, "C:\\Users\\user\\Desktop\\dest.c4d", SAVEDOCUMENTFLAGS_0);  
      return 0;  
    }
    


  • On 25/10/2016 at 07:15, xxxxxxxx wrote:

    Hi ScottA,
     following the steps you pointed out i've reproduced the issue reported and, getting back to your initial post, i confirm that since Melange doesn't expose the XpressoTag interface you can't relink the driving UserData parameter belonging to the source object to the new one created in the destination object.
    It should also be noted that the CopyTo() method is actually working properly since, as long as you don't remove the source object in the scene, the Xpresso relationships are properly maintained through the copy operation. Obviously the CopyTo() method can't be informed about the fact that the UserData in the new object is the one that is expected to replace the UserData in the old object in the Xpresso hierarchy even if it was previously copied from it.

    Best, Riccardo.

    Edit: PS Copying the whole BaseObject copies both the UserData parameters as well as the Xpresso tag which in this case are pointing to the newly copied UserData params.



  • On 25/10/2016 at 07:23, xxxxxxxx wrote:

    OK. Thanks.
    I guess I've hit a limitation that is not supported. 😢
    At least I know that I'm not doing it wrong.
    Hopefully Maxon can implement some way to make this possible at some point.

    BTW: If you would like to try out my application you can get it here:
    http://www27.zippyshare.com/v/IzW8hymU/file.html

    I'm not really sure if my application is using Melange as it was intended to be used or not.
    I've always been a bit fuzzy on when/how to use Melange.
    But it sure is a lot of fun using it in combo with Qt this way.

    -ScottA



  • On 25/10/2016 at 07:34, xxxxxxxx wrote:

    Thanks indeed for sharing ScottA! Consider that Melange has been mostly designed to deliver the Cineware integration and to provide some effective means to integrate Cinema in architectural design pipelines.
    I'll keep you informed if I hit a solution.

    Best, Riccardo


Log in to reply