Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Python hyperfile write/read float32

    Scheduled Pinned Locked Moved Bugs
    3 Posts 0 Posters 707 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      On 05/06/2016 at 07:49, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   R17 
      Platform:   Windows  ;   
      Language(s) :

      ---------

      When writing out and reading floats I noticed a difference between write/read float32 and write/read float64.
      I have included code using the 32 variant. The double precision seems to work OK, but I would expect that while less precise, the 32 bit variant to "closely" match the expected value.

      Write/Read Float32
      writing -> version: 0.4
      reading -> version: -1.58818683921e-23

      Write/Read Float64
      writing -> version: 0.4
      reading -> version: 0.4

      def WritePreset(self) :
            testversion = 0.4
            folder, filename = os.path.split(__file__)
            fn = os.path.join(folder, 'preset')
            hf = c4d.storage.HyperFile()
            if hf.Open(ident=12345, filename=fn, mode=c4d.FILEOPEN_WRITE, error_dialog=c4d.FILEDIALOG_NONE) :
                print 'writing -> version:', testversion
                if not hf.WriteFloat32(testversion) :
                    print 'Failed writing'
                hf.Close()
            else:
                print 'Failed open hyperfile', hf.GetError()
            return
       
        def ReadPreset(self) :
            folder, filename = os.path.split(__file__)
            fn = os.path.join(folder, 'preset')
            hf = c4d.storage.HyperFile()
            if os.path.isfile(fn) and hf.Open(ident=12345, filename=fn, mode=c4d.FILEOPEN_READ, error_dialog=c4d.FILEDIALOG_NONE) :
                ver = hf.ReadFloat32()
                print 'reading -> version:', ver
                hf.Close()

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 13/06/2016 at 06:34, xxxxxxxx wrote:

        Hi,

        you have found a bug in the argument parsing of WriteFloat32(). Sorry!
        The only workaround I have for now is to use WriteFloat64() instead. The bug will be fixed in one of the next releases.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 15/06/2016 at 12:19, xxxxxxxx wrote:

          Thank you Andreas

          1 Reply Last reply Reply Quote 0
          • First post
            Last post