sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Slice a model to a series of Jpegs

    Scheduled Pinned Locked Moved Plugins
    14 Posts 4 Posters 809 Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M Offline
      makingfoamfly
      last edited by

      I ran the slicer plugin and while it took a while it did seem to work. However manually zooming and exporting isn't practical if there is 5,000 slices in a single model. Now if we can find an automated way then we got something

      1 Reply Last reply Reply Quote 0
      • M Offline
        makingfoamfly
        last edited by

        I have found a way to mod the slicer script to get what I need. While its not dumping out an image format as I couldn't find a way to import a gem into a script (I am new to ruby so please let me know if there is a way) I ended up going to a custom xml format and displaying direct from the control software. I know svg may have been better but I am not familiar with the format yet and this was quicker to produce. Thank you to everyone who spent some time with this thread.

        1 Reply Last reply Reply Quote 0
        • TIGT Online
          TIG Moderator
          last edited by

          There are tools in the API to output views as images and much more.
          See the API docs http://code.google.com/apis/sketchup/docs/...]
          Make a folder to hold the images - imgfolder=File.join(File.dirname(model.path),"Images") Dir.mkdir(imgfolder) if not File.exist?(imgfolder)
          Iterate through the array of flattened slice groups [you have it made already from groups=fslice.entities.to_a] - groups.each{|group|.....}.
          You can use that within a modified version of Slicer OR make your own standalone tool to work after Slicer is done, working on the pre-selected 'FLAT...' group - groups=model.selection[0].entities.to_a
          Processing each 'group' in turn you need to...
          Empty the current selection - model.selection.clear
          Add the group - model.selection.add(group)
          Then change to plan view [parallel] - Sketchup.send_action("viewTop:")
          Then use Sketchup.send_action("viewZoomToSelection:")
          Then model.active_view.camera.perspective=false
          With that as the view you can write an image-file - using the group.name as part of its title...
          imgname=group.name+".png" imgpath=File.join(imgfolder,imgname) keys={ :filename => imgpath, :width => 640, :height => 480, :antialias => false, :compression => 0.9 } puts imgpath model.active_view.write_image(keys)
          Repeat till all groups processed...
          Where the keys set whatever values you want...

          This is only partial code... I'll write a new method for Slicer and post is soon... πŸ˜„

          TIG

          1 Reply Last reply Reply Quote 0
          • TIGT Online
            TIG Moderator
            last edited by

            Here's Slicer v4.3 http://forums.sketchucation.com/viewtopic.php?p=336616#p336616
            An Image export option has been added.
            Usage:
            Run the main Slicer tool and make your flatten slices set.
            Then preselect the 'Flat-Slice-nnnnnnnn' group and type into Ruby Console: Slicer::images
            It then makes .png image files of 0.9 quality, with no anti-aliasing, each named after the slice; all within a folder with the model, named 'ModelName-Slice-Images-nnnnnnnn'. All images are made the same size [based on the screen] with the relative size of each slice maintained in the 'pixel sizes', so subsequent auto-cropping of the white-space leaves images that are all 'relatively sized'...
            Tip: use a Style with a white '[back]ground', no profiles, no extensions, no endpoints etc so the images are as sharp as possible.

            If you what something other than a .png image you can easily edit the code to make say .jpg images... πŸ€“

            TIG

            1 Reply Last reply Reply Quote 0
            • pilouP Offline
              pilou
              last edited by

              So no problem of proportion if I print these images?
              A square will be a square when printed?

              Frenchy Pilou
              Is beautiful that please without concept!
              My Little site :)

              1 Reply Last reply Reply Quote 0
              • TIGT Online
                TIG Moderator
                last edited by

                @unknownuser said:

                So no problem of proportion if I print these images?
                A square will be a square when printed?

                Should be - at least within 1 pixel as that's the accuracy we can write and image at πŸ˜‰
                If you have say a 1m square slice [max size] in a set of slices that goes down to a 100mm x 100mm square [min size], whilst every image might be 1200px x 1700px from your screen-size - the max square might be represented by a 1100px square, centered within its larger image-rectangle... BUT the min square will also be 'pro rata' and occupy only a 110px square, also centered in its image-rectangle. So if you print the images at 'full size' [or for that matter any reduced/enlarged format, provided that 'scaling' is consistently used for all the images] then the resulting slice of each image-print will remain at the correct relative size, when compared to the other slices... πŸ€“
                To save printing materials you could also pass all of your images through a batch-editor [e.g. a Gimp plugin] which could auto-crop all of them to remove the outer 'white-space' around the images' slice-pixels. Images could then be combined onto one sheet [knowing that they are all relatively sized to one another]... so that when printed off you'll use a lot fewer sheets of paper/card/board etc. The small reference number appears at the bottom left of all of the slices so you can sort out which is which when you are trying to reassemble them later πŸ˜‰

                TIG

                1 Reply Last reply Reply Quote 0
                • M Offline
                  makingfoamfly
                  last edited by

                  Tig, You are awesome! Thank you so much for your help. I will grab the new version and try it as soon as I can.

                  1 Reply Last reply Reply Quote 0
                  • BoxB Offline
                    Box
                    last edited by

                    Tig, this is a fantastic addition to an already wonderful tool.
                    I'm mobile for a while so can't actually test it but will as soon as I get near a computer.

                    But, from my read of what's happening here I thought I could make one suggestion.

                    For those of us that do use slices for construction quite often, exporting at full size in .DWG or various other formats would be a Godsend. I know you mentioned being able to chage that in the ruby, but I for one wouldn't have a clue how.

                    Just to explain the usage I see for it.
                    Take a model of Churchill's famous figure. Slice it and export just the lines of the slices in a format that can be read one to one by a plotter/vinyl cutter or a laser engraver/cutter.
                    This can then be used to construct a life size, layered replica.

                    I actually do it manually with layers of glass, but I see so many uses for it.

                    Up till now I have been manually transfering each section and converting it, it's a lot of work.

                    1 Reply Last reply Reply Quote 0
                    • TIGT Online
                      TIG Moderator
                      last edited by

                      At the moment it only writes images [i.e. any of the types supported by SUp = png, jpg, tif, bmp etc] - it defaults to 'png'... but a simple edit of a line of code allows any other type too...

                      Rather than the latest Slicer::images we could envisage a similar tool Slicer::dxfs [or ::whatever_format_you_need], with appropriate adjustments to the code so that it export each flattened-slice as a separate file, like a 'dxf' or whatever...

                      Let me know how you might see this evolving... ❓

                      TIG

                      1 Reply Last reply Reply Quote 0
                      • BoxB Offline
                        Box
                        last edited by

                        Excellent Tig, thanks, it's nice to know you will look at it.
                        I'm at sea again for a while but will get back home eventually and I'll sort out the best exports for what I do. Off the top of my head I know .dwg work for my plotter, not sure of the file format for the laser cutter, don't actually have it in hand yet, but it will be capable of cutting 900mm wide by 2000mm long.
                        In the meanwhile, if anyone else sees the benefits and knows the format they need.......

                        Sorry, hate using a phone for this stuff, typing is a pain, and satellite connection is so hit and miss.

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        • First post
                          Last post
                        Buy SketchPlus
                        Buy SUbD
                        Buy WrapR
                        Buy eBook
                        Buy Modelur
                        Buy Vertex Tools
                        Buy SketchCuisine
                        Buy FormFonts

                        Advertisement