I tried to make a script where when generating a material, assign the active object that material but I do not know if it should go the way I am doing it or it is wrong, I also saw in the script history c4d.ID_MATERIALASSIGNMENTS
I guess it has something to do with it but I don't understand
from c4d import gui
cubo = doc.GetActiveObject()
c4d.CallCommand(13015, 13015) # Nuevo Material
mat = doc.GetAciveMaterial()
mat[c4d.MATERIAL_PAGE_ASSIGNMENT] = cubo
thank you for reaching out to us. While it is possible to use CallCommand in scripts for the more basic things like creating a material, it is recommended to use the more abstract object-oriented API whenever possible. Below you will find an example script which creates, modifies and assigns a new material to the currently active object.
"""Example for creating a material and assigning it to the currently active
As discussed in:
# op and doc a are module attributes predefined by Cinema 4D for a script
# module. doc is the currently active document, op the currently active
# object in this active document.
if op is None:
raise RuntimeError("Please select an object.")
# Instantiate a standard material and insert it into the document, as
# otherwise we could not use it.
mat = c4d.BaseList2D(c4d.Mmaterial)
# Example for modifying the material, here setting its diffuse color.
mat[c4d.MATERIAL_COLOR_COLOR] = c4d.Vector(1, 0, 0)
# Create a texture tag on the selected object, change the projection mode
# to uvw and link the newly crated material to it.
tag = op.MakeTag(c4d.Ttexture)
tag[c4d.TEXTURETAG_PROJECTION] = c4d.TEXTURETAG_PROJECTION_UVW
tag[c4d.TEXTURETAG_MATERIAL] = mat
# Notify Cinema 4D of the changes made.
# Execute main()
thank you very much solved my doubts
without further questions or postings, we will consider this topic as solved by Wednesday and flag it accordingly.
Thank you for your understanding,