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

    BaseFile->Open crash

    SDK Help
    0
    15
    1.2k
    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
      Helper
      last edited by

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

      On 21/12/2003 at 16:12, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   8.206 
      Platform:   Windows  ;   
      Language(s) :     C++  ;

      ---------
      Hi, this code crashes cinema4d and I don't see why

          
          
          
          
           Bool OK=FALSE;  
           Filename File;          
          
          
          
          
           BaseFile *ExportFilename=NULL;     
          
          
          
          
             
           // Show FileSelect dialog  
           if(!File.FileSelect(FSTYPE_ANYTHING,GE_SAVE,NULL))  
           {  
            MessageDialog("Export Cancelled");  
            return FALSE;  
           }
          
          
          
          
           // Set mouse cursor to a busy sign  
           GeShowMouse(MOUSE_BUSY);
          
          
          
          
          GePrint("Before Open");  
           // Open file for exporting  
           OK = ExportFilename->Open(File, GE_WRITE);  
          GePrint("After Open");
          
          
          
      

      it crashes on the ExportFilename->Open line
      What am I doing wrong?

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

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

        On 22/12/2003 at 03:30, xxxxxxxx wrote:

        Have you actually allocated the BaseFile? the code above doesn't.

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

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

          On 23/12/2003 at 10:36, xxxxxxxx wrote:

          Thanks, yes I forgot to allocate it 😕

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

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

            On 12/02/2005 at 09:53, xxxxxxxx wrote:

            how do i have to alloc ?

            BaseFile *bfile=NULL;
              bfile->Alloc();
              bfile->Open(name,GE_WRITE);
            crashes again ) :

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

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

              On 12/02/2005 at 10:27, xxxxxxxx wrote:

              AutoAlloc<BaseFile> bfile;
              if (!bfile) /* panic */
              bfile->Open(...);
              // do file stuff
              bfile->Close();
              // bfile is automatically Free()'d when it goes out of scope

              or

              BaseFile *bfile;
              if (!(bfile = BaseFile::Alloc()) /* panic */
              bfile->Open(...);
              // do file stuff
              bfile->Close();
              BaseFile::Free(bfile);

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

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

                On 13/02/2005 at 08:48, xxxxxxxx wrote:

                thanks, it doesnt crash now,
                but my plugin still doesnt create a file ) :
                what´s wrong, this time

                LONG SMDFilter::Save(PluginSceneSaver *node, const Filename &name, BaseDocument *doc, LONG flags)
                {
                 doc = GetActiveDocument();
                    BaseObject *obj = doc->GetActiveObject();
                    if(obj)
                    {
                  //IO
                  AutoAlloc<BaseFile> bfile;
                  if (!bfile) MessageDialog(" - no file");
                  bfile->Open(name,GE_WRITE);
                  bfile->WriteString("Claude Bonet Tags: ");
                  bfile->Close();
                ...

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

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

                  On 13/02/2005 at 09:20, xxxxxxxx wrote:

                  Have you checked that 'name' has content and points to a valid path?

                  I can't see anything obviously wrong, otherwise.

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

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

                    On 13/02/2005 at 10:17, xxxxxxxx wrote:

                    BaseFile *file;
                      file = BaseFile::Alloc();
                      file->Open(name,GE_WRITE);
                      file->WriteString("test");
                      BaseFile::Free(file);
                    i tried it this way, too
                    nothing happens, no file created
                    i can´t see the mistake
                    could you give me a very little example for a plugin that saves a string to a file, plz ??
                    thanks

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

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

                      On 13/02/2005 at 11:23, xxxxxxxx wrote:

                      It works fine for me here:

                      AutoAlloc<BaseFile> bf;  
                           if (!bf->Open(presetdirectory,GE_WRITE,FILE_NODIALOG,GE_MOTOROLA)) return FALSE;
                      
                      1 Reply Last reply Reply Quote 0
                      • H
                        Helper
                        last edited by

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

                        On 13/02/2005 at 12:17, xxxxxxxx wrote:

                        ok, here is my code, i hope the variable "name" in the save-method is used correctly:

                        #include <stdio.h>
                        #include <stdlib.h>
                        #include <string.h>
                        #include <c4d.h>
                        class SMDFilter : SceneSaverData
                        {
                            public:
                          virtual LONG Save(PluginSceneSaver *node, const Filename &name, BaseDocument *doc, LONG filterflags);
                          static NodeData *Alloc(void) { return gNew SMDFilter; }
                        };

                        LONG SMDFilter::Save(PluginSceneSaver *node,const Filename &name, BaseDocument *doc, LONG flags)
                        {
                         doc = GetActiveDocument();
                            BaseObject *obj = doc->GetActiveObject();
                            if(obj)
                            {
                          //IO
                          AutoAlloc<BaseFile> bf;
                          if (!bf->Open(name,GE_WRITE,FILE_NODIALOG,GE_MOTOROLA))
                          return FALSE;

                        //Polygoncount
                          char polybuffer [33];
                          GePrint("all Vertices: ");
                          GePrint(itoa(static_cast<PolygonObject *>(obj)->GetPointCount(),polybuffer,10));
                          //Claudebonet test
                                BaseTag *tag = obj->GetFirstTag();
                          
                          char ibuffer [33];
                          int i=0;
                                while(tag->GetType() == Tclaudebonet)
                                {
                           GePrint(".............");
                           VariableTag *gtag = (VariableTag * )tag; 
                           int cnt = gtag->GetDataCount();
                           Real *value = (Real * )gtag->GetDataAddress();
                           //read relevant values
                           i=0;
                           for(int a=0; a<cnt; a++)
                           {
                            if(value[a]==1.0) i++;
                           }
                           GePrint(itoa(i,ibuffer,10));
                           //go to the next tag
                           tag = tag->GetNext();
                                }  
                            } 
                            else MessageDialog(" - no object");
                           
                            return TRUE;
                        }
                        Bool RegisterSMD(void)
                        {
                          if(!RegisterSceneSaverPlugin(1111111,"SMDex",0, SMDFilter::Alloc, EXECUTION_RESULT_OK, 0, NULL)) return FALSE;
                          return TRUE;
                        }

                        if so, what´s wrong here ?
                        thanks a lot for your help!!!

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

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

                          On 13/02/2005 at 12:23, xxxxxxxx wrote:

                          The rest of the code shouldn´t have an effect on the save operation. The save code is correct, not sure why it doesn´t work for you. I assume it has something to do with the SceneSaver hook. (however I cannot really judge it, as I haven´t used this hook yet).

                          Mikael probably knows what´s wrong here, so I suggest to wait for his support.

                          Katachi

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

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

                            On 15/02/2005 at 10:51, xxxxxxxx wrote:

                            ok, thanks anyway,
                            i hope Mikael can help me, soon

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

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

                              On 28/02/2005 at 13:11, xxxxxxxx wrote:

                              What return values do you get when not file is created?

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

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

                                On 28/02/2005 at 17:01, xxxxxxxx wrote:

                                i dont see any values in return
                                AutoAlloc<BaseFile> bf;
                                  if (!bf->Open(name,GE_WRITE,FILE_NODIALOG,GE_MOTOROLA))
                                  MessageDialog(" - no -");
                                "- no -" never appears 😞

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

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

                                  On 09/03/2005 at 06:06, xxxxxxxx wrote:

                                  i made another solution:
                                  ----------------------------------------------------------------

                                  void writetofile(FILE *fi, String st)
                                  {
                                   char *buffer = bNew char[st.GetLength()+1];
                                   for(int n=0; n < st.GetLength(); n++)
                                   {
                                    buffer[n] = st[n];
                                   }
                                   fwrite(buffer,1,st.GetLength(),fi);
                                  }
                                  LONG SMDFilter::Save(PluginSceneSaver *node,const Filename &name, BaseDocument *doc, LONG flags)
                                  {
                                   doc = GetActiveDocument();
                                      BaseObject *obj = doc->GetActiveObject();
                                      if(obj)
                                      {
                                    CHAR header[80];
                                    ClearMem(header,sizeof(header));
                                    String str = name.GetString(),
                                        slash = "/";
                                    //SUFFIX check
                                    if(str.SubStr(str.GetLength()-4,4) != ".smd") str += ".smd";
                                     
                                    LONG count = str.GetCString(header,78,St7bit);
                                    char *ch = bNew char[count+1];
                                    //String to Char
                                    for(int a=0; a < count; a++)
                                    {
                                     if(str[a]=='\') ch[a] = slash[0];
                                     else
                                      ch[a] = str[a];
                                    }
                                    FILE *datei;
                                    datei = fopen(ch,"w+");
                                    if(datei)
                                    {
                                     //file stuff
                                     writetofile(datei,"version 1\n");
                                     writetofile(datei,"nodes\n");
                                    }
                                    fclose(datei);
                                  //... other code

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