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

    Split PolygonObject from multiple Selections

    Scheduled Pinned Locked Moved SDK Help
    5 Posts 0 Posters 417 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 17/05/2011 at 15:48, xxxxxxxx wrote:

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

      ---------
      Hi All,

      here my first question:
      How to split a PolgonObject with multiple PolygonSelection-Tags (for Materials) into multiple PolygonObjects?

      Here my start.

      void Walk(BaseObject *object)
      {
      	while (object)
      	{
      		if(object->GetType() == Tpolygon)
      		{
      			BaseTag *tag = object->GetFirstTag();
      			
      			while (tag)
      			{
      				if (tag->GetType() == Tpolygonselection)
      				{
      					SelectionTag *selectionTag = (SelectionTag * )tag;
      					BaseSelect *select = selectionTag->GetBaseSelect();
      					/*...
      						alloc new PolygonObjects, fill given data 
      					*/
      				}
      				tag = tag->GetNext();
      			}
        
      			if (object->GetDown()) 
      			{
      				//recursive walk
      				Walk(op->GetDown());
      			}
      			
      			object = object->GetNext();
      		}
      	}
      }
      

      Thanks,
      ToBSn

      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 17/05/2011 at 17:00, xxxxxxxx wrote:

        Select the polygons of the PolygonSelection and then use SendModelingCommand() to do a split.  Here is a convenience method which does it for you:

        PolygonObject* SplitObject(PolygonObject* op, SelectionTag* pstag)  
        {  
          // BaseSelect of Polygon Selection Tag  
          BaseSelect*        pbs =        pstag->GetBaseSelect();  
          if (!pbs)                            return NULL;  
          // BaseSelect of Polygon Object  
          BaseSelect*        bs =        op->GetPolygonS();  
          if (!bs)                            return NULL;  
          // Select Polygons on Polygon Object belonging to Polygon Selection Tag  
          if (!pbs->CopyTo(bs))    return NULL;  
          
          // Split selected polygons (tops) into new object  
          ModelingCommandData    mcd;  
          mcd.doc =                    NULL;  
          mcd.bc =                    NULL;  
          mcd.mode =                MODELINGCOMMANDMODE_POLYGONSELECTION;  
          mcd.flags =                MODELINGCOMMANDFLAGS_0;  
          mcd.op =                    op;  
          if (!(SendModelingCommand(MCOMMAND_SPLIT, mcd) && mcd.result))    return NULL;  
          PolygonObject*    top =    ToPoly(mcd.result->GetIndex(0L));  
          // - it is your responsibility to free the 'result' AtomArray returned in 'mcd'!  
          AtomArray::Free(mcd.result);  
          return top;  
        }
        
        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 18/05/2011 at 01:14, xxxxxxxx wrote:

          Just btw: If a non-polygonobject is parsed, you will never ever leave the while-loop.

          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 18/05/2011 at 01:34, xxxxxxxx wrote:

            @kuroyume0161
            Very cool, thank you. Clever idea to use the modeling command. 🙂

            @nux95
            a yeah, thats right. 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 18/05/2011 at 08:21, xxxxxxxx wrote:

              To avoid the infinite while-loop just move the line "object = object->GetNext();" outside of the if() block.

              SendModelingCommand() is your friend ... most of the time but depending upon its mood. 🙂

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