Does anyone know how to make a automation plugin determine the group and layer hierarchy in Photoshop using the SDK?
My plugin already enumerates layers and I found that groups are included in the flat list appearing as normal layers. Now I want the plugin to actually know the hierarchy of groups and layers but I am not sure how to get the hierarchy information.
Has anyone done this kind of thing before?
Cheers,
Ashley Davis
Determine group and layer hierarchy...
(i tried to paste a sample, but it doesnt work with the html editor)
Determine group and layer hierarchy...
Personnaly, i have modified the Getter sample of the SDK to get same this (it was a speed issue with scripting). There where some difficulties, but it would probably be trivial for someone with more experience.
But the description i get from this is not hierarchical, the layers being listed one after another. There is attributes like ''layerSection'' that give the information needed to reconstruct a ''clean'' hierarchy.
I had to add a second ''pass'' to read this XML and output it in a more typical representation. I have another similar problem with this, i have script that output the vectors path in readable xml descripting, the pluggin output the data but way more faster (like 10 minutes instead of 1h30 to parse a heavy document with alot of nested groups and layers and path on group). But the output from the pluggin even if it is complete and logical is hard to work with (say to read it back and display it in another software).
But i would be surely curious to hear if there is another way to do this...
Ashley_Davis_75@adobeforums.com wrote:
%26gt; Does anyone know how to make a automation plugin determine the group and layer hierarchy in Photoshop using the SDK?
%26gt;
Here's my script that does a full XML dump of docs, layers, apps, etc...
http://ps-scripts.cvs.sourceforge.net/*checkout*/ps-scripts/xtools/apps/GetterDe mo.jsx
The output loads up into a web browser pretty well (within reason).
The XML I use for translating ActionDescriptors is fully reversible which is why
it may seem a bit verbose in places: it needs to be.
-X
--
for photoshop scripting solutions of all sorts
contact: xbytor@gmail.com
I retought about it and maybe you where just asking about the format.
If you have a folder organisation like this:
Group a
- Layer a
Group b
- Group c
- Layer b
You will should get form you layer list output, not 5, but 8 layers. (layer sets will are listed as ''two layers'' in the data structures).
Xbytor can confirm this or maybe you know already, but i think background layer has to be checked out separatly.
So for the exemple i give here, my xml help me getting this info (info i get from getter pluggin.. wich i converted in a readable XML format instead of ''code'' output).
Layer keyname=''Group a'' LayerSectionType=''LayerSectionStart''
Layer keyname=''Layer a'' LayerSectionType=''LayerSectionContent''
Layer keyname='''' LayerSectionType=''LayerSectionEnd''
Layer keyname=''Group b'' LayerSectionType=''LayerSectionStart''
Layer keyname=''Group c'' LayerSectionType=''LayerSectionStart''
Layer keyname=''Layer b'' LayerSectionType=''LayerSectionContent''
Layer keyname='''' LayerSectionType=''LayerSectionEnd''
Layer keyname='''' LayerSectionType=''LayerSectionEnd''
If you read the data and use the property as flags, it's easy to get the hierarchy.
To output in XML, you would output Open tag for layerSectionStart, close tag for layerSectionEnd and Open AND Close tag for layer sectionContent.
If you follow the order from top to bottom, you will rebuild the hierarchy... (i did this part in applescript and it was really simple)
I'm not sure if this is of help to you... if it is, just tell me if there is something that is not clear enough.
EricGagnon@adobeforums.com wrote:
%26gt;
%26gt; Xbytor can confirm this or maybe you know already, but i think background layer has to be checked out separatly.
Yep. It's a special case.
-X
Thanks Eric,
That information is really useful.
Do you know how to extract the LayerSectionType for a layer using the C++ SDK?
Cheers,
Ashley Davis
In fact, if you compile getter and install the pluggin and run it From File/Automate menu... you will find in the ouput c++ formatted code that will help you getting this. (it's very similar to the actionlistener pluggin the guys are using to get the same info but via javascript).
Check GetLayerInfo() in GetInfoFromPhotoshop.cpp (getter sample of the SDK)and have a look at PIUDumpDescriptor (and PUIDumpDescriptorInfo) wich goes through the ''result'' recursively if you want to have a better understanding of how all this work together (maybe you know already?).
I cant help you much more than that as i'm new to all this too.
Subscribe to:
Post Comments
(Atom)
No comments:
Post a Comment