Write Strings into HyperFile ?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/03/2011 at 14:39, xxxxxxxx wrote:

    Hi there,

    i want to write a string into a hyperfile. But i don't want that string being compiled or something. It should just be a string in the file.

    How to do that ?

    Thanks, nux



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 12/03/2011 at 10:06, xxxxxxxx wrote:

    What do you mean with "being compiled"?

    To save a string in a hyperfile check out this example:

    import c4d
    from c4d import gui, storage
    #Welcome to the world of Python
      
    path="/path/to/file/test.xyz"
    ident=123456 #file identifier
      
    def write() :
        hf=storage.HyperFile()
        hf.Open(ident, path, c4d.FILEOPEN_WRITE, 0)
        hf.WriteString("Hello World!")
        hf.Close()
      
    def read() :
        hf=storage.HyperFile()
        hf.Open(ident, path, c4d.FILEOPEN_READ, 0)
        c=hf.ReadString()
        print c #ouput: Hello World!
        hf.Close()
      
    if __name__=='__main__':
        write()
        read()
    

    Cheers, Sebastian



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 12/03/2011 at 13:24, xxxxxxxx wrote:

    With 'being compiled' I mean, the written String is not formatted as if I would write it into the File myself.
    It's kind of "compiled". Is it MD5 ? Dunno, but it's not a usual String.
    Int your example it's like this:

    QC4D â@  /  '   H e l l o   W o r l d !
    

    I already made a couple of Plugins with files in Coffee and Python.
    But in Coffee, writing a String to BaseFile works as I want it in this case.

    Finally, I want to write an XML Exporter, I already imported the pyfo Package to Py4D.
    For XML I need "real" strings, even the actual way data is being to files by the HyperFile class ia very useful, too.

    And some extra questions by the way :

    - How to browse a directory on harddrive?
    - How can I deliver necessary Packages not
    installed by default with my Plugin ?
    - Would it be possible to write a Py4D Package in order to extend it with functions from C++ not implemented by you ?

    Much Thanks in Advance,
    Niklas



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 16/03/2011 at 14:22, xxxxxxxx wrote:

    *push it to the limit*



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 16/03/2011 at 15:59, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    With 'being compiled' I mean, the written String is not formatted as if I would write it into the File myself.
    It's kind of "compiled". Is it MD5 ? Dunno, but it's not a usual String.

    A HyperFile is a container format for C4D. If you want to write XML files via Python, please check the modules and types which are part of the Python core (xml module + type:file)

    Originally posted by xxxxxxxx

    I already made a couple of Plugins with files in Coffee and Python.

    HyperFile!=BaseFile
    Take a look at: 
    http://docs.python.org/library/stdtypes.html#file-objects
    http://docs.python.org/library/xml.dom.html
    http://docs.python.org/library/xml.dom.minidom.html

    - How to browse a directory on harddrive?
    - How can I deliver necessary Packages not
    installed by default with my Plugin ?

    I recommend you to take a look at the Python documentation or tutorials (especially check the module os ).



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 16/03/2011 at 22:44, xxxxxxxx wrote:

    Ahhhhhh Thanks ! :)

    I thought Basefile in Cof and HyerFile in Py are kind og the same because there is noe BaseFile class in Python and one can create HyperFiles easily which is not possible in Coffe.

    I'm already on my way checking the hole Python documentation. But I did not reach FileObjects yet.

    Much appreciate your help!
    -Niklas


Log in to reply