GroupOverlappingObjects is a script that analyzes your selection and creates discrete groups for any objects that are touching each other.
I often need a script like this for less than 100 objects so it serves my purposes. It's almost instantaneous on objects less than 20, but I'm a little disappointed with the speed of this one when processing a larger number of objects.
I tried to rebuild the code using bitshifting to keep track of the overlaps, and the test code worked so much faster, but unfortunately it created a buffer overflow on 100 objects, so I'm posting this version, because it's more robust, and it's finished. :) I may re-address this code at a later date, but meanwhile if you're in a pinch to group a lot of objects, give it a shot.
Friday, April 18, 2008
Monday, April 14, 2008
Never Say Die
This morning I got a request from Karl Stanton from Melbourne, asking about "changing the color of an object inside a blend."
Sadly(...maddeningly...frustratingly), as you may know, access of a "plug-in" item is not directly possible using JavaScript.
Now, I saw the word "plug-in" in his email, and immediately thought "hopeless" and I told him it was not possible.
Not easily discouraged, Karl wrote back and suggested that it may be possible to access the objects color indirectly using the swatch palate. He was, however, having trouble getting the object to stay bound to the swatch when the swatch was changed with JS.
I ran a quick test myself and was able to make it work by setting the swatch to a spot color, and then changing the RGB color values inside the spot, i.e.;
var doc = activeDocument;
doc.swatches["MyCustomSpotColorName"].color.spot.color.red=3;
Had Karl given up after my first response, or had I persisted in my belief that it was impossible, we would never have discovered that changing a color inside a plug-in object actually IS possible. So folks... The moral of the story (or the morrel if you like mushrooms), is "Never Say Die."
And on that front... "Hi everybody..."
...I have a neat 'grouping' script coming soon... I promise...
stay tuned,
-J
Sadly(...maddeningly...frustratingly), as you may know, access of a "plug-in" item is not directly possible using JavaScript.
Now, I saw the word "plug-in" in his email, and immediately thought "hopeless" and I told him it was not possible.
Not easily discouraged, Karl wrote back and suggested that it may be possible to access the objects color indirectly using the swatch palate. He was, however, having trouble getting the object to stay bound to the swatch when the swatch was changed with JS.
I ran a quick test myself and was able to make it work by setting the swatch to a spot color, and then changing the RGB color values inside the spot, i.e.;
var doc = activeDocument;
doc.swatches["MyCustomSpotColorName"].color.spot.color.red=3;
Had Karl given up after my first response, or had I persisted in my belief that it was impossible, we would never have discovered that changing a color inside a plug-in object actually IS possible. So folks... The moral of the story (or the morrel if you like mushrooms), is "Never Say Die."
And on that front... "Hi everybody..."
...I have a neat 'grouping' script coming soon... I promise...
stay tuned,
-J
Subscribe to:
Posts (Atom)