Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

[JS] 3D Extrude Object Script

Community Expert ,
Jul 18, 2009 Jul 18, 2009

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

  • 😞
  • extrude.png

    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.

  • It's almost right, because tight curves appear 'copied' rather than extruded along the most extreme curved edge. But the math to get that right is horrible. You'll just have to live with that, correct by hand, or ... adjust the script (and in that case I'd love to hear from you!).
  • TOPICS
    Scripting
    9.0K
    Translate
    Report
    Community guidelines
    Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
    community guidelines
    Engaged ,
    Jul 18, 2009 Jul 18, 2009

    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

    Translate
    Report
    Community guidelines
    Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
    community guidelines
    Community Expert ,
    Jul 18, 2009 Jul 18, 2009

    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

    extrude2.png

    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.

    Translate
    Report
    Community guidelines
    Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
    community guidelines
    Community Expert ,
    Jul 18, 2009 Jul 18, 2009
    A quick look at Indesign CS3.chm ...

    *cough* (embarrassed)

    Translate
    Report
    Community guidelines
    Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
    community guidelines
    People's Champ ,
    Jul 23, 2009 Jul 23, 2009

    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

    Translate
    Report
    Community guidelines
    Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
    community guidelines
    Community Expert ,
    Jul 23, 2009 Jul 23, 2009

    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.

    Translate
    Report
    Community guidelines
    Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
    community guidelines
    People's Champ ,
    Jul 24, 2009 Jul 24, 2009

    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

    Translate
    Report
    Community guidelines
    Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
    community guidelines
    Contributor ,
    Jan 05, 2010 Jan 05, 2010

    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

    Translate
    Report
    Community guidelines
    Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
    community guidelines
    Community Expert ,
    Jan 05, 2010 Jan 05, 2010

    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:

    cs4rocks.png

    Translate
    Report
    Community guidelines
    Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
    community guidelines
    Contributor ,
    Jan 06, 2010 Jan 06, 2010

    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

    Translate
    Report
    Community guidelines
    Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
    community guidelines
    Advocate ,
    Jan 07, 2010 Jan 07, 2010

    Jongware's script. Type on a path. Gradient fill. Outer glow. (Maybe I overdid it.)

    script.jpg

    Translate
    Report
    Community guidelines
    Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
    community guidelines
    Guest
    Mar 01, 2012 Mar 01, 2012
    LATEST

    YOU ROCK!!!!

    Translate
    Report
    Community guidelines
    Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
    community guidelines
    Community Expert ,
    Jul 22, 2009 Jul 22, 2009

    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

    Translate
    Report
    Community guidelines
    Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
    community guidelines
    Community Expert ,
    Jul 22, 2009 Jul 22, 2009

    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.

    extrude1.02.png

    Translate
    Report
    Community guidelines
    Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
    community guidelines