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?
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.
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)
(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
loadPrcFile("myPrcFile.prc")
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.
os.system(command)
(With the caveat that the above is untested–especially as I haven’t myself used the “ConfigVariableList” method, that I recall.)