Applying custom config vars to Panda tool binaries

I know that Panda binaries can refer to etc/Config.prc oftentimes to register various data, such as egg object type definitions. Moreover, executing a panda tool binary is completely independent of the Python script (a la subprocess), so trying to insert loadPrcFile/loadPrcFileData won’t do any good for registering custom values with the tool process.

Is there a way I can pass custom config value(s) or a config file to the panda tool without resorting to adding things inside Config.prc manually?

loadPrcFile/loadPrcFileData this works before ShowBase initialization.

from panda3d.core import loadPrcFileData 
loadPrcFileData("", "win-size 300 300")

from direct.showbase.ShowBase import ShowBase

class MyApp(ShowBase):
    def __init__(self):

app = MyApp()

During execution, you need to use the class responsible for the configuration directly.

from panda3d.core import WindowProperties
from direct.showbase.ShowBase import ShowBase

class MyApp(ShowBase):
    def __init__(self):
        props = WindowProperties()
        props.set_size(300, 300)

app = MyApp()

I suppose that my question is: how are you executing these tools? Are you using something like “os.system(…)”?

I am personally using the subprocess python library to execute the binaries + passing arguments to them, though it’d be the equivalent of me calling a tool directly (ie “egg2bam.exe”)

I am not using ShowBase here; I am using the Panda tool binaries (egg-trans.exe, egg2bam.exe, etc.), and wondering if there is a way I could pass in custom config values similar to how one would use loadPrcFileData/loadPrcFile before initializing a showbase.

This is a strange approach, usually configuration settings do not affect the output of tools.

Okay, that makes sense I believe!

In which case, it seems to me that you could perhaps in your code read settings from a PRC file, then make use of those settings to determine what arguments to pass to your execution of the binaries. Would that work?

It would be nice, though I am not sure how I would pass those configs as args to the panda tool.

My specific case is that I have a lot of custom egg object types defined in an PRC file that I need to pass to a panda tool without resorting to manually adding them into the default Config.prc for that panda tool (especially when using Panda with virtual environments)

What I’m thinking is something like this:

(It’s not clear to me which tool you intend to use–you mention “egg2bam” above, but I don’t see an “object types” parameter for that tool–so I’m just making one up below. Hopefully the idea is clear!)

from panda3d.core import ConfigVariableList, loadPrcFile

import os


objectTypes = ConfigVariableList("egg-object-types")

command = "toolCommand -objectTypes "
for objType in objectTypes:
    command += objType
    command += " "
# This should produce a command-string that looks
#  something like this:
#  "toolCommand -objectTypes type1 type2 etc.
# Note that there may be more-efficient 
#  string-building approaches.


(With the caveat that the above is untested–especially as I haven’t myself used the “ConfigVariableList” method, that I recall.)

You can add directories to the PANDA_PRC_PATH in the environment variables containing .prc files, that will be read by the egg tools.

1 Like

Are you saying to pass PANDA_PRC_PATH as an environment variable when executing the egg tools?
Ie, such as passing:

Just the directory containing the PRC files.