[Scripting API]getPageItemFromUuid returns `typename === "GroupItem"` for RasterItem / PlacedItem / CompoundPathItem / SymbolItem / MeshItem
Environment:
Illustrator 30.3, Windows, ExtendScript / CEP.
When you look an item up by UUID, the wrapper returned by Document.getPageItemFromUuid() lies about its type for several subtypes. They all come back as "GroupItem":
// uuid belongs to a RasterItem (or PlacedItem / CompoundPathItem / SymbolItem / MeshItem):
var item = app.activeDocument.getPageItemFromUuid(uuid);
alert(item.typename); // -> "GroupItem" (expected the real subtype)
This makes type-based dispatch on UUID lookups unreliable. My current workarounds to recover the true type:
- Items with children: read
item.pageItems[0].parent-> Returns correct object with the correcttypename. - Childless items (e.g. RasterItem): search the parent's typed sub-collections (
rasterItems,placedItems,symbolItems,meshItems, …) by uuid.
Is there a better way to get the real typed object by UUID?
2
votes