Interrogate does not publish PMaps or PVectors..?

I’ve tried literally everything. And no matter what i do. The values (Map or Vectors) don’t publish and aren’t visible or accessible in Python at all. Any suggestions?

Normally, types are only exported if they have methods marked “PUBLISHED”. This is not the case for pvector and pmap. Templates need to be explicitly instantiated, too.

To force a type to be instantiated even without this, create a .N file in which you use “forcetype” to force the type to be wrapped. See the forcetype instructions in the .N files strewn about the Panda source.

Oh thanks! I’ll be sure to look into that.

EDIT: It seems any instructions are long gone from what i see. Searched the entire repo and none are around…

^ Bump

Here’s an example: … mathutil.N

From the looks of it. forcetype is used to publish a classes as PointerTo is also a class in the Panda3D engine i’m sure of… But thanks anyways i changed what i was doing to a get and set function. But it’d still be nice to figure it out for the possible future.

I finally understand what you meant by ‘force a type to be instantiated’ after all this time due to the big jump of experience I’ve had since then. Well thanks for the help. Good to know you have to instantiate them explicitly.

Thanks for the help. :laughing:


I just encountered the same problem. I have a class (example.h) with a pvector<LPoint2d> member variable and I am not able to publish the pvector. As far as I understand I have to create an example.N file and force pvector to be instanciated.


#include <pandabase.h>
#include <lpoint2.h>
#include <pvector.h>

class ExampleClass
    pvector<LPoint2d> mPoints;


forcetype pvector<LPoint2d>
forcetype pvector<LVecBase2d> 

I am able to see mPoints from python but I get following error/warning when accessing mPoints:

Detected leak for pvector_LPoint2d which interrogate cannot delete.
<class ‘TestModule.pvector_LPoint2d’>

So what does forcetype do exactly and how do I use it correctly?

I would suggest that instead of a pvector you use a PTA_LVecBase2d in this case, which is wrapped by interrogate and reference-counted for proper memory management. The interface is similar to a vector, and this class will automatically allow a list to be converted. It is included from pta_LVecBase2.h.

I am not sure if forcing a pvector instantiation to be wrapped is enough because the constructor, destructor, etc. are not marked published, leading interrogate to be unable to manage their lifetime properly.

That seems to publish the list but that would only work for vectors and matrices. What should I do with pvectors containing other datatypes like pvector<int> or pvector<pvector<LPoint2d>>. Is that possible to do with interrogate or is it the wrong tool for that?

edit: same thing for pmaps

Depending on the use case it may be better (and more efficient) to just have the method take a PyObject *args and use the Python C API to accept whatever you need.