Duplicating a group with a script does not change/update groupItems.length
When you duplicate a group via script (check the video and screenshots) activeDocument.groupItems.length is not reflecting that. It stays the same. app.redraw() is not helping. Only when you set the new group to .selected = true you can force an update. But that slows down everything when you have a lot of groups.
Video: https://drive.google.com/file/d/1dd0PyBRDBciNnUgnhGLV7Hf40rrG_vSb/view
Steps to Reproduce:
All with script!
1. Create a group (put something in that group)
2. Alert the activeDocument.groupItems.length (it's now 1)
2. Duplicate the group.
3. Alert the activeDocument.groupItems.length: it stays the same (1 instead of 2)
Please take a look at the script and the video.
Actual Result:
groupItems.length stays 1
Expected Result:
groupItems.length is 2
Any Workarounds:
selected = true but that is not a good workaround. It slows down everything. And it messes up the current selection of users.
Shared by Eugen Pflueger