Hi sadly the only way is to use c4d.CallCommand(1055347) which does not open the window but directly execute the command.
You can change the setting as you could in the windows, by editing the value in the BaseContainer of the document.
Finally it act on the selected polygon, so the best way would be to select them.
Find bellow a script that you can execute in the script manager that will select all polygon of an object and run the command.
from typing import Optional
import c4d
doc: c4d.documents.BaseDocument # The active document
op: Optional[c4d.BaseObject] # The active object, None if unselected
def main() -> None:
# Enables UV Polygon Mode if not already in any UV mode (needed for GetActiveUVSet to works)
if doc.GetMode() not in [c4d.Muvpoints, c4d.Muvpolygons]:
doc.SetMode(c4d.Muvpolygons)
# Retrieves active UVSet, The UV windows need to be opened at least one time
handle = c4d.modules.bodypaint.GetActiveUVSet(doc, c4d.GETACTIVEUVSET_ALL)
if handle is None:
# If fail it may be because the Texture view is not open
# Open A texture View
c4d.CallCommand(170103)
# In S22 you need to update the UV Mesh
if c4d.API_VERSION >= 22000:
c4d.modules.bodypaint.UpdateMeshUV(False)
# Retrieves active UVSet, The UV windows need to be opened at least one time
handle = c4d.modules.bodypaint.GetActiveUVSet(doc, c4d.GETACTIVEUVSET_ALL)
if handle is None:
raise RuntimeError("There is no Active UVSet")
# Select the polygon you want to operate on
currentSel = op.GetPolygonS()
previousSel = currentSel.GetClone() # Will be used to restore the initial selection state at the end
currentSel.SelectAll(op.GetPolygonCount() - 1 )
# Update the UV mesh to properly take into account the new selection
c4d.modules.bodypaint.UpdateMeshUV(True)
# Define the settings
settings = doc.GetSettingsInstance(c4d.DOCUMENTSETTINGS_MODELING)
settings[c4d.MDATA_UVRECTANGULARIZE_ALIGN] = True
settings[c4d.MDATA_UVRECTANGULARIZE_EQUIDISTANT] = False
# Execute the command
c4d.CallCommand(1055347)
# Restore the initial selection
previousSel.CopyTo(currentSel)
c4d.modules.bodypaint.UpdateMeshUV(True)
c4d.EventAdd()
if __name__ == '__main__':
main()
Cheers,
Maxime.