On 14/08/2018 at 09:24, xxxxxxxx wrote:
Hello,
I'm trying to move UVs using UVCOMMAND for a UDIM setup with multiple selected objects. In my current script, the transforms only happen to the last object in the list. I've tried other flags for the Active UV set and selecting the UV Polygons before UVCOMMAND is called. Nothing is working. Could someone please tell me what I am doing incorrectly? Here's my code.
def moveUVs(obj,index) :
# Retrieves active UVSet
handle = bodypaint.GetActiveUVSet(doc, c4d.GETACTIVEUVSET_ALL)
if not handle:
print "No active UVSet!"
return
settings = c4d.BaseContainer()
settings[c4d.UVCOMMAND_TRANSFORM_MOVE_X] = index
settings[c4d.UVCOMMAND_TRANSFORM_MOVE_Y] = 0
settings[c4d.UVCOMMAND_TRANSFORM_SCALE_X] = 1
settings[c4d.UVCOMMAND_TRANSFORM_SCALE_Y] = 1
settings[c4d.UVCOMMAND_TRANSFORM_ANGLE] = utils.DegToRad(0)
# Retrieves UVW list
uvw = handle.GetUVW()
if uvw is None:
return
# Calls UVCOMMAND_TRANSFORM to change UVW list
ret = bodypaint.CallUVCommand(handle.GetPoints(), handle.GetPointCount(), handle.GetPolys(), handle.GetPolyCount(), uvw,
handle.GetPolySel(), handle.GetUVPointSel(), handle.GetBaseObject(), handle.GetMode(), c4d.UVCOMMAND_TRANSFORM, settings)
if not ret:
print "CallUVCommand() failed!"
return
print "CallUVCommand() successfully called"
# Sets the transformedUVW from Texture View
if handle.SetUVWFromTextureView(uvw, True, True, True) :
print "UVW from Texture View successfully set"
else:
print "UVW from Texture View failed to be set!"
# Releases active UVSet
bodypaint.FreeActiveUVSet(handle)
def main() :
objs = doc.GetActiveObjects(0)
doc.StartUndo()
for idx, obj in enumerate(objs) :
moveUVs(obj,idx)
c4d.EventAdd()
doc.EndUndo()
if __name__=='__main__':
main()
Thank you!