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

    new(BaseFile) returns NIL

    Scheduled Pinned Locked Moved SDK Help
    4 Posts 0 Posters 352 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

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

      On 07/01/2008 at 20:29, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   10.5 
      Platform:   Windows  ;   
      Language(s) :   C.O.F.F.E.E  ;

      ---------
      Hi. I'm a new() COFFEE user but I can't get new() to work!:)

      I'm trying to access a file from within a COFFEE script and whenever I try to instantiate a BaseFile object using new(BaseFile) I get a NIL instead of an object. I have tried copying and pasting the code from the 9.5 COFFEE SDK into my script and it does not run because the new() function returns a NIL. (See below)

      Does someone have a clue to steer me in the right direction?

      // Creates the file and writes a string to it
      var file = new(BaseFile);
      file->Open(filename, GE_WRITE);
      file->WriteString("Hello World!");

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

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

        On 07/01/2008 at 23:38, xxxxxxxx wrote:

        It works fine here, maybe your filename is wrong? Here a working sample:

        > _
        > var fn = new(Filename);
        > if(!fn) return;
        >
        > if(!fn- >FileSelect("Create file", TRUE)) return;
        >
        > var file = new(BaseFile);
        > if(!file) return;
        >
        > if(!file->Open(fn, GE_WRITE, FILE_IGNOREOPEN, GE_INTEL)) return;
        >
        > if(!file->WriteString("hallo", GE_7BIT)) return;
        > _

        cheers,
        Matthias

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

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

          On 08/01/2008 at 12:29, xxxxxxxx wrote:

          Thanks for your response Matthias. It got me half way there.

          I have been developing scripts by creating a Null Object and attaching a COFFEE tag to it. If I paste your code into one of those tags, it fails just like mine did.

          If I use the Script Manager and paste your code into it, your code works fine, so the code itself is not the problem but my way of implementing it within C4D. I'll have to read up on it and figure out why the tag method doesn't work.

          You got me over the hump though - thanks!

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

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

            On 08/01/2008 at 12:48, xxxxxxxx wrote:

            You can't do file access in COFFEE when the script is in a tag or Xpresso node as expressions (this is to disallow scripts from being used maliciously - see the "Basic Functions and Classes" section of the COFFEE docs). You'll need to do the COFFEE script as a full-blown plugin to have file access.

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