sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Layer by height

    Scheduled Pinned Locked Moved SketchUp Discussions
    sketchup
    4 Posts 2 Posters 506 Views 2 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.
    • E Offline
      ericschimel
      last edited by

      Hey all! I've got a challenge...

      I mill a lot of stuff on CNC, typically plywood and other sheet goods. I design all of it in SketchUp.

      What I do is draw the parts, and lay them flat in SketchUp and then bring them into my milling program that drives the CNC.

      When you get the parts into the milling program they are 2D. Right now I have to manually select each vector and tell the machine what to do with that vector. Sometimes it's cutting out a shape, making a pocket, or cutting a hole.

      The milling software I use can automatically make toolpaths based on vectors being on a layer, which leads me to my question:

      Does anyone know of an automatic way to put faces and lines on named layers based on their Z height? The trick here is that the height needs to be related to the thickness of the piece of wood that's being cut.. That means if I'm cutting a .25" deep pocket out of a 1" piece of plywood that pocket's Z depth is .75". Now if I wanted to mill a .25" pocket out of a .75" thick piece of plywood that pocket's Z height is .5"

      Does anyone know of a plugin out there, or some other method that I could achieve this? Here's a mockup:

      Layers_and_Entity_Info.png

      -Eric
      http://plugin.sketchthis.net
      Sketchup Kitchen Design Plugin
      Custom Models

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

        First collect all 'flat' faces to be reassigned to these layers:
        model=Sketchup.active_model; faces = model.active_entities.grep(Sketchup::Face).find_all{|face| face.normal.parallel?(Z_AXIS) }
        This example uses the ' .active_entities', but you could change it to work on a ' .selection' OR ALL faces in the model - even those that are nested inside groups or components, simply by iterating model.entities then all non-image model.definitions.entities for such faces... e.g.
        faces=model.entities.grep(Sketchup::Face).find_all{|face| face.normal.parallel?(Z_AXIS) } model.definitions.find_all{|d| ! d.image? }.each{|d| faces << d.entities.grep(Sketchup::Face).find_all{|face| face.normal.parallel?(Z_AXIS) } } faces.flatten!; faces.compact!; faces.uniq!
        Then iterate that collection of faces to set up a hash based on their 'heights'...
        fs={}; faces.each{|f| z=f.bounds.min.z; fs[z]=[] unless fs[z]; fs[z]<<f }
        Then it can make layers if needed, and change the equivalent faces to have those layers.
        fs.each_key{|z| lay=model.layers.add(z.to_s); fs[z].each{|f| f.layer=lay; f.edges.each{|e| e.layer=lay } } }
        If you want particular colors for depths it's probably best to set up your layers with colors beforehand [my 'Layers From List' plugin http://sketchucation.com/pluginstore?pln=TIG_LayersFromList will let you do that from a text list]

        TIG

        1 Reply Last reply Reply Quote 0
        • E Offline
          ericschimel
          last edited by

          All this code is a bit above my pay grade... If I get the gist it sounds like it is possible?

          -Eric
          http://plugin.sketchthis.net
          Sketchup Kitchen Design Plugin
          Custom Models

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

            I'll PM you an example RBZ.
            Watch fro it in a while...

            TIG

            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