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

    tag GetParameter TEXTURETAG_RESTRICTION

    SDK Help
    0
    15
    1.3k
    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

      On 07/07/2015 at 11:40, xxxxxxxx wrote:

      Hi,

      Okay, now we know that 😛

      I wasn't able to find anything about that on the docs.

      Could it be an enum value? Just my thoughts here.

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

        On 07/07/2015 at 13:43, xxxxxxxx wrote:

        Here are my thoughts on this:

        1. Do not assume that the first tag is a Texture tag.  And you might be like well it is the first and maybe only tag on the object.  And you would be incorrect.  Polygon objects also have two hidden tags: a Point tag and a Polygon tag.  Verify that you are getting the proper tag type.  Would be better to iterate through the object's tags until you find a texture tag.  There may be more than one or none.

        if (tag && tag->IsInstanceOf(Ttexture) && tag->GetParameter(TEXTURETAG_RESTRICTION, data))
        

        2. TEXTURETAG_RESTRICTION is defined as a String description in the Ttexture.res file.  Therefore, it should *always* return a String.  That is why I mention point 1.  Could be that you are requesting a parameter for a tag that isn't a Texture tag and thus the issues.

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

          On 07/07/2015 at 13:52, xxxxxxxx wrote:

          Hi,

          So I thought that simplifying the code was the best approach to make myself clear, but I was wrong. So here is the full code until the problematic line:

          BaseObject *searchOp = (PolygonObject* )op;
          while (!found && searchOp != nullptr)
          {
              BaseTag* btag = searchOp->GetFirstTag();
              for (; btag; btag = (BaseTag* )btag->GetNext())
              {
                  if (btag->GetType() == Ttexture)
                  {
                      if (btag->GetParameter(TEXTURETAG_MATERIAL, data))
                      {
                          MaterialSelection m;
                          m.mat = (AlienMaterial* )data.GetLink();
                          
                          found = true;
                          if (m.mat != nullptr && std::find(std::begin(materials), std::end(materials), m) == end(materials))
                          {
                              if (btag->GetParameter(TEXTURETAG_RESTRICTION, data))
                              {
                                  String name = data.GetString();
          

          I think I have all the needed checks, however, if I check the "data" type (data.GetType()) it returns Int32, and the the data.GetString() crashes.

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

            On 07/07/2015 at 15:04, xxxxxxxx wrote:

            data.GetType() does indeed return Int32.  It is a value representing the 'type' of data for the description.  It should be DA_STRING.

            if (data.GetType() != DA_STRING)  //then something is wrong
            

            Otherwise, I don't see anything wrong with the code (except the possible issues using the STL).

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

              On 07/07/2015 at 15:21, xxxxxxxx wrote:

              Yep, the type I'm getting when it crashes is DA_LONG.

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

                On 07/07/2015 at 15:57, xxxxxxxx wrote:

                That is very odd.  Possible memory corruption?  Is the restriction empty when it crashes or it doesn't matter either way?  There has to be some outside factor for the data type to return DA_LONG when it has to be DA_STRING.

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

                  On 07/07/2015 at 15:59, xxxxxxxx wrote:

                  may be it returns an Int32 "0" when string is empty.

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

                    On 07/07/2015 at 16:30, xxxxxxxx wrote:

                    It could be empty yes, because all variables are null, and the type could just be the initial value, or even memory trash.

                    Either way, does it make sense to crash in situations like this? Also, why the GetParameter returns true, if the data is empty?

                    I check for type now, to make sure it does not read invalid stuff, but it was not needed before.

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

                      On 08/07/2015 at 10:46, xxxxxxxx wrote:

                      Hello,

                      I can confirm the described behavior and it seems to be a bug. A bug report was filed.

                      But calling GetString() should not cause a crash, it should just trigger a breakpoint. Are your sure it causes a crash?

                      Best wishes,
                      Sebastian

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

                        On 08/07/2015 at 10:48, xxxxxxxx wrote:

                        You're right, it's just a breakpoint! That's why it doesn't happen in release mode.

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