I’ve got the basics down, but now looking to do something more complex, and unsure if it’s possible. I have imported a flat shape (a pcb), and I can extrude this out. What I want to do however is to rotate it on its axis, and then extrude it down the z-axis (not directly out from the surface). Is this possible, and if so, how?

  • @mholiv
    link
    110 months ago

    I use OpenSCAD all the time. What do you mean by “then extrude it down the Z axis”? Happy to help. Just don’t know what you mean here.

    • AndyOP
      link
      110 months ago

      Thank you! So, you can get a regular 2D shape and use the linear_extrude() function to extrude out at 90 degrees from the object. They refer to in in the docs as the equivalent of pushing playdoh through a press. And from the docs ‘In OpenSCAD Extrusion is always performed on the projection (shadow) of the 2d object xy plane and along the Z axis; so if you rotate or apply other transformations to the 2d object before extrusion, its shadow shape is what is extruded.’

      So the Z axis is no related to what I see on the screen, but is in direct relation to the original 2D image. If I were to first rotate the 2D image by 90 degrees, and then extrude, the extrusion would be on the Z axis relative to the 2D object, but the X axis relative to the rest of the project (if that makes sense).

      What I want it to extrude on the absolute Z axis of the total project, regardless of the angle of rotation of the 2D object. To put it another way, if I were to have a square on the 2D, and I rotated it 30 degrees before extruding, I would not want a cube to be formed, but rather would want a rhombohedron.

      • @wolfwood
        link
        110 months ago

        hull() between 2 cubes would be my strategy for rhombo

      • @[email protected]
        link
        fedilink
        110 months ago

        You’ll want to leverage hull! First linear extrude your PCB shape just to make it 3D, you can do something like 0.00001 then rotate to your desired angle. Make this a module then call it twice, once at wherever you want it and once more but translated on the z-axis by however high you want to “extrude”. Wrap these two up in a hull and you’re good to go!

        • AndyOP
          link
          210 months ago

          That’s awesome, thank you so much!

          • @mholiv
            link
            110 months ago

            A bunch of people beat me to it but yah hill between two objects is the way to go. Linear_extrude is best thought of as a purely 2d operation that produces a 3d object.

        • @[email protected]
          link
          fedilink
          210 months ago

          Note that this will always be convex, if your 2d shape has “holes” you’ll want to get a bit more creative, I like to do a difference to create the “negative” as a 3D shape, do the same exercise as above but translate slightly higher and lower and use ‘difference’ to create your final shape

      • @luckybipedal
        link
        110 months ago

        I’ve done something like that with a multmatrix transformation. There is an example of doing a skew transformation like that in the OpenSCAD user manual. This works with any 3D shape, not just extrusions. So you could transform a cube into a parallelepiped.