Skip navigation
ExoRider
Currently Being Moderated

AICS6: Dictionary not saved / Different ArtHandle ?

Aug 13, 2013 1:03 AM

Tags: #illustrator #copy #sdk #cs6 #reference #dictionary #not_saved

Hello everybody,

 

I'm facing an issue when trying to set an entry value in an art object's dictionary with AICS6 SDK.

I have a native winow handler set on a toolbar where I have set a few buttons.
bar.jpg

 

When I click on the "Outline" button, it is supposed to set an entry (named "FB_CurveType") in the dictionary of the selected art object.

 

  newKey = pAIDictionary->Key("FB_CurveType");

 

          pAIArt->GetDictionary(hArt, &dataDict);

          pAIDictionary->SetIntegerEntry(dataDict, newKey, type);

          pAIDictionary->Release(dataDict);

 

          pAIArt->DisposeArt(hArt);

 

The Art Handle named "hArt" is returned by a wrapper function called GetCurrentSelection() :

 

AIArtHandle GetCurrentSelection()

{

          AIArtSet set;

          AIArtHandle hnd;

          size_t count = 0;

 

  pAIArtSet->NewArtSet(&set);

  pAIArtSet->SelectedArtSet(set);

  pAIArtSet->CountArtSet(set, &count);

 

          if(!count)

                    return NULL;

 

          pAIArtSet->IndexArtSet(set, 0, &hnd);

          pAIArtSet->DisposeArtSet(&set);

          return hnd;

}

 

The returned art handle is valid (not NULL) and I can successfully set the value, and re read it immediatly after setting it (even when disposing/re-getting a reference to the dictionary).

 

The problem comes when I click on "Get Data", it is supposed to loop through each art handle in the document, and check if it has an entry called "FB_CurveType" in its dictionary. Unfortunately, the returned Art Handle's dictionary is empty, and no error code is returned by the SDK functions.
I have also noticed that the art handle's value is not the same as the one in the selection code above, at first I thought "Well, maybe that's because Illustrator returns some dynamicaly allocated pointer or something", but when I'm clicking on "Outline" again, the art handle's value is the same as the one in the previous call.

 

My guess is that my function to get all the art objects in the document makes an older or a pale copy of the real art object. Here is the function :

 

void GetArtsByType(AIArtType artType, AIArtSet set)

{

          AIArtSpec specs[1];

          pAIArtSet->NewArtSet(&set);

 

          specs[0].type = artType;

          specs[0].whichAttr = 0;

          specs[0].attr = 0;

 

 

          pAIArtSet->MatchingArtSet(specs, 1, set);

}

 

I'm looking forward for your help because you are my last resort !

Thanks in advance !

 
Replies
  • Currently Being Moderated
    Aug 19, 2013 10:00 AM   in reply to ExoRider

    Sorry about the delay, been on vacation!

     

    I've never seen any evidence that Illustrator creates stale or pale copies of artwork with ArtSets, so that shouldn't be the problem. How are you creating those buttons on the toolbar? Presumably you're using a 3rd party toolkit or an OS API to create the buttons?


    If so, are you creating an ApplicationContext in your click handler? If not, you can get wierd results. I wouldn't have thought you'd see something like this, but it's possible that without you'd getting a strange transaction merge happening or something like that. If you're not using a context, add one (you don't need to call anything, just create it) and that should be enough. That might solve your problem.

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 21, 2013 5:25 AM   in reply to ExoRider

    Nested contexts shouldn't be bad, you just need to have at least one somewhere or you get strange results -- hence that being my (almost always!) first suggestion. It sounds like you're fine though (you're doing it for all buttons presumably), so it's not that.

     

    Re-reading your original post, I think I have an idea though. You mention that the art handle isn't the same when you read the dictionary as it is when you write out the dictionary. I'm about 99% sure you're not reading the dictionary of the same object you write to.

     

    Handles in AI don't actually change. There are a few odd exceptions to that, but by & large they don't change. That's not to say you should depend on it 100%, because as I said, there are some exceptions, but if you're selecting art, clicking your button, then clicking the other button and you haven't done anything else, I'm very confident you're not talking to the same art object. A simple test is to get the AIArtType (AIArtSuite::GetArtType) of both handles before you try and access the dictionary. That might reveal a difference. You're using two different methods to get a list of art in the document and I'm not even sure I'd trust the same method to necessarily return the art in the same order if invoked twice (probably it would, but I won't assume that). My guess is you're *probably* getting the layer's group art in the Get Data click, but it could be something else. Even an empty document has at least one art object because a document must have at least one layer & that layer is represented in the art tree by a group.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points