Hey @lednevandrey,
without wanting to be rude, I really struggle with understanding what you want to convey. Material[c4d.TEXTURETAG_PROJECTION] = c4d.TEXTURETAG_PROJECTION_UVW does not work because Python is case sensitive and you gave your BaseMaterial instance the symbol material. So, Python is complaining about that.
But as said before, a material, i.e., BaseMaterial is not the right place to set the projection. It is the counter part to the thing you see in the Material Manager of Cinema 4D and has no projection. The projection is set in the Material Tag, which slightly confusingly is called TextureTag in the API.
Cheers,
Ferdinand
"""Assigns the first material in the document to the selected object and sets its projection to UVW.
"""
import c4d
import mxutils
doc: c4d.documents.BaseDocument # The currently active document.
op: c4d.BaseObject | None # The primary selected object in `doc`. Can be `None`.
def main() -> None:
"""Called by Cinema 4D when the script is being executed.
"""
if not op:
raise ValueError("Please select an object.")
# Get the first material in the document.
material: c4d.BaseMaterial = doc.GetFirstMaterial()
if not material:
raise ValueError("No materials found in the document.")
# Get the first existing texture tag on #op or create a new one when none exists.
tag: c4d.BaseTag = op.GetTag(c4d.Ttexture) or op.MakeTag(c4d.Ttexture)
if not tag:
raise ValueError("Failed to get or create a texture tag.")
# Set the material and projection.
tag[c4d.TEXTURETAG_MATERIAL] = material
tag[c4d.TEXTURETAG_PROJECTION] = c4d.TEXTURETAG_PROJECTION_UVW
# Update the Cinema 4D UI.
c4d.EventAdd()
if __name__ == '__main__':
main()