I am Having troubles with Multifile

I am new to panda3d,
I have read the documentation , and have created a multifile called Assets.mf ,
the occurs when i add an .egg file,
Here is my code

from panda3d.core import Multifile,Filename
file = Multifile()
file.openReadWrite('Assets.mf')
file.addSubfile("/Box.egg",Filename('/Box.egg'), 6)
file.flush()

the error is;


Assertion failed: fname.is_binary_or_text() at line 426 of c:\buildslave\sdk-windows-amd64\build\panda\src\express\multifile.cxx
Traceback (most recent call last):
  File "D:\Test Game 01\Panda3d_Multifile.py", line 4, in <module>
    file.addSubfile("/Box.egg",Filename('/Box.egg'), 6)
AssertionError: fname.is_binary_or_text() at line 426 of c:\buildslave\sdk-windows-amd64\build\panda\src\express\multifile.cxx

It would be great if someone could explain it to me.
Thanks😊

Looking at the API, it seems that the Filename that one supplies to “addSubFile” must have had either “setBinary()” or “setText()” called on it.

Since you’re creating and using your Filename in the same line, that’s presumably not happening, and thus the error.

It seems that “addSubFile” requires that one specify explicitly what sort of file–text or binary–is being used.

so does that mean just add .setBinary()

file.addSubfile("/Box.egg",FileName('/Box.egg').setBinary(),6)

if my code is wrong could you give me an example

I don’t think that “setBinary” returns a Filename object–if I were to guess, I’d guess that it returns nothing, i.e. “None”. As a result, the code above would end up passing “None” into “addSubfile”, which would presumably itself cause a problem.

Instead, what I recommend is that you create your Filename-object separately from the call to “addSubfile”, call “setBinary” on it, and then pass it into your call to “addSubFile”.

1 Like

Thanks bro😇

1 Like