I need to make shapes like this based on a value for graph purposes - usually I would just create a cutting shape based on trig (this shape representing around 60%) and subtract it from the path - I have about 30 graphs to do and I need to base it on a variable, and I want to use script - I'm sure there must be a better way, and I'm hoping you guys have the answer.

"Minus Back" needs an action in Illustrator!? Gosh. I have been programming something for InDesign for a while now, having all kinds of fun with (let me check) ... add and intersect, so far. Now working something that needs subtracting as well.

I *was* thinking about it but I guess there's not going to be an Illustrator version of this!

Jong, I think in AI about half the app is plug-ins… And script gets no access to this… It's over my level but I thought that plug-ins could be wrote to allow scripting access ( photoshop has some Im almost sure ) What you can do in ID compaired to this app makes it quite <path>etic I should be a copy writer me thinks??? Scriptographer does have some of this… I've made lots of scripted use of 3d perspective grids though… Why on earth would you want to cut a simple shape an colour it up using a drawing app are you mad???

Dave, Yes this is much easier stuff to do in ID it has all the equivilent pathFinder methods… It is possible to get your paths from AI to ID via bridgetalk then manipulate and copy back but its a lot of work for something that should be in the AI toolbox anyhow… It may be possible to use AI's data driven graphics ( datasets ) for what you want but you would need to know XML for that…? An option for AI would be to add lots of path points around your circle at given distances then remove a bunch of them ( with a fat stroked path ) Thats going to involve bézier math and Im going to say goodluck at that point…

Jong, ID's path methods are good scripting fun and the one trick I had much fun with was text wrap ( off setting paths ) You can read the text wrap path point array out and apply it to other paths… I have a couple of scripts where I used this…

If you want to keep your original circle, change the last command line to:

cutoff.intersectPath(app.selection[0].duplicate());

The original circle stays selected, so you can run the script again.

Thinking: since this uses "prompt" to let you input the values, it could be rewritten to accept a range of numbers and then slice the underlying object up according to those values, having it do the calculations itself. Hmmm ...

Shall I leave that as an excercise to the Reader? After all, this is still an InDesign script ...)

Jong, shorter does not mean better… I used to be great at math while ( at school ) it's the do { nothing } with it since thats the root of my problems… Too larger gap between school & scripting to fix that now…

(g) You should see what lower grade websites I had to read today just to get my basic trigonometry right, coupled with some line-line intersection.

I couldn't resist: Here is a script that accepts any array of numbers -- they don't even have to add up to 100%. Funny thing: with a slight adjustment, you can now not only make pie diagrams, but also squares -- or whatever. Stars? Yup:

I couldn't resist: Here is a script that accepts any array of numbers -- they don't even have to add up to 100%. Funny thing: with a slight adjustment, you can now not only make pie diagrams, but also squares -- or whatever. Stars? Yup:

(Warning: THIS IS STILL AN INDESIGN SCRIPT!)

Hi [Jongware] and everyone.

Great thread. I happened to come across this thread/script (searching the forum for tint) and also then saw the accompanying thread in the indesign forum as well, great stuff [Jongware]! So I was hoping [Jongware] or someone would be willing to convert it to Illustrator JS Code? Also if possible to include the mentioned "slight adjustment" for working on whatever shaped shapes as mentioned. I really appreciate the consideration and assistance in converting this for illustrator. Thanks everyone for your time and consideration and especially [Jongware] for the nifty script!

Thanks for responding. Yeah I have seen mention through the forums about illustrators lacking vs inDesigns robust scripting control, thats too bad illustrator is not on par. Well, I guess worse case scenario, as long as the converted script makes the proper circular chart shape based upon the array numbers I can then position and use the pathfinder manually to combine the two shapes to get the desired end result.

Maybe someone can help with the conversion to illustrator of drawing the divided circle shape from the array, it looks like you have already tackled all the required math. So I guess it's just a matter of using illustrators drawing methods, using setEntirePath with the array of numbers I suppose like in CarlosCanto's example? Thanks for the assistance [Jongware] and anyone that is willing to help. Again this is a great thread with some really good nuggets in it. Thanks everyone for the assistance on this.

I was thinking that with in those bits, it could be re-coded to use illustrators pathItems.ellipse along with pathItems..add() + setEntirePath , etc., is it not quite that simple and involves more to it than what I am imagining? Myself however, looking at the inDesgn code I cant make heads or tales of the the similarities or conversion needs between the two to get there. Any further help would be greatly welcomed. Thanks everyone.

Yes I know where you come from and its a big issue for me… I came from AppleScript where the syntax like every & whose filtering worked across all apps because it opperates above them… Then you get to ExtendScript and things are not so portable… idiosyncrasies or so I like to call it id is a much newer app and it pretty much has it's own set of methods unlike the other suite apps. Makes things a little to say the least difficult for a scripter of all suite apps… Using core JavaScript Math & geometry should transend all apps if you can remember it…?

W_J_T, the handling of paths is different enough to just re-write it from scratch. Fortunately, I found some code on the web! The math is really horrible Hans Muller's Flex Blog contained *almost* ready-to-use code, only minor tinkering was necessary to adjust it for Illy.

This script prompts you for a series of numbers, adds them all up, and then shows a circle pie divided into relatively-sized slices in the center of your viewport, with a fixed radius of 100 points, and colored at random.

I briefly considered adding a hole in the middle, but ... well, maybe later. Also, maybe left as "exercise for the reader"

Ha ha, but you are comparing it against another "circle" from Illustrator!

There is no mathematically correct method to draw circles (or circle segments) exactly using Bezier curves, there always is going to be an error of some kind. In your example, the error in my code and Illy's approximation seem to add up, rather than cancel each other out, so it's highly visible.

I can live with this

A better way would have been to use my InDesign approach: take a native object (which, somewhere far in the future, just might include "real" circles) and use Pathfinder operations to cut it into pieces. This can be done manually, but as said above, Illy's scripting language isn't quite there yet. Maybe somewhere far in the future it will be.

Wow, you went all out with these examples thanks so much for your time and effort, lots to learn from in your examples. Awesome, thanks so much for taking the time to do this, really appreciated. Thanks [Jongware]!

I have a more poor mans approach in mind and will post it if I accomplish it.

---

[/Off Topic]: Is there any way to mark these answers besides "Was this helpful? Yes / No" since its not my thread, just wanted to know because this thread has a lot of nice examples in it and I wanted to give people thanks. I marked many as helpful, but was not sure if that does the trick. So many thanks [Jongware], CarlosCanto, Muppet Mark, a lot of good stuff in here by all of you. ;-)