Skip to main content
Known Participant
April 23, 2009
Question

SetArtUserAttr(art, kArtHidden, 0); not working in CS4

  • April 23, 2009
  • 1 reply
  • 991 views

I have a CS3 plug-in that I have converted to CS4. Part of the process is that I hide text objects and save layers as PDF files. At the end of the process I want to show all the objects that I have hidden so that I can save as an Illustrator CS2 file for archiving. To do this I execute the following code by calling ShowAllArt(); below. The call to SetArtUserAttr works fine in CS3 so when I save as an Illustrator CS2 file and re-open the save file, all objects are visible. When I do the same in CS4, SetArtUserAttr returns kNoErr but on opening the Illustrator CS2 file, the text objects are still invisible in the layers palette. Is there something I should do in CS4 before I save (like sAIUtils->AppIdle();) ?

static void ShowAllArt (AIArtHandle inArt)

{

if (inArt)

{

sAIArt->SetArtUserAttr (inArt, kArtHidden, 0);

short type;

if (!sAIArt->GetArtType (inArt, &type))

{

if (type == kGroupArt)

{

AIArtHandle child;

if (!sAIArt->GetArtFirstChild (inArt, &child))

{

while (child)

{

ShowAllArt (child);

if (sAIArt->GetArtSibling (child, &child))

break;

}

}

}

}

}

}

static void ShowAllArt ()

{

AILayerHandle theLayer;

long count;

ReturnIfError (sLayer->CountLayers (&count));

for (long i = 0; i < count; ++i)

{

if (!sLayer->GetNthLayer (i, &theLayer))

{

if (theLayer)

{

sLayer->SetLayerVisible (theLayer, true);

sLayer->SetLayerIsTemplate (theLayer, false);

AIArtHandle art;

if (sAIArt->GetFirstArtOfLayer (theLayer, &art))

return;

while (art)

{

ShowAllArt (art);

ReturnIfError (sAIArt->GetArtSibling (art, &art));

}

}

}

}

}

This topic has been closed for replies.

1 reply

A. Patterson
Inspiring
April 24, 2009

I just checked, and SetArtUserAttr() still works as expected in CS4, so it's not that function. It could be some kind of oddity with regards to timing when saving back to CS2, I don't know.

BTW, this block:

while (art)

{

ShowAllArt (art);

ReturnIfError (sAIArt->GetArtSibling (art, &art));

}

...is unnecesary. The first art of every layer is always a group that represents the layer. So your recursive function has already taken care of the top-level of art. You can just call ShowAllArt (art) and that should do the whole layer. I don't think that would cause your problem, but it would definitely make it run faster

Alternately, if you're just trying to put the document back the way it was before you started your operation, a much faster method would be to undo your changes using:

sUndo->UndoChanges()