Copy link to clipboard
Copied
I want to get a complete list of property keys from a Document object, similar to that found in the scripting reference doc.
So far, using Object.keys( activeDocument ) gives a partial list, excluding keys I want to capture such as: brushes, characterStyles, layers, pageItems.
Using hasOwnProperty() I confirmed these properties are not inherited, and using propertyIsEnumerable() I confirmed they are enumerable.
So why are they not being captured and how do I correct it?
Thank you
Copy link to clipboard
Copied
try this, you won't be able to display all of them in the alert window, but you get the idea. You can write the data to a file or write to console, etc
var a = 0, props = [], val;
for (var o in activeDocument) {
try {
val = activeDocument[o];
}
catch (e) {
val = '** ' + e
}
props.push(a++ + ' prop: ' + o + ' - ' + val);
}
alert(props);
Copy link to clipboard
Copied
Here are my sorted results:
XMPString
activeDataSet
activeLayer
activeView
brushes
colorProfileName
cropBox
cropStyle
defaultFillColor
defaultFillOverprint
defaultFilled
defaultStrokeCap
defaultStrokeColor
defaultStrokeDashOffset
defaultStrokeDashes
defaultStrokeJoin
defaultStrokeMiterLimit
defaultStrokeOverprint
defaultStrokeWidth
defaultStroked
documentColorSpace
fullName
geometricBounds
height
inkList
kinsokuSet
mojikumiSet
name
outputResolution
pageOrigin
parent
path
printTiles
rasterEffectSettings
rulerOrigin
rulerUnits
saved
scaleFactor
selection
showPlacedImages
splitLongPaths
stationery
tileFullPages
typename
useDefaultScreen
variablesLocked
visibleBounds
width
Oddly brushes showed up this time, but characterStyles, layers, and pageItems are still missing.
(I only needed the keys, sorry. Just realized I called them values above. I'll fix that now.)
Copy link to clipboard
Copied
oh I see, this method only return Properties, it's missing all collections like GroupItems, Layers, Swatches, etc.
Copy link to clipboard
Copied
Thanks, this is my first run-in with collections. Is there a way to capture all collections held within an object? I could certainly add their keys to my list explicitly, but it would be best if I could do it without having to know them beforehand.
Copy link to clipboard
Copied
it might be possible, smart people over github worked something out to apply intellisense to vscode.
https://github.com/pravdomil/Types-for-Adobe
or maybe they did it the hard way and typed the file themselves?
perhaps parsing the OMV.xml?
<topicref navtitle="Collections">
<topicref navtitle="Assets" href="#/Assets" />
<topicref navtitle="Artboards" href="#/Artboards" />
<topicref navtitle="Documents" href="#/Documents" />
<topicref navtitle="Layers" href="#/Layers" />
<topicref navtitle="GroupItems" href="#/GroupItems" />
<topicref navtitle="PageItems" href="#/PageItems" />
<topicref navtitle="PathItems" href="#/PathItems" />
<topicref navtitle="PathPoints" href="#/PathPoints" />
<topicref navtitle="CompoundPathItems" href="#/CompoundPathItems" />
<topicref navtitle="Stories" href="#/Stories" />
<topicref navtitle="TextFrameItems" href="#/TextFrameItems" />
<topicref navtitle="LegacyTextItems" href="#/LegacyTextItems" />
<topicref navtitle="TextRanges" href="#/TextRanges" />
<topicref navtitle="InsertionPoints" href="#/InsertionPoints" />
<topicref navtitle="Characters" href="#/Characters" />
<topicref navtitle="Words" href="#/Words" />
<topicref navtitle="Lines" href="#/Lines" />
<topicref navtitle="Paragraphs" href="#/Paragraphs" />
<topicref navtitle="CharacterStyles" href="#/CharacterStyles" />
<topicref navtitle="ParagraphStyles" href="#/ParagraphStyles" />
<topicref navtitle="Spots" href="#/Spots" />
<topicref navtitle="Swatches" href="#/Swatches" />
<topicref navtitle="SwatchGroups" href="#/SwatchGroups" />
<topicref navtitle="Gradients" href="#/Gradients" />
<topicref navtitle="GradientStops" href="#/GradientStops" />
<topicref navtitle="Patterns" href="#/Patterns" />
<topicref navtitle="Symbols" href="#/Symbols" />
<topicref navtitle="SymbolItems" href="#/SymbolItems" />
<topicref navtitle="Brushes" href="#/Brushes" />
<topicref navtitle="ArtStyles" href="#/ArtStyles" />
<topicref navtitle="TextFonts" href="#/TextFonts" />
<topicref navtitle="Tags" href="#/Tags" />
<topicref navtitle="RasterItems" href="#/RasterItems" />
<topicref navtitle="PlacedItems" href="#/PlacedItems" />
<topicref navtitle="EmbeddedItems" href="#/EmbeddedItems" />
<topicref navtitle="MeshItems" href="#/MeshItems" />
<topicref navtitle="GraphItems" href="#/GraphItems" />
<topicref navtitle="PluginItems" href="#/PluginItems" />
<topicref navtitle="NonNativeItems" href="#/NonNativeItems" />
<topicref navtitle="Views" href="#/Views" />
<topicref navtitle="Variables" href="#/Variables" />
<topicref navtitle="DataSets" href="#/DataSets" />
</topicref>