3dsMax MSX/Python API skin influence question

Hello,

I’m looking for a way to check if an object is influencing a geometry as a skin influence. I know I can go through the list of influences in the geometries skin modifier(s), but for checking many influences against many skinned geometries, it seems this would scale poorly.

I have MaxScript and MaxPlus Python API at my disposal.

Thanks,
Sune

I’m tackling this right now:

def getSkinnedNodeInfluences(iNode):
    for i in xrange(iNode.GetNumModifiers()):
        modifier = iNode.GetModifier(i)
        # print 'Modifier: {}
	Class_ID:{}
	References: {}'.format(modifier.GetClassName(), modifier.GetClassID(), modifier.GetNumRefs())
        if modifier.GetClassName() == 'Skin':
            for j in xrange(modifier.GetNumRefs()):
                ref = modifier.GetReference(j)
                if ref is not None and ref.GetClassName() == 'Node':
                    influence = MaxPlus.INode.GetINodeByName(ref.GetNodeName()) # this is dangerous, would need to cross check with handle
                    yield influence

In your case I think passing both lists and cross referencing might be more efficient.

Hi, thanks for the reply!

This is how I’m currently doing it myself:

def find_influences(geometry):
    influence_list = list()

    for i in range(geometry.GetNumModifiers()):
        mod = geometry.GetModifier(i)

        if mod.ClassID != MaxPlus.ClassIds.Skin:
            continue

        for ref in mod.Refs:
            if not ref:
                continue

            if ref.ClassID != MaxPlus.ClassIds.NodeObject:
                continue

            for subref in ref.Refs:
                if not subref:
                    continue

                if subref.SuperClassID == 16 or subref.SuperClassID == 80:
                    influence_list.append(MaxPlus.INode.FindNodeFromBaseObject(subref))

    return influence_list

Very similar, but I use some extra steps to get there.

In praxis I look through all geometries in the scene and build a dictionary where any influence becomes a key and the where the values are lists of geometry affected by a given influence:

skin_map[influence_a.handle] = [geom_a, geom_c, geom_d]

Now lookup is fast, but creating the dict is still too slow… It looks like MaxScript can go “The Other Way”, where you ask “what something influences”, rather than “what influences something”. I will pull the the old EvalMaxScript and report back :slight_smile:

This is how I would do it:


def findSkinInfluences(node):
    influence_list = list()
    for mod in node.Modifiers:
        if mod.ClassID == MaxPlus.ClassIds.Skin:
            for ref in mod.Refs:
                if ref:
                    if ref.ClassID == MaxPlus.ClassIds.NodeObject:
                        influence_list.append(MaxPlus.INode._CastFrom(ref))
    return influence_list

And Maxscript:


fn findSkinInfluences obj  = (
	influence_list = #()
	for objmod in obj.modifiers where (classof objMod == Skin) do (
		influence_list = for ref in (refs.dependsOn objmod) where (superclassof ref == GeometryClass) collect ref
	)
	influence_list
)

Thanks a lot Artur, I’ll test with _CastFrom and see if it’s faster!

It seems that MaxScript refs.dependents, will let me go the other way (Asking a influence, what is skinned to it, if anything). For my use case this might be way faster. Do any of you know, if there is an equivalent in the Python API (Asking what depends on an object, rather than what an object depends upon)?

B.t.w. I’d love any recommendations on Max API training material. I’m assuming it would be for either .Net or C++, I haven’t found any Python Training as of yet :slight_smile:

I took a peek at the SDK and there are far more members to the ReferenceTarget class. It seems Autodesk only wrapped part of this class for python.

Nice one, well patience is a virtue I guess :slight_smile:

I was doing the same thing and tried a bunch of different things, nothing works (the usual face to the wall MaxPlus situation)