[JS] 3D Extrude Object Script
Copy link to clipboard
Copied
Brought to the idea by dreamriverdesign's question of how to script a 3D box extrude from an image, I decided to try this for any object. It was a bit of a struggle, trying to get the curved lines just right, but I think I got it (almost
The script asks for the extrusion color and offsets, and can optionally combine the extrusion (making the black part above a single object) or leave it as numerous little objects, and/or group the extruded part together with the original.
Download the script from http://www.jongware.com/binaries/extrude.zip
It works on CS, I haven't been able to test on CS2, CS3, or CS4, so please report back if it doesn't work.
Copy link to clipboard
Copied
You are amazing!
In CS3, the script choked on
b.strokeStyle = app.strokeStyles[0];
A quick look at Indesign CS3.chm showed that GraphicLines want a strokeType, so I replaced it with
b.strokeType = "Solid";
and it worked perfectly on polygons and outlined text. I haven't examined any curves too closely yet...
Noel
Copy link to clipboard
Copied
Good catch, Noel. My home version is CS, and it seems that has been changed somewhere in time. I included a rather ad hoc fix -- it just might work.
Meanwhile, I was wondering if it was possible to expand or contract the extrusion. Just guess ..
The new version is http://www.jongware.com/binaries/extrude-1.01.zip
By the way, both offsets set to 0 and both scaling to 100% will give you an error from the pathfinder. Well ... in that case you wouldn't get any extrusion anyway, so don't do it.
Copy link to clipboard
Copied
A quick look at Indesign CS3.chm ...
*cough* (embarrassed)
Copy link to clipboard
Copied
Hi Jongware,
You are very full of surprises 🙂
Do you mind if I post your script in this forum ?
http://creative.mediabox.fr/index.php?showforum=60
regards,
loic
Copy link to clipboard
Copied
Please do! I am pretty content with it, and I'd be happy to see the WordArt others can create with it.
My French is rusty ("rusté", perhaps?), but I see your name and Laurent's there, and I'm sure Marc Autret is out there somewhere as well, so it's assured quality all the way. [Unlike some Indian and Chinese sites which I won't mention because I'm mad at them.]
Be sure to post the last version (http://www.jongware.com/binaries/extrude-1.02.zip) as the older ones has a nasty visual bug re: curves.
Copy link to clipboard
Copied
Hi Jongware,
I am pleased about your answer. Your french is not rusté but "rouillé" 😉
I am posting your script asap on the Mediabox forum. I don't think we had the pleasure yet to see Marc Autret on this website but as the scripting section is new, maybe the javascript smells are going to tease him soon 😄
I will encourage readers to post you comments.
Congrats for your talent and scripting skills, I wish I have time to practicize more :-S
Bye Loic
Copy link to clipboard
Copied
Hi Jongware-
I just tried the script with CS4 and it doesn't seem to do anything. Well, it looks like it's trying (I get a beachball cursor) but there is no result on the page. It works fine for me in CS3. In spite of the CS4 problem, I think it's very cool. Thanks.
-Mike
Copy link to clipboard
Copied
Hi Mike,
Well, that's weird. It works fine for me under CS4. Perhaps there was something odd in the shape you tried? Or did you up the Divisions number a lot? It uses a recursive call to itself, so a high value just may crash ID internally.
That said, it may take a while to render a moderately complicated object, although I get a madly flickering beachball-and-watch, and actually see the progress the script makes. This image took quite a while, on a 3GHz Mac:
Copy link to clipboard
Copied
Hi Jongware-
It works now! I don't think it was my short attention span since I was only trying to extrude a square, and it goes pretty quick now (nearly instant). Not sure but maybe restarting CS4 helped? I crashed last night and the script works like a charm today. I even enjoy taking apart the pieces of the extrusion to make other weird shapes. Thanks again!
-Mike
Copy link to clipboard
Copied
Jongware's script. Type on a path. Gradient fill. Outer glow. (Maybe I overdid it.)

Copy link to clipboard
Copied
YOU ROCK!!!!
Copy link to clipboard
Copied
A week ago I said
... tight curves appear 'copied' rather than extruded along the most extreme curved edge. But the math to get that right is horrible.
and I stand by that. The problem is how to calculate a tangent to a bezier curve at the precise angle (dx/dy), and I'm not that good in math.
Fortunately, many roads lead to Rome (and if you happen to be a true Roman, many roads lead away from it as well). I chose the easier road: I added a piece of code to sub-divide each curve into straight segments and used that to add the drop box segments. Sub-dividing random curves into a fixed number of straight lines sometimes leads to unseemly angles, especially if the entire curve is rather large, or it bends around itself tightly. So I added the 'flatten path' box: a high number will lead to a more precise curve (because more segments are created), but will make the script run slower. Try a higher value if you are not satisfied.
The subdivision code appears courtesy of Maxim Shemanarov, one of my heroes, as he singlehandedly programmed an entire low level antialiased graphics library! It seems he has no problems at all with the required maths... (Do visit www.antigrain.com if that sounds interesting!)
The new script is downloadable from my site: http://www.jongware.com/binaries/extrude-1.02.zip
Copy link to clipboard
Copied
Ha -- I accidentally removed the 'widen' option. Restored (extrude-1.02.zip is updated).
Here is an image. Note the flattened curves -- it's just visible in the wireframe.

