Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    MCOMMAND_CONVERTSELECTION [SOLVED]

    SDK Help
    0
    5
    482
    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
      Helper
      last edited by

      On 02/07/2015 at 09:35, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   R16 
      Platform:      Mac OSX  ; 
      Language(s) :     C++  ;

      ---------
      Hi,

      I'm trying to convert a selection from edge-mode to point-mode.
      Here is what I've got so far:

        
          
          
          BaseContainer bc;  
          bc.SetInt32(MDATA_CONVERTSELECTION_LEFT, 1);  
          bc.SetInt32(MDATA_CONVERTSELECTION_RIGHT, 0);  
          bc.SetBool(MDATA_CONVERTSELECTION_TOLERANT, false);  
          ModelingCommandData cd;  
          cd.doc = doc;  
          cd.arr = selection;  
          cd.bc = &bc;  
          if (!SendModelingCommand(MCOMMAND_CONVERTSELECTION, cd))  
          {  
            return false;  
          }  
          EventAdd();
      

      Is it normal that this doesn't update visually?
      And if so, what do I have to do to make it visible?

      Greetings,
      Casimir Smets

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

        On 02/07/2015 at 10:01, xxxxxxxx wrote:

        After SendModelingCommand(), update the objects involved:

        for (Int32 x = 0; x < selection->GetCount(); x++)
        {
             BaseObject *op = static_cast<BaseObject*>(selection->GetIndex(x));
             if (!op) continue;
             op->Message(MSG_UPDATE);
        }
        

        It is also possible that MCOMMAND_CONVERTSELECTION in SendModelingCommand() does not handle multiple objects like the Convert Selection command does.  Try it with one object, setting cd.op instead of using a selection in cd.arr to confirm its behavior.

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

          On 02/07/2015 at 11:54, xxxxxxxx wrote:

          Hi Robert,

          I've tried everything you said, with no results :s
          Here is my last piece of code:

          for (Int32 x = 0; x < selection->GetCount(); x++)
          {
            BaseContainer bc;
            bc.SetInt32(MDATA_CONVERTSELECTION_LEFT, 1);
            bc.SetInt32(MDATA_CONVERTSELECTION_RIGHT, 0);
            bc.SetInt32(MDATA_CONVERTSELECTION_TOLERANT, false);
            ModelingCommandData cd;
            cd.doc = doc;
            cd.op = static_cast<BaseObject*>(selection->GetIndex(x));
            cd.bc = &bc;
            if (!SendModelingCommand(MCOMMAND_CONVERTSELECTION, cd))
                return false;
            op = static_cast<BaseObject*>(selection->GetIndex(x));
            if (!op) return false;
            op->Message(MSG_UPDATE);
          }

          But this seems to do nothing :s

          Thanks for your help and time!
          With kind regards,
          Casimir Smets

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

            On 02/07/2015 at 13:21, xxxxxxxx wrote:

            I just tried it with one object and it works great.  Remember that to see the resulting conversion in the viewport, you will need to set the document mode (SetMode()) to be Mpoints.  Here is a quick test (using a button in a dialog from a CommandData to do the conversion) :

            //*---------------------------------------------------------------------------*
            void MIDialog::RunCommand()
            //*---------------------------------------------------------------------------*
            {
            	BaseDocument*	doc =	GetActiveDocument();
            	BaseObject*		op =	doc->GetActiveObject();
            	if (!op)
            	{
            		GePrint("Test_Command.MIDialog.RunCommand.op");
            		return;
            	}
            	BaseContainer bc;
            	bc.SetInt32(MDATA_CONVERTSELECTION_LEFT, 1);
            	bc.SetInt32(MDATA_CONVERTSELECTION_RIGHT, 0);
            	bc.SetBool(MDATA_CONVERTSELECTION_TOLERANT, false);
            	ModelingCommandData cd;
            	cd.doc = doc;
            	cd.op = op;
            	cd.bc = &bc;
            	if (!SendModelingCommand(MCOMMAND_CONVERTSELECTION, cd))
            	{
            		GePrint("Test_Command.MIDialog.RunCommand.SendModelingCommand");
            		return;
            	}
            	op->Message(MSG_UPDATE);
            	doc->SetMode(Mpoints);
            	EventAdd();
            }
            
            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              On 03/07/2015 at 05:24, xxxxxxxx wrote:

              Hi Robert,

              Thanks for your answer!
              That indeed did it!

              This thread can be marked as solved!

              With kind regards,
              Casimir Smets

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