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

    BaseSelect::GetCount() Crash

    SDK Help
    0
    7
    651
    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 19/05/2004 at 16:21, xxxxxxxx wrote:

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

      ---------
      Hi,
      Im trying to retrieve an Point Selection Tag from an object via a LINK control in a UI.
       
      Im attempting to get the SelectionTag, if there is none, I am trying to create a new BaseSelect and select all the elements inside.
      If there was a SelectTag then Im trying to simply print out the amount of selected elements.
       
      My code is

          
          
          
          
           // Get the Point Selection link from the GUI  
           bsSelection = (BaseSelect* )data->GetLink(MAIN_LINKPOINTSELECTION, hh->GetDocument());
          
          
          
          
           
          
          
          
          
           // If there is no PointSelection Tag, create a new internal one, and populate it  
           if(!bsSelection)  
           {  
              
            bsSelection = BaseSelect::Alloc();  
            bsSelection->SelectAll(0,lPointCount-1);  
           }  
           else  
           {  
            // Crashes on this line  
            GePrint(LongToString(bsSelection->GetCount()));  
           }
          
          
          
      

      For some reason, I am crashing when there is a SelectionTag.
      Any reason why?
      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/05/2004 at 16:30, xxxxxxxx wrote:

        I just relacing it with

            
            
            
            
            GePrint(LongToString(bsSelection->GetSegments()));
            
            
            
        

        And that printed a number like 285662124 in the conole!
         
        Now im quite sure there arn't that many segments in this selection tag, as the object is only a 4 point polygon, with one point selected

        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 20/05/2004 at 03:46, xxxxxxxx wrote:

          If you are retrieving a selection from a LINK field the returned type cannot be a BaseSelect. It has to be a SelectionTag.
          SelectionTag *stag = ( SelectionTag * )data->GetLink(MAIN_LINKPOINTSELECTION, hh->GetDocument()); if(!stag) return FALSE;
          bsSelection = stag->GetBaseSelect();
          That´s probably why it´s crashing.

          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 20/05/2004 at 04:14, xxxxxxxx wrote:

            What Samir says is true. Btw, if you would have used the C++-style static_cast_<_baseselect*_>_(...) instead of the C-style cast, then the compiler would have caught the error.

            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 20/05/2004 at 14:51, xxxxxxxx wrote:

              Thank you Samir. Got it working now
              I must sleep more, I'm having trouble with the most obvious things.
               
              Thank you Mikael, I didn't know the difference between static_cast and just (BaseSelect* ). I had no idea one was C++ and the other was C.
               
              Thats what you get for self teaching C++ or C or whatever C langauge I have learn'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 20/05/2004 at 18:58, xxxxxxxx wrote:

                The old conventional casts are still legal cast operators in C++ (it´s just C-style) but as Mikael already said the new cast operators should be used and they bring some advantages too. Not only that they are much better noticed in your code (not only for yourself but also for tools maybe like grep) but they are also better for the compiler to diagnose mistakes.
                For example only the const_cast<T> can be used to cast away the constant of something. If you try to cast away the constant of an object or a pointer with one of the other new cast-operators, this expression will not be compiled.
                For completeness, there are 2 other cast operators dynamic_cast<T>, which is i.e. used for safe downcasting, and reinterpret_cast<T> can for example be used to cast between a pointer and a function. But it isn´t used very often (I haven´t used it myself yet).
                Ok, now it´s bed time.

                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 21/05/2004 at 11:18, xxxxxxxx wrote:

                  Thanks Samir.
                   
                  In my current project I am using reinterpret_cast<T>. It was from a snippet I saw on the forums. I didn't *really* understand exactly what it was doing, All I knew was it was casting from one data type to another (in this case, a function* to a Real* ).
                   
                  Thanks for the heads up, Will have to go looking for some c++ resources like this

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