Selecting Faces (EditableMesh/Poly)

 
 
 
Posted by:Vincentt
Data created:28 December 2014

Hello,

 

I have 2 problems selecting faces. I currently have this:

 

           IINode node = iface.GetINodeByHandle(handle);

           if (node == null)

               return;

 

           iface.SelectNode(node, true);

 

           iface.CommandPanelTaskMode = TASK_MODE_MODIFY; //2

           IObject baseObjectRef = node.ObjectRef.FindBaseObject();

           

           if (baseObjectRef.SubObjectLevel != 4)

               baseObjectRef.ActivateSubobjSel(4, m_Global.XFormModes.Create());

 

           ITriObject triObj = (ITriObject)node.EvalWorldState(0, true).Obj.ConvertToType(0, m_Global.TriObjectClassID);

           var mesh = triObj.Mesh;

 

           MasterNode tempMasterNode = m_MasterNodeList[handle];

 

           IBitArray selectionArray = GetFacesBitArrayByID(treeNode.matID, tempMasterNode);

           if (selectionArray != null)

               mesh.FaceSel = selectionArray;

 

1st problem: ActivateSubobjSel method crashes Max when there are modifier on my node. Is there a way to go to the baseObject? Ignoring all the modifiers on top?

2nd problem: This code is working with EditableMesh object but doesn’t work very well with EditablePoly. I can change the ITriObject to IPolyObject so it works on EditablePoly but then it doesn’t work on EditableMesh. I was wondering though if it’s possible to make it work on these 2 base meshes without checking the baseObject first.

 

Thanks in advance,
Vin

AFAIK, ActivateSubobjSel is supposed to be called by Max itself. There should be some method in IInterface which allows you to set the sub-object selection. Can't really say anything about EditableMesh vs. EditablePoly as I haven't done much work with these two. Maybe separate handling is required for each.

Marsel Khadiyev (Software Developer, EPHERE Inc.)

Aha! Thanks for the quick reply :)

iface.SetSubObjectLevel(4, true); 

Seems to be the method I was looking for! It no longer crashes when there is a modifier but it doesn't go to the correct level yet. Do you know how I can 'select' the baseObject to then go to the correct subobject level?