I'm trying to create a new UVWTag (if an object doesn't already have one). Here's my basic code:
obj = doc.GetFirstObject()
if obj.GetTag(c4d.Tuvw) is None:
tag = obj.MakeTag(c4d.Tuvw)
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.
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?
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".
Generate UV coordinates
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:
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:
# check that an object is selected
if op is None:
# get the active material
activeMat = doc.GetActiveMaterial()
if activeMat is None:
# instantiate a TextureTag
sph50NoTileTextureTag = c4d.TextureTag()
if sph50NoTileTextureTag is None:
# 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:
# 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:
if op.GetTag(c4d.Ttexture) is None:
# notify Cinema about the changes