Maxscript create guid

Hi all, is it possible to generate a guid through maxscript?

Not that I am aware of. You can use the .NET System.Guid.NewGuid() method.

thanks I ended up using MaxPlus and uuid lib,
but thanks anyway

You can generate a new class ID:

Hey elpie89,

This is something I did a while ago that might help. I’m assuming your goal is to make types hashable for testing membership in a list/set.

def __INode_eq__(self, other):
        if self.__hash__() == other.__hash__():
            return True
        return False
        return False

MaxPlus.INode.__eq__ = __INode_eq__

def __INode_hash__(self):
    return hash(self.GetHandle())

MaxPlus.INode.__hash__ = __INode_hash__

I’d probably change this to:

def __INode_eq__(self, other):
        return isinstnace(other, MaxPlus.INode) and hash(self) == hash(other)
    except TypeError:
        return False

Mostly because it avoids the bare except and I like to double check that the instances at least share some parent type.

Also, its good practice to use the protocol’s function instead of calling the dunder method directly.

1 Like