Notifications
Clear all

[Closed] SDK Convert to Editable Mesh

Hi, I need to be about to convert a object into a Editable Mesh. I need to be able to attach objects, but my attach won’t work unless the first object is a Editable Mesh. The Code below is able to convert it to TriObject, but Im not sure what to do to convert it to Editable Mesh.

void PolyTools::ConvertShape(){
    	ip = GetCOREInterface();
    	INode* nodeTab;
    	   nodeTab = ip->GetSelNode(0));
    
    	Object *obj = nodeTab->EvalWorldState(TimeValue(0)).obj;
    
    	TriObject *meshObj = (TriObject*)obj->ConvertToType(TimeValue(0), triObjectClassID);
    	TriObject* newObj = CreateNewTriObject();
    	newObj->mesh = meshObj->mesh;
    
    	nodeTab.Delete(TimeValue(0), TRUE);
    	
    }

Edit* I was able to fix it. I forgot to set the Objects ref to the new object. Code is below incase anyone else have the same issue.

void PolyTools::ConvertShape(){
 	ExecuteMAXScriptScript(_T("print \"Tri\""), 0, 0);
 	ip = GetCOREInterface();
 	INodeTab nodeTab;
 	for (auto i = 0; i < ip->GetSelNodeCount(); i++){
 		nodeTab.AppendNode(ip->GetSelNode(i));
 	}
 
 	Object *obj = nodeTab[0]->EvalWorldState(TimeValue(0)).obj;
 
 	 TriObject *meshObj = (TriObject*)obj->ConvertToType(TimeValue(0), triObjectClassID);
 
 	 nodeTab[0]->SetObjectRef(meshObj);
 	 Matrix3 ntm = nodeTab[0]->GetNodeTM(ip->GetTime());
 	 nodeTab[0]->SetNodeTM(ip->GetTime(),ntm);
 	 
 	 nodeTab.Delete(TimeValue(0), TRUE);
 	 ip->RedrawViews(ip->GetTime());
 	
 }