Notifications
Clear all

[Closed] CanConvertToType for editable spline C++

I’m changing around the collapes stack function but when I come across Shapes (SHAPE_CLASS_ID) I would like to collapes then to editable Splines. Can’t not sure what one is it’s ConvertToType


void PolyTools::CollapseSpline(INode *node){
	ICustAttribCollapseManager * iCM = ICustAttribCollapseManager::GetICustAttribCollapseManager();
	ShapeObject *tobj = NULL;
	//TriObject *tobj = NULL;
	Object *oldObj = node->GetObjectRef();

	bool ignoreBaseObjectCAs = false;
	if(iCM && iCM->GetCustAttribSurviveCollapseState()){
		NotifyCollapseMaintainCustAttribEnumProc2 PreNCEP(true,node);
		EnumGeomPipeline(&PreNCEP,oldObj);
	}
	else{
		NotifyCollapseEnumProc PreNCEP(true,node);
		EnumGeomPipeline(&PreNCEP,oldObj);
	}
	ObjectState os = oldObj->Eval(ip->GetTime());
	HoldSuspend hs; 
	Object *obj = (Object*)os.obj->CollapseObject();
	if(obj == os.obj){
		Object *theBaseObject = oldObj->FindBaseObject();
		if (obj == theBaseObject)
			ignoreBaseObjectCAs = true;
			obj = (Object*)CloneRefHierarchy(obj);
	}
	hs.Resume();
	if (os.obj->CanConvertToType(splineObjectClassID)) {
		// Convert it to a TriObject and make that the new object
		tobj = (ShapeObject*)obj->ConvertToType(ip->GetTime(),splineObjectClassID);
	}
	if (tobj != obj)
		ignoreBaseObjectCAs = false;
	oldObj->SetAFlag(A_LOCK_TARGET);
	node->SetObjectRef(tobj);		
	GetCOREInterface7()->InvalidateObCache(node);
	node->NotifyDependents(FOREVER, 0, REFMSG_SUBANIM_STRUCTURE_CHANGED);

	if(iCM && iCM->GetCustAttribSurviveCollapseState()){
		NotifyCollapseMaintainCustAttribEnumProc2 PostNCEP(false,node,ignoreBaseObjectCAs,tobj);
		EnumGeomPipeline(&PostNCEP,oldObj);
	}
	else{
		NotifyCollapseEnumProc PostNCEP(false,node,tobj);
		EnumGeomPipeline(&PostNCEP,oldObj);
	}
	oldObj->ClearAFlag(A_LOCK_TARGET);
	oldObj->MaybeAutoDelete();
					
	if (obj!=tobj) obj->MaybeAutoDelete();

	ip->RedrawViews(ip->GetTime());
}

1 Reply

Never mind I found it
os.obj->CanConvertToType(splineShapeClassID)) {