Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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 not in sync

    Cinema 4D SDK
    r20 python
    3
    5
    1.5k
    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.
    • R
      Rage
      last edited by a_block

      Hi All,

      I'm trying to create a new UVWTag (if an object doesn't already have one). Here's my basic code:

      def main():
      obj = doc.GetFirstObject()

      if obj.GetTag(c4d.Tuvw) is None:
          tag = obj.MakeTag(c4d.Tuvw)
          tag[c4d.TEXTURETAG_PROJECTION]=3
          tag.SetName('Cubic_map')
          c4d.EventAdd()
      

      The code runs howewer, cinema reports the following error later when trying to access the uv:

      A problem with this project has been detected: Object "Cube" - Tag 5671 not in sync. Please save and contact MAXON Support with a description of the last used commands, actions or plugins.

      What Am I missing?

      1 Reply Last reply Reply Quote 0
      • M
        mp5gosu
        last edited by

        A UVWTag does not have any projections. You might want to use a Texture Tag (Ttexture) instead.

        Best,
        Robert

        1 Reply Last reply Reply Quote 1
        • R
          Rage
          last edited by

          It seems like it has a projection.

          Please note that I don't know c4d, I'm just coding with the api but I don't know the software itself (I came from the blender's world)

          Anyways, If you go to the UV edit, and you select your object and UVW tag, you can choose the UV mapping - Projection

          let me attach a screenshot of what I'm trying to access. On the bottom right you can see there are some projections types, how do I set those through python?

          0_1549970768494_Screen Shot 2019-02-12 at 12.25.12.png

          1 Reply Last reply Reply Quote 0
          • M
            mp5gosu
            last edited by

            The projection modes listed there are actually commands that operate on the UVs directly.
            I'm not sure if you can access those functions in py, but here's a workaround.

            As said above, use a texture tag to set desired projection. After that, you can call the command Generate UV coordinates which then creates a new UV tag with the projection "baked in" and the texture mode is automatically set to "UVW".

            1 Reply Last reply Reply Quote 2
            • r_giganteR
              r_gigante
              last edited by r_gigante

              Hi Rage, thanks for reaching us.

              With regard to the issue mentioned and considering your non-Cinema background, first of all lets settle down a few concepts:

              • UVWTags are just acting as "storage" for the UVW data used on polygonal objects;
              • TextureTags are instead used to create the actual texturing on the on a generic object (whatever it's a polygonal or parametric one)

              A parametric object can use a texture even without explicit an UVWTag since the TextureTag delivers all the information with regard on how to map a texture to the object.

              When a parametric object (e.g. cube) is converted into a polygonal one the UVW values which are part of the parametric object gets dumped in the UVWTag that is generated as soon as the conversion ends.

              That said give a certain object (a polygonal one) the way to go is:

              def main():
                  # check that an object is selected
                  if op is None:
                      return
                  
                  # get the active material
                  activeMat = doc.GetActiveMaterial()
                  if activeMat is None:
                      return
                  
                  # instantiate a TextureTag
                  sph50NoTileTextureTag = c4d.TextureTag()
                  if sph50NoTileTextureTag is None:
                      return
                  
                  # set the mapping type
                  sph50NoTileTextureTag[c4d.TEXTURETAG_PROJECTION] = c4d.TEXTURETAG_PROJECTION_SPHERICAL 
                  # turn off tiling
                  sph50NoTileTextureTag[c4d.TEXTURETAG_TILE] = False
                  # scale the mapping to 50% on u and v
                  sph50NoTileTextureTag[c4d.TEXTURETAG_LENGTHX] = 0.5
                  sph50NoTileTextureTag[c4d.TEXTURETAG_LENGTHY] = 0.5
                  # link to the active material
                  sph50NoTileTextureTag[c4d.TEXTURETAG_MATERIAL] = activeMat
                  
                  # generate the corresponding UVWTag using the mapping settings specific in the TextureTag
                  sph50NoTileUVWTag = c4d.utils.GenerateUVW(op, op.GetMg(), sph50NoTileTextureTag, op.GetMg())
                  # check for UVWtag being properly created
                  if sph50NoTileUVWTag is None:
                      return
                  # set the name of the tag
                  sph50NoTileUVWTag.SetName('0.5 non-tiled spherical')
                  # add both the UVWTag and the TextureTag
                  if op.GetTag(c4d.Tuvw) is None:
                      op.InsertTag(sph50NoTileUVWTag)
                  if op.GetTag(c4d.Ttexture) is None:
                      op.InsertTag(sph50NoTileTextureTag)
              
                  # notify Cinema about the changes
                  c4d.EventAdd()   
              

              Best, Riccardo

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