Hello,
I would like to use UV Relaxing and in particular pass the current edge selection via RELAXUV_EDGESEL_POINTER to create UV seams on the selected edges.
Basically the script does the UV Relaxing and I can see this clearly in the UV Editor Window, it doesn't report any errors and the res of SendModelingCommand() also returns True. Also I check via print(edge_selection.GetCount()) if my selection is passed at all and the count always matches the current edge selection. However, the relaxing does not use the edge selection as it would work in UV Manager via the UV Relaxing tab.
I also found an older thread from 2016 mentioning that RELAXUV_EDGESEL_POINTER expects a string reference to a selection tag, although the SDK clearly indicates that a c4d.BaseSelect is expected, of course I tried that too, but that also remains unsuccessful.
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:
Unwrap(op)
def Unwrap(obj: c4d.BaseObject):
if not isinstance(obj, c4d.PolygonObject):
return None
edge_selection = get_selected_edges(obj)
print(edge_selection.GetCount())
# Set up the settings for the UV unwrapping.
settings = c4d.BaseContainer()
settings[c4d.RELAXUV_KEEP_BORDER] = False
settings[c4d.RELAXUV_KEEP_NEIGHBORS] = False
settings[c4d.RELAXUV_KEEP_POINTSEL] = False
settings[c4d.RELAXUV_CUT_EDGESEL] = True
settings[c4d.RELAXUV_EDGESEL_POINTER] = edge_selection
settings[c4d.RELAXUV_MAX_ITERATIONS] = 0
settings[c4d.RELAXUV_MODE] = 0
# Execute the UV unwrapping command.
res = c4d.utils.SendModelingCommand(command=1053624,
list=[obj],
mode=c4d.MODELINGCOMMANDMODE_POLYGONSELECTION,
bc=settings,
doc=doc)
print(res)
c4d.EventAdd()
def get_selected_edges(obj):
if not isinstance(obj, c4d.PolygonObject):
return None
neighbor = c4d.utils.Neighbor()
neighbor.Init(obj)
return obj.GetSelectedEdges(neighbor, c4d.EDGESELECTIONTYPE_SELECTION)
"""
def state():
# Defines the state of the command in a menu. Similar to CommandData.GetState.
return c4d.CMD_ENABLED
"""
if __name__ == '__main__':
main()