nicklockwood / ShapeScript

The ShapeScript 3D modeling app for macOS and iOS
https://shapescript.info
MIT License
393 stars 18 forks source link

Feature request: Parallel extrude along path #11

Closed jaikdean closed 1 year ago

jaikdean commented 1 year ago

The existing “extrude along path” feature extrudes perpendicular to the path, like the red image. It would be useful to allow parallel extrusion along a path, like the blue image.

Screenshot 2022-11-15 at 14 45 48
nicklockwood commented 1 year ago

Thanks for the suggestion - I'm just looking into this now, but I've found some bugs in the current implementation and I'm having a bit of trouble recreating either of these shapes. Do you happen to have a snippet of ShapeScript code to produce the left hand shape that I can use for testing?

jaikdean commented 1 year ago

This gives a rough approximation of the perpendicular vs parallel extrude along paths.

define sweepPoints (
    (1.000157 0.002094)
    (0.998642 0.002569)
    (0.994106 0.003984)
    (0.986575 0.006316)
    (0.976089 0.009524)
    (0.962709 0.013555)
    (0.946509 0.018343)
    (0.927582 0.023810)
    (0.906037 0.029875)
    (0.881997 0.036445)
    (0.855603 0.043428)
    (0.827009 0.050725)
    (0.796385 0.058239)
    (0.763914 0.065870)
    (0.729788 0.073517)
    (0.694216 0.081078)
    (0.657412 0.088451)
    (0.619601 0.095532)
    (0.581016 0.102217)
    (0.541894 0.108401)
    (0.502481 0.113980)
    (0.463021 0.118853)
    (0.423763 0.122921)
    (0.384955 0.126093)
    (0.346846 0.128290)
    (0.309677 0.129441)
    (0.273687 0.129495)
    (0.239109 0.128415)
    (0.206162 0.126188)
    (0.171835 0.122326)
    (0.139362 0.116037)
    (0.109873 0.107670)
    (0.083605 0.097631)
    (0.060740 0.086326)
    (0.041395 0.074153)
    (0.025636 0.061477)
    (0.013484 0.048626)
    (0.004914 0.035872)
    (-0.000128 0.023429)
    (-0.001729 0.011445)
    (0.000000 0.000000)
)

define sweepPath path {
    for i in sweepPoints {
        point i
    }
}

define star {
    path {
        for 1 to 5 {
            point 0 -0.05
            rotate 1 / 5
            point 0 -0.1
            rotate 1 / 5
        }
        point 0 -0.05
    }
}

// Perpendicular
extrude {
    position 0 0.5 0
    star
    along sweepPath
}

// Parallel
group {
    loft {
        orientation 0 -0.5 0

        for i in sweepPoints {
            translate 0 i.y i.x
            star
            translate 0 -i.y -i.x
        }
    }
}
Screenshot 2022-11-18 at 16 41 12 Screenshot 2022-11-18 at 16 41 22
nicklockwood commented 1 year ago

@jaikdean this is implemented in the latest version. Use axisAligned true per the example here: https://shapescript.info/mac/builders.html#extrude