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

    Edge To Spline Modeling Command

    Cinema 4D SDK
    sdk r20 c++
    2
    3
    704
    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.
    • J
      JohnThomas
      last edited by

      Hello,

      I have a polygon object with an Edge Selection tag associated with it that has a selection of edges. Independently browsing through the selection tag I know that it contains the edges that it should.

      When I try to use SendModelingCommand to have Cinema return the spline of these selected edges it always fails with SendModelingCommand returning false.

      if (op->GetDown() != nullptr)
      {
      	PolygonObject *poly = (PolygonObject*)op->GetDown();
      	if (poly == nullptr)
      		return nullptr;
      	PolygonObject *clonePoly = (PolygonObject*)poly->GetClone(COPYFLAGS::NONE, nullptr);
      	if (clonePoly == nullptr)
      		return FALSE;
      	if (neighbor.Init(clonePoly->GetPointCount(), polyArray, clonePoly->GetPolygonCount(), nullptr))
      	{
      		clonePoly->SetSelectedEdges(&neighbor, edgeselectionTag, EDGESELECTIONTYPE::SELECTION);
      				
      		AutoAlloc<BaseDocument> tempDoc;
      		ModelingCommandData cd;
      		BaseContainer bc = BaseContainer();
      		cd.doc = tempDoc;
      		cd.bc = &bc;
      		cd.op = clonePoly;
      		if (!SendModelingCommand(ID_MODELING_EDGE_SPLINE_COMMAND, cd))
      		{
      			return FALSE;
      		}
      	}
      }
      

      I looked through some forums posts and through the sdk and I don't understand why the SendModelingCommand is always returning false.

      Any help would be greatly appreciated.

      John Thomas

      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by

        hi,

        you should use the command ID MCOMMAND_EDGE_TO_SPLINE and not ID_MODELING_EDGE_SPLINE_COMMAND

        One remark to your code, you are returning both nullptr and FALSE.
        That's kind of strange.

        You should have a look at our error handling system. It's a bit scary at the beginning but it's really powerful and useful for debugging.

        static maxon::Result<BaseObject*> pc12903(BaseDocument* doc)
        {
        	iferr_scope;
        	CheckArgument(doc != nullptr);
        	BaseObject* op = doc->GetActiveObject();
        
        	if (op == nullptr)
        		return nullptr; // not an error for me.
        	
        	PolygonObject* clonePoly = static_cast<PolygonObject*>(op->GetClone(COPYFLAGS::NONE, nullptr));
        		
        	if (clonePoly == nullptr)
        		return maxon::NullptrError(MAXON_SOURCE_LOCATION);
        
        	ModelingCommandData cd;
        
        	BaseContainer bc = BaseContainer();
        	cd.doc = nullptr; // this command in particular doesn't need any document.
        	cd.bc = &bc;
        	cd.op = clonePoly;
        	if (!SendModelingCommand(MCOMMAND_EDGE_TO_SPLINE, cd))
        	{
        		return maxon::UnknownError(MAXON_SOURCE_LOCATION);
        	}
        	BaseObject* spline = clonePoly->GetDown();
        	if (spline == nullptr)
        		return maxon::NullptrError(MAXON_SOURCE_LOCATION);
        	spline->Remove(); // just to be sure
        	return spline;
        }
        

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • J
          JohnThomas
          last edited by

          Thanks for the response, that was exactly what I needed.

          John Thomas

          1 Reply Last reply Reply Quote 0
          • i_mazlovI i_mazlov referenced this topic on
          • First post
            Last post