Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

ConvertToPoly in SDK

ConvertToPoly in SDK

Anonymous
Not applicable
555 Views
1 Reply
Message 1 of 2

ConvertToPoly in SDK

Anonymous
Not applicable

I'm having a hard time finding answers to simple things in the SKD. 

 

Like doing actions in maxscript...

 

macros.run "Modifier Stack" "Convert_to_Poly"
or
ConvertToPoly $

 

I have been working with

ip = GetCOREInterface();
TimeValue t = GetCOREInterface()->GetTime();

int Node_Count;
Node_Count = ip->GetSelNodeCount();
Object *N_obj[100];

for (int i = 0; i < Node_Count; i++){ 
	INode *node = ip->GetSelNode(i);
	Object *obj = node->EvalWorldState(t).obj;
	if (obj->CanConvertToType(Class_ID(POLYOBJ_CLASS_ID, 0))){
		obj->ConvertToType(t, defObjectClassID);
		PolyObject * PolyObj = (PolyObject *)obj;
		MNMesh *pmesh = &PolyObj->GetMesh();

	}
}

 or

 

for (int i = 0; i < Node_Count; i++){ 
	INode *node = ip->GetSelNode(i);
	Object *obj = node->EvalWorldState(t).obj;
	Object *New_obj = obj->CollapseObject();
}

 

The first looks like it gets me down to a mesh level.  But does not "ConvertToType(t, defObjectClassID);"

 

Any ideas any thoughts?

0 Likes
556 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

ok, sorted

 

ip = GetCOREInterface();
TimeValue t = GetCOREInterface()->GetTime();

int Node_Count;
Node_Count = ip->GetSelNodeCount();

for (int i = 0; i < Node_Count; i++){ 
	INode *node = ip->GetSelNode(i);
	Object *obj = node->EvalWorldState(t).obj;
	if (obj && obj->CanConvertToType(Class_ID(POLYOBJ_CLASS_ID, 0))){
		PolyObject *pObj = (PolyObject *)obj->ConvertToType(t, Class_ID(POLYOBJ_CLASS_ID, 0));
		Object* cObj = pObj->CollapseObject();
		INode *NewNode = ip->CreateObjectNode(cObj);
	}
	ip->RedrawViews(ip->GetTime());
}

 

0 Likes