Notifications
Clear all

[Closed] SDK: Select INode on creation

Hi.
I’m trying to detach parts of the poly object into new nodes and select newly created nodes in case if base object was initially selected.
My problem is that in 2020 max I can’t select detached object without crashing max.
Is there anything critical that should be done before attempting to select a node? Maybe some notifications?

a piece of C#

IPolyObject out_poly = GlobalInterface.Instance.PolyObject.Create();

if ( mesh.DetachElementToObject( out_poly.Mesh, MN_SEL, true ) )
{
	IPolyObject poly = (IPolyObject)out_poly.ConvertToType( t, PolyClassID );
	IObject obj = poly.CollapseObject;

	node = GlobalInterface.Instance.COREInterface.CreateObjectNode( obj );
	node.ObjectRef = obj;

	// not working in 2020, but ok in 2014
	//if ( initial_node.Selected ) GlobalInterface.Instance.COREInterface.SelectNode( node, false );
}