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

    Forward text and case sensitivity routine

    SDK Help
    0
    6
    1.1k
    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 18/12/2002 at 05:11, xxxxxxxx wrote:

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

      ---------
      I've created a Find Object command using a COFFEE plugin I've written. Unfortunately it's case sensitive and there doesn't seem to be a case insensitive function in COFFEE, though I think there might be something like that in C++ which I can't use because of the learning curve - COFFEE is distraction enough from the creative work.

      Another thing I'd love to have in my Find dialog box is the same forward lookup that you get in C4D native dialogs, saving you having to type the whole string.

      A search of the old archive revealed there was a Japanese user who claimed to have the latter routine, but his site link returned Not Found and searching Google produced to result.

      Does anyone have either of these two routines written in COFFEE that they could share? Or if you have it as a C++ library of some kind, would there be a way of making use of it in a COFFEE plugin?

      I'm sure I'm not the only one who would hugely appreciate this. Once you start building dialogs to enter names of objects, you realize how much these two routines are needed.

      Thanks in advance!

      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 18/12/2002 at 12:32, xxxxxxxx wrote:

        Hi,
        this is what I have used for my COFFEE plugins all the time:

            
            
            CheckHierarchy(obj, stopAt)   
            {   
              if (!obj) return NULL; 
            
            
            
            
              var next;   
              if (next = obj->GetDown()) return next;   
              if (next = obj->GetNext()) return next;    
            
            
            
            
              var up = obj;   
              while (up = up->GetUp())   
              {   
                if (up == stopAt) return NULL;   
                if (next = up->GetNext()) return next;   
              }    
            } 
            
            
            
            
            struppercase(str)  
            {   
             var i;    
             for (i = 0; i < sizeof(str); ++i)    
             {      
              if (str[i] >= 97 && str[i] <= 122)      
              {        
               str[i] -= 32;       
              }    
             }    
             return str;  
            }
            
            
            
            
            SearchObject(str_name)  
            {  
             var length,char,can_length,i;  
             var input;     
             var my_new_group; 
            
            
            
            
            var match;     
            var group;   
            
            
            
            
             var candidate;  
            
            
            
            
             var doc = GetActiveDocument();  
             if(!doc) return NULL;
            
            
            
            
             group = doc->GetFirstObject();
            
            
            
            
             if (sizeof(str_name)==0) return NULL;   
             input = struppercase(str_name);
            
            
            
            
             while ( group )  
             {  
              length = sizeof(input); 
            
            
            
            
              candidate = struppercase (group->GetName());  
              can_length = sizeof(candidate);
            
            
            
            
              if (can_length < length) length = can_length;
            
            
            
            
              i = 0;  
              do  
              {  
               if ( !match ) { match = candidate; } 
            
            
            
            
               if  ( strcmp (candidate,input) == 0 )  
               {   
                match = candidate;  
                my_new_group = group;  
                break;  
               }  
               if  ( strcmp (match,input)  == 0 ) break; 
            
            
            
            
               if  ( strcmp (match,candidate)  == 0 ) break;  
            
            
            
            
               if  ( strcmp (match,candidate)  != 0 )  
                {    
                 if (input[i] == candidate[i]) 
            
            
            
            
                 {  
                  if(sizeof(match)<(i+1))  
                   {       
                    match = candidate;  
                    my_new_group = group;  
                   }  
                  else  
                  {  
                   if ( input[i] != match[i] )   
                   {  
                    match = candidate;    
                    my_new_group = group;  
                    break;  
                   }  
                   else 
            
            
            
            
                   {  
                    i++;  
                   }  
                  }  
                 } // if (input[i] == candidate[i])  
                 else break;       
                } // if  ( strcmp (match,candidate)  != 0 )  
                 else break;   
              } while (i<length);
            
            
            
            
               group = CheckHierarchy(group, NULL);  
             }   
                
               if (!my_new_group) my_new_group = doc->GetFirstObject();  
               return my_new_group;  
            }
        

        Feel free to use it for whatever you want.
        Best
        Samir

        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 18/12/2002 at 17:35, xxxxxxxx wrote:

          Wow, thanks, Samir!! Many many thanks! I'm much obliged. Wishing you tons of good karma and very happy holidays and a prosperous New Year! You totally rule, man!!

          Cheers, 🙂

          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 18/12/2002 at 18:55, xxxxxxxx wrote:

            Oups, I've run into a problem - don't know how to update a static text field in the dialog with the output of the SearchObject function as I type my input into an edit field. I can error check the output and get a string out of it, but calling CreateLayout again or setting the static text string variable doesn't update the static field. I'm working around this problem at the moment by sending the output to the status bar instead, which is satisfactory but not elegant. I must be missing something obvious....

            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 19/12/2002 at 01:07, xxxxxxxx wrote:

              In the Dialog Class or one of its methods just use SetString(ID,string). On the outside you will have to use the dialog constructor like dialog->SetString(ID,string);

              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 19/12/2002 at 03:48, xxxxxxxx wrote:

                Thanks a lot! 🙂

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