Hot Door CORE Forum

Full Version: reordering art can confuse Illustrator
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a complex function that does a lot of manipulation and creation of path art, then returns a pointer to a group containing the finished art. Toward the end of the function, it stacks and organizes the pieces, sometimes into sub-groups, using Art::reorder(). Sometimes Illustrator seems to get overloaded and confused, and does things such as reading the location of the art incorrectly or applying clipping mask attributes to more paths than the one that was specified. After applying a clipping mask at the end of the function, I have to cycle through every other path and setAttribute(hdi::core::ArtAttrIsClipMask, false), which is usually not necessary. It seems that reordering is what throws it off.

I tried adding  HDI_CORE_ILLUSTRATOR->currentDocument()->sync() to get AI to reevaluate the location and stacking order of its art, but it didn't seem to help. Maybe sync() needs to be done only at certain times?

The function is invoked by releasing a tool or selecting a menu item, so I don't think app context is relevant.

Maybe there's simply a practical limit to how much Illustrator can do in one function.

Any suggestions would be much appreciated.

=====  edit ========

The issue above remains, but in another function, paths are drawn and then moved into a group using Art.reorder(). It worked when called from a tool's drag event or mouse up event, but reorder() failed when called from custom art's update function IF the update function were called from a CustomArtUpdateViewableArtMessageType message. I think this an important clue, but it does NOT help to book-end it with pushContext and popContext, even when also adding push/pop context with the custom art update function that called it. The custom widget that called it had push context in the mouse down and pop context in the mouse up, but that didn't help. Bookending the custom widget's drag event did it!

Prior to my further context experiments, the reorder problem in this case was also solved by simply using the CORE function draw::line where it specified the group to be placed into, thereby avoiding Art.reorder.

In the custom art update function, is there a way for it to tell if it were called directly by a plugin control or from the dispatcher? If so, it could call a simplified draw function when things are more likely to go wrong. Does it hurt to add push/pop context when it is not necessary?