Notifications
Clear all

[Closed] Reading all the objects in the scene 3ds Max SDK C++

How do I read the names of all the groups and objects in the group from the scene?

Also if there are good tutorials to 3ds Max SDK C++ tutorial do share the link.

Thanks.

1 Reply

this is how i do it…


class INodeEnum
{
public:
    virtual BOOL proc(INode *node) = 0;
    virtual ~INodeEnum() {}
};

typedef BOOL (*GetObjectTypeFnPtr)(Object* obj);

class CollectObjectsOfType : public INodeEnum
{
public:

    GetObjectTypeFnPtr GetTypeFn;
    INodeTab nodes;
    
    CollectObjectsOfType(GetObjectTypeFnPtr fn, i) : GetTypeFn(fn) { }
    BOOL proc(INode *node)
    {
        Object* obj = node->GetObjectRef();
        if(obj && GetTypeFn(obj))
            nodes.AppendNode (node);
        return TRUE;
    }
};

BOOL INodeEnumTree(INode *node, INodeEnum& enumerator) 
{
    if(node == NULL) return TRUE;
    if(!enumerator.proc(node)) return FALSE;

    for(int i = 0; i < node->NumberOfChildren(); ++i) 
        if(!INodeEnumTree(node->GetChildNode(i), enumerator)) 
            return FALSE;
    return TRUE;
}

// this function can test any aspect of the object such as class id or superclass id or as in this case use one of the built in object functions

BOOL isShapeObject(Object* obj) { return obj->IsShapeObject(); }


CollectObjectsOfType  ShapeNodeCollector (isShapeObject);
INodeEnumTree(ip->GetRootNode(), ShapeNodeCollector);