Instance Exists

I know you can check if a node exists with render.isAncestorOf(), but what about checking for an instance of a class itself? In other words instanceExists().

Is there a function/method for checking if an instance of a user defined object class exists?

I made good use of such a function in past engines I’ve used. Ive come across need for it again an was just wonder if P3D had one…

An instance is simply a node with multiple parents. So depending on how you use your instances, it’s not straightforward. But in most cases, you can just use getParents to get a list of parents, assuming that those parents are the placeholder nodes that you use for the individual instances.

Note that rdb’s reply assumes you are using the word “instance” to refer to scene-graph instancing of nodes. If you are using “instance” in the object-oriented programming sense, then you are actually asking a question about Python, and not Panda3D specifically, and yes there are several ways to ask whether an instance exists in Python.

The precise answer for the Python question depends on what precisely you mean to ask–are you asking about whether a class definition with the given name exists in the current namespace, or whether an instance object with the given name exists, or whether an attribute of a class definition exists, or whether “self” has a particular attribute, or so on.