Tag not in sync



  • 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?



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

    Best,
    Robert



  • 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



  • 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".



  • 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


Log in to reply