Notifications
Clear all

[Closed] C++ Spline INode crashing max

Hi, I have started writing a Detach splines by shape function, which works. But after I use this function, if I try and open a different file, it will crash max. Code Below:

	ip = GetCOREInterface();
 	t = GetCOREInterface()->GetTime();
 
 	for (int i=0; i < ip->GetSelNodeCount(); i++){
 		INode *node = ip->GetSelNode(i);
 
 		Object *newObject = node->GetObjectRef();
 		BezierShape* bs = &((SplineShape*)newObject)->shape;
 
 		if(bs->SplineCount() > 1){
 			for(int j = 0; j < bs->SplineCount(); j++){
 				SplineShape *shape = (SplineShape*)GetSplineShapeDescriptor()->Create(0);
 				Spline3D* OldSpline = bs->GetSpline(j);
 				shape->shape.AddSpline(OldSpline);
 				shape->shape.InvalidateGeomCache();
 				shape->shape.UpdateSels();
 				INode *Splinenode = ip->CreateObjectNode (shape);
 				Splinenode->SetNodeTM(t, node->GetNodeTM(t));
 			}
 		}
 	}
 
 	ip->FlushUndoBuffer();
 	ip->RedrawViews(ip->GetTime());
 
 	ip->ClearNodeSelection(1);

I found out that if you get rid of the new Splinenode, then it won’t crash max. But I’ve used INode loads of times and never crashed before, so I believe its got something to do with the SplineShape, but got no clue what ! Got any ideas ??

EDIT:* Nevermind, found out it was a different plugin all together it just happened to be at the same time I used this code that the issue appeared.