Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    Merge selected polygons objects.

    Scheduled Pinned Locked Moved SDK Help
    6 Posts 0 Posters 598 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 22/08/2010 at 05:14, xxxxxxxx wrote:

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

      ---------
      Hi!

      I'm new (noob :D) developer  and i'm developing a little plugin to delete, with 1-click, all materials and merge all meshes for a specified selected object.

      I've no problems with materials, but I've trouble with "merge meshes" function. I can't find a usefull method to merge selected objects. With a recursive function I can select all interesting objects wich I want to merge, but after this operation what I can use to connect all objects? I'm working with AtomArray and GetSelection BaseDocument method but I can't figure out how I can obtain a new unique polygon object. So, I'm working with Modeling entity like this:

      AutoAlloc<AtomArray> curr_selection;
      AutoAlloc<Modeling> merged_model;
       
      doc->GetSelection(curr_selection);

      if(merged_model->InitArray(curr_selection)) {
        //Add Modeling object to my document...
      }

      I think that this isn't the correct way. I think that I have to working with BaseObject and not with Modeling entity, but I can't figure out how I can use the interesting my selection to create a new BaseObject.

      Many thanks, any help is appreciated.

      Bye

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 22/08/2010 at 06:23, xxxxxxxx wrote:

        Have a look at SendModelingCommand() and MCOMMAND_JOIN therein in the docs and here.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 22/08/2010 at 06:48, xxxxxxxx wrote:

          Nice, it work! I really missed the SendModelingCommand, sorry, I'm very newbee 😄 I'm starting to develop my plugin yesterday! Many thanks!

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 23/08/2010 at 11:29, xxxxxxxx wrote:

            Sorry, I noticed a problem probably stupid but I can not understand the problem. I've activated all interested objects on my scene and then I've called this code:

            AutoAlloc<AtomArray> curr_selection;
              ModelingCommandData modeling_comm;

            doc->GetActiveObjects(curr_selection, true);
                
              modeling_comm.arr = curr_selection;

            if(!SendModelingCommand(MCOMMAND_JOIN, modeling_comm))
                  MessageDialog(ERR_MRG);

            BaseObject* merged_obj = static_cast<BaseObject*>(modeling_comm.result->GetIndex(0));
              doc->InsertObject(merged_obj, NULL, root);

            I'm sure that the selection contains ONLY the selected objects that I want (I've printed the curr_selection content) but the merged_obj returned by modeling_comm.result contains a merged object for the entire scene!! I'm wrong in the ModelingCommandData use?

            Many thanks!

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 23/08/2010 at 11:54, xxxxxxxx wrote:

              AutoAlloc<> returns a POINTER.  GetActiveObjects wants a reference.  Call it like this:

              doc->GetActiveObjects(*curr_selection,  TRUE);

              Just double checked my own code, and, indeed, that is how I always do it.

              You may also want to set modeling_comm.doc = doc for completeness.

              Finally, if none of these is the issue, then it may be the types of objects you are attempting to join.  JOIN only works on Polygon objects (maybe Spline objects in their own regard) as far as I know.  You might need to prepare procedural objects first (Make Editable).

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 23/08/2010 at 14:03, xxxxxxxx wrote:

                Thanks for your quick response.

                For the reference you have reason, but this kind of mistake should be warned from the compiler...but no...in any case this is not the problem. Yes, I've already inserted the modeling_comm.doc = doc. The problem is on the GetActice* call. Must be GetActivePolygonsObjects and not GetActiveObjects. I was misled by the fact that when I selected all the objects in c4d (including null objects), the "Connect" function works fine but, of course, on low level will identify evidently the polygonal objects only.

                Ok, the objects join works fine but now the merged object is moved in a different position than the originals objects...I'm looking into setPos and helperAxis...I think that I can fix the position but for the axis I have to look the axis operations...

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post