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:
https://help.autodesk.com/view/3DSMAX/2017/ENU/?guid=__files_GUID_E59FCB9A_04C0_4228_9779_4FD74F2D35AD_htm

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):
    try:
        if self.__hash__() == other.__hash__():
            return True
        return False
    except:
        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):
    try:
        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

i find this : genguid()