Skip to main content
Known Participant
October 11, 2009
Question

using GetMatchingArt

  • October 11, 2009
  • 1 reply
  • 2757 views

Hello,

I'm trying to do something with every selected element.

My testdocument contains two groups on one layer. Each group contains one symbol and one text element.

From the first group only the symbol is selected, the second group is fully selected.

With this piece of code I get to much elements in selCount. Selcount gives me a count of 6 items. How can I reduce this so I get only one Group and the symbol. Becouse this is only a sample the real question is how to get a list of only these elements which the user has selected without any parent groups, layers etc. 

spec.whichAttr = kArtSelected;

spec.attr = kArtSelected;

spec.type = kAnyArt;

sAIMatchingArt->GetSelectedArt( &theArtStore, &selCount);

Thanks
Michael

This topic has been closed for replies.

1 reply

A. Patterson
Inspiring
October 13, 2009

I don't think there's any way to refine the call to get that narrow a focus I'm afraid. AIArtSetSuite::SelectedArtSet() works in a similar manner (it probably calls GetMatchingArt actually internally) and it suffers from the same problem. Your best bet is to use one or the other and then iterate over the result throwing away any kGroupArt handles you don't care about.

One word of warning from my own experience: compound paths tend to show up as the kCompoundPathArt, and each of the kPathArt components individually. That one you can fix though, since there's an attribute kArtPartOfCompound. Just a head's up on that one, though I don't know how you want paths & compound paths to be reported to you.

Known Participant
October 13, 2009

Hello Andrew,

should it be the truth that there's no way to get only the elements the user has clicked/selected?

Is it really impossible to distinguish between a group where only the group is selected by the user or all its members :-(

My plugin should in the first case process only the group and in the other case only the members.

Hello ADOBE!!! How could this done?????

Michael

A. Patterson
Inspiring
October 13, 2009

They're not wrong though. The art is stored in a tree, and as such it has hierarchical properties. One of those is that some properties are inherited up and down the tree. A good example of that is selection -- if an object is selected, its parent is selected. The logic is fairly inescapable -- after all, if something in a group is selected, the group is also selected, at least partially. This is why you get the behaviour you get with these methods. It can be a little annoying -- believe me, I have a lot of code in this SDK! -- but it can generally be worked around fair easily. The benefits of the art tree on the other hand are plentiful and I make use of them all the time -- you just have to bear in mind that it is, in fact, a tree.

Its still a fast operation to collect selected art this way and simply discard the ones you're not interested in. And their approach satisfiies the large majority of SDK development, which is plugins that run on selected art, typically in a pass or two modifying select types of art.

Also, I don't believe you can select an empty group. I could have that wrong, but I don't think so. I also think its fairly hard to get an empty group in the art tree (without using the SDK to acheive it specifically) -- AI typically deletes groups once they become empty if you use their UI. Lastly, I'm not sure its possible to select *just* the group without selecting all the art inside it. So those cases really don't actually happen.