How to get only modifiers of current selection?

I'm trying to get the modifiers(morphs) of the current selected item (which is usually a cloth piece). Code looks like this:
 

var oNode=Scene.getPrimarySelection();
var oObj = oNode.getObject();	
var nShapes = oObj.getNumShapes();
for (var j=0; j < nShapes; j++) {
	var oShape = oObj.getShape(j);
	var nMod= oObj.getNumModifiers();
	for (var k=0; k < nMod; k++) {
		var oMod = oObj.getModifier( k );		
		//filter
		if(oMod.getTypeLabel()!="Morph") continue;		
		if(oMod.getValueChannel().isHidden()) continue;
		if(oMod.getValueChannel().isNumeric()==false) continue;

		//..
		//do something
	}
}

This works to get the modifiers. But when selecting a cloth item which is attached to a character the code returns as well morphs from the character. How can those be filtered to have only modifiers connected to the selected item?

Comments

  • PerttiAPerttiA Posts: 3,682

    The morphs from the character are usually hidden.

  • Stretch65Stretch65 Posts: 140

    Perhaps if you unfit / unparent the clothing from the character in your code?  Then refit after.

  • mikekmikek Posts: 170
    edited August 2021

    Thanks for the suggestions. Moving them out of the character would work but I have found another solution to filter them:
     

    if(oMod.getValueChannel().getNumControllers ()<=0) continue;

    The ones creating the issue aren't hidden but it looks like they don't have a controller set.

    Post edited by mikek on
Sign In or Register to comment.