[User]
I'd like to create a customizable 2D origami flamingo design in OpenSCAD, similar to the one described in the text. I need the design to be parametric, allowing me to adjust several key aspects, primarily the overall size, height, and thickness of both the outer and inner outlines.

Here's a breakdown of what I'm looking for:

*   **Overall Size:** The design should scale proportionally based on the user-defined maximum size for the longest side. The shorter side should automatically resize to maintain the aspect ratio of the original flamingo shape. I should be able to set this maximum size in millimeters.

*   **Model Height:** I need to be able to specify the height (thickness) of the final extruded model in millimeters.

*   **Outline Thickness:** There should be two outline parameters:
    *   **Outer Outline:** This controls the thickness of the outer edge of the flamingo.
    *   **Inner Outline:** This controls the thickness of the lines forming the inner details of the flamingo.
    Both of these should be adjustable in millimeters, and the inner outline should have a rounded end (a radius parameter).

*   **Flip Option:** I'd like a boolean option to flip the design horizontally.

The flamingo shape itself is defined by a series of 2D coordinates (points) forming both the outer boundary and the internal cutouts. These points are provided in the original description, and the code should use these exact coordinates to define the shape. The code should use polygon() to draw the outline and cutouts.

The script should begin by defining the outer points and inner points, which will be used to define both the outline and the internal cutouts. The script should also define which points will be used to create polygon cutouts. The program should perform linear extrude operations to create the specified height.

I don't need any external libraries, but it does need to scale the design based on the max size parameter and the model height parameter.

[Assistant]
customizable_origami_flamingo.scad:
```
/*
 * Customizable Origami - Flamingo - https://www.thingiverse.com/thing:2635776
 * by Dennis Hofmann - https://www.thingiverse.com/mightynozzle/about
 * created 2017-11-09
 * version v1.0
 *
 * Changelog
 * --------------
 * v1.0:
 *      - final design
 * --------------
 *
 * This work is licensed under the Creative Commons - Attribution - NonCommercial - ShareAlike license.
 * https://creativecommons.org/licenses/by-nc-sa/3.0/
 */

 // Parameter Section //
//-------------------//

// preview[view:north, tilt:top]

// The maximum size of the longest side. The shorter side will be automatically resized in same ratio.
max_size_in_millimeter = 120; //[20:300]

// The height of the model.
model_height_in_millimeter = 5; //[0.2:0.2:100]

// Thickness of the outer outline.
outline_size_in_millimeter = 1.4; //[0.5:0.1:20]

// Thickness of the inner outline.
inline_size_in_millimeter = 0.7; //[0.5:0.1:20]

// Roundiness of the ends of the inner outlines.
inline_edge_radius_in_millimeter = 0.4; //[0.0:0.1:5]

// Flip model
flip_model = "no"; //[yes,no]

/*[hidden]*/
max_size = max_size_in_millimeter;
model_height = model_height_in_millimeter;
$fn=32;

// Outer Points
A1 = [252, 247];
A2 = [203, 149];
A3 = [236, 119];
A4 = [234, 93];
A5 = [278, 37];
A6 = [311, 21];
A7 = [391, 66];
A8 = [429, 167];
A9 = [363, 390];
A10 = [388, 406];
A11 = [413, 366];
A12 = [529, 324];
A13 = [639, 324];
A14 = [799, 489];
A15 = [757, 524];
A16 = [732, 487];
A17 = [643, 499];
A18 = [629, 520];
A19 = [692, 661];
A20 = [667, 691];
A21 = [576, 687];
A22 = [521, 949];
A23 = [521, 687];
A24 = [411, 684];
A25 = [340, 707];
A26 = [400, 665];
A27 = [521, 663];
A28 = [527, 545];
A29 = [545, 527];
A30 = [537, 510];
A31 = [432, 517];
A32 = [285, 434];
A33 = [281, 398];
A34 = [399, 173];
A35 = [329, 104];
A36 = [312, 159];
A37 = [249, 169];

outline = [A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27, A28, A29, A30, A31, A32, A33, A34, A35, A36, A37];

// Inner Points
B1 = [656, 659];
B2 = [590, 578];
B3 = [580, 659];
B4 = [617, 501];

// Polygons
C1 = [A1, A2, A37];
C2 = [A2, A3, A36, A37];
C3 = [A3, A36, A35];
C4 = [A3, A35, A4];
C5 = [A4, A5, A35];
C6 = [A5, A6, A35];
C7 = [A6, A35, A7];
C8 = [A35, A7, A8, A34];
C9 = [A8, A9, A33, A34];
C10 = [A9, A33, A32];
C11 = [A32, A31, A10, A9];
C12 = [A10, A31, A11];
C13 = [A11, A12, A31];
C14 = [A31, A30, B4, A17, A16, A12];
C15 = [A12, A13, A16];
C16 = [A13, A16, A15, A14];
C17 = [A17, A18, B4];
C18 = [A30, A29, B2, B1, A19, A18, B4];
C19 = [A29, A28, B2];
C20 = [A28, A27, B3, B2];
C21 = [A23, A21, A22];
C22 = [A19, B1, B3, A27, A26, A24, A23, A21, A20];
C23 = [A26, A25, A24];
C24 = [B2, B3, B1];

cut_polygons = [C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15, C16, C17, C18, C19, C20, C21, C22, C23, C24];

min_x = A2[0];
min_y = A6[1];
max_x = A14[0];
max_y = A22[1];

x_size = max_x - min_x;
y_size = max_y - min_y;

x_factor = max_size / x_size;
y_factor = max_size / y_size;

inline_size = x_size > y_size ? inline_size_in_millimeter / x_factor / 2: inline_size_in_millimeter / y_factor / 2;
inline_edge_radius = x_size > y_size ? inline_edge_radius_in_millimeter / x_factor: inline_edge_radius_in_millimeter / y_factor;
outline_size = x_size > y_size ? outline_size_in_millimeter / x_factor - inline_size: outline_size_in_millimeter / y_factor - inline_size;

 // Program Section //
//-----------------//

if(x_size > y_size) {
    resize(newsize=[max_size, x_factor * y_size, model_height]){
        if(flip_model == "yes") {
            mirror([0,1,0]) {
                rotate([180,180,0]) {
                    create(outline, cut_polygons);
                }
            }
        } else {
            create(outline, cut_polygons);
        }
    }
} else {
    resize(newsize=[y_factor * x_size, max_size, model_height]){
        if(flip_model == "yes") {
            mirror([0,1,0]) {
                rotate([180,180,0]) {
                    create(outline, cut_polygons);
                }
            }
        } else {
            create(outline, cut_polygons);
        }
    }
}

 // Module Section //
//----------------//

module create() {
    linear_extrude(height=1) {
        difference() {
            offset(r = -0) {
                offset(r = +outline_size) {
                    polygon(points = outline, convexity = 10);
                }
            }

            for(cut_polygon = [0:len(cut_polygons)]) {
                offset(r = +inline_edge_radius) {
                    offset(r = -inline_size - inline_edge_radius) {
                        polygon(points = cut_polygons[cut_polygon], convexity = 10);
                    }
                }
            }
        }
    }
}

```


[User]
I'd like to design a decorative lantern, similar to the one described in the provided OpenSCAD code. It's cylindrical with a pattern of triangular holes cut into its surface. The key aspects I'd like to control are:

*   **Overall Dimensions:**  I need to be able to set the outer diameter, height, and wall thickness of the cylinder.
*   **Hole Size:** I need to define the size of the equilateral triangle used for the holes, specifically the length of one side.
*   **Hole Pattern:**  The triangles should be arranged in rows and columns wrapping around the cylinder.  The number of rows and columns should be automatically calculated based on the triangle size, cylinder dimensions, and some spacing between them. I'd like to have the rows staggered, so that the triangles in every other row are shifted slightly along the circumference.
*   **Hole Density:** I want to add a random element to the hole generation. This way, not every single possible hole position will be cut out. I want the option to set how densely the holes are generated, like I can specify that only 25% of the possible holes are actually cut. It would be great if this randomness was controlled by a seed that I can change in the OpenSCAD code.

I'd also like to make sure it's efficient to render, so avoid any unnecessary overlaps or other geometry that might slow down the preview. I don't have any preference on particular libraries or anything, just whatever is straightforward. I’d like all of the files in one place, so I can easily access and modify them together.

[Assistant]
Laterne.scad:
```
Dreieckseite=2;       // Size of the hole --> side of the triangle
Aussendurchmesser=45; // Outer diameter
Hoehe=70;             // Height
Wandstaerke=1.6;      // Wall thickness
Random=3;             // Possible number of holes --> 1 = maximum, 2 = 50%, 3 = 33%, 4 = 25%, 5 = 20%

LoecherUmfang=floor(180/(8*asin(Dreieckseite/Aussendurchmesser/2)));
LoecherHoehe=floor((Hoehe-2*Wandstaerke)/(Dreieckseite*sqrt(0.75)/2))-1;
echo(LoecherHoehe);

difference(){
    translate([0,0,Hoehe/2])
        cylinder(h=Hoehe,d=Aussendurchmesser,center=true);
    translate([0,0,Hoehe/2+Wandstaerke])
        cylinder(h=Hoehe,d=Aussendurchmesser-2*Wandstaerke,center=true);
    translate([0,0,Wandstaerke*1.1])
        Rosetten(Hoehe-2*Wandstaerke,LoecherHoehe,LoecherUmfang);
}
//Rosetten(Hoehe-2*Wandstaerke,LoecherHoehe,LoecherUmfang);

module Rosetten(Hoehe,AnzahlHoehe,AnzahlUmfang){
    for (i = [0:AnzahlHoehe-2]){
        translate([0,0,Hoehe/AnzahlHoehe*i])
            if ((i % 2) == 0){
                Rosette(AnzahlUmfang,0);
            }
            else {
                Rosette(AnzahlUmfang,180/AnzahlUmfang/2);
            }
        }
}

module Rosette(Anzahl, Startwinkel){
    for (i = [0:Anzahl-1]){
        rotate([0,0,180/Anzahl*i+Startwinkel])
            3dDreieck(Dreieckseite, Aussendurchmesser+2);
    }
}

module Dreieck(Seitenlaenge){
    polygon(points=[[0,0],[Seitenlaenge,0],[Seitenlaenge/2,Seitenlaenge*sqrt(0.75)]]);
}

module 3dDreieck(Seitenlaenge, Hoehe){
    r = floor(rands(0,1000,1)[0]);
    //echo(r);
    if((r % Random) == 0){
        translate([-Seitenlaenge/2,0,0])
            rotate([90,0,0])
                linear_extrude(height=Hoehe,center=true, convexity = 10, twist = 0)
                    Dreieck(Seitenlaenge);
    }
}
```


[User]
I'm looking to create a customizable 2D origami-style diamond design using OpenSCAD, similar to the one described in the provided text. I need the design to be parametric so I can adjust several key dimensions.

Specifically, I'd like the following parameters to be configurable:

*   **Maximum Size:** I need to be able to set the maximum length of the longest side of the diamond. The shorter side should automatically scale proportionally to maintain the diamond's original aspect ratio.
*   **Model Height:** The overall height/thickness of the extruded 2D shape should also be customizable.
*   **Outline Thickness:** I need to set the thickness of the outer outline of the diamond.
*   **Inner Outline Thickness:** The thickness of the inner lines/cuts within the diamond shape should also be configurable.
*  **Inner Outline Corner Radius:** The corner radius of the inner lines/cuts within the diamond shape should also be configurable.
*   **Flip Model:** I'd like a boolean option to mirror the design across the Y axis.

The provided file defines the diamond shape using specific points, but I would like this to be generated parametrically without needing to define all of the points. The design consists of an outer outline, and internal polygons that are removed to create the origami cut pattern, with some rounding of the inner lines.

Please generate an OpenSCAD file that implements this design with the above parameters. I do not need any external libraries.

[Assistant]
customizable_origami_diamond.scad:
```
/*
 * Customizable Origami - Diamond - https://www.thingiverse.com/thing:2637332
 * by Dennis Hofmann - https://www.thingiverse.com/mightynozzle/about
 * created 2017-11-10
 * version v1.0
 *
 * Changelog
 * --------------
 * v1.0:
 *      - final design
 * --------------
 *
 * This work is licensed under the Creative Commons - Attribution - NonCommercial - ShareAlike license.
 * https://creativecommons.org/licenses/by-nc-sa/3.0/
 */

 // Parameter Section //
//-------------------//

// preview[view:north, tilt:top]

// The maximum size of the longest side. The shorter side will be automatically resized in same ratio.
max_size_in_millimeter = 120; //[20:300]

// The height of the model.
model_height_in_millimeter = 5; //[0.2:0.2:100]

// Thickness of the outer outline.
outline_size_in_millimeter = 2.1; //[0.5:0.1:20]

// Thickness of the inner outline.
inline_size_in_millimeter = 0.7; //[0.5:0.1:20]

// Roundiness of the ends of the inner outlines.
inline_edge_radius_in_millimeter = 0.9; //[0.0:0.1:5]

// Flip model
flip_model = "no"; //[yes,no]

/*[hidden]*/
max_size = max_size_in_millimeter;
model_height = model_height_in_millimeter;
$fn=32;

// Outer Points
A1 = [371, 251];
A2 = [419, 251];
A3 = [477, 251];
A4 = [526, 251];
A5 = [564, 305];
A6 = [448, 463];
A7 = [333, 305];

outline = [A1, A2, A3, A4, A5, A6, A7];

// Inner Points
B1 = [391, 305];
B2 = [449, 305];
B3 = [507, 305];

// Polygons
C1 = [A7, A1, B1];
C2 = [B1, A1, A2];
C3 = [A2, B2, B1];
C4 = [A2, A3, B2];
C5 = [A3, A4, B3];
C6 = [A3, B3, B2];
C7 = [A4, A5, B3];
C8 = [A5, A6, B3];
C9 = [B3, A6, B2];
C10 = [B2, B1, A6];
C11 = [B1, A7, A6];

cut_polygons = [C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11];

min_x = A7[0];
min_y = A1[1];
max_x = A5[0];
max_y = A6[1];

x_size = max_x - min_x;
y_size = max_y - min_y;

x_factor = max_size / x_size;
y_factor = max_size / y_size;

inline_size = x_size > y_size ? inline_size_in_millimeter / x_factor / 2: inline_size_in_millimeter / y_factor / 2;
inline_edge_radius = x_size > y_size ? inline_edge_radius_in_millimeter / x_factor: inline_edge_radius_in_millimeter / y_factor;
outline_size = x_size > y_size ? outline_size_in_millimeter / x_factor - inline_size: outline_size_in_millimeter / y_factor - inline_size;

 // Program Section //
//-----------------//

if(x_size > y_size) {
    resize(newsize=[max_size, x_factor * y_size, model_height]){
        if(flip_model == "yes") {
            mirror([0,1,0]) {
                rotate([180,180,0]) {
                    create(outline, cut_polygons);
                }
            }
        } else {
            create(outline, cut_polygons);
        }
    }
} else {
    resize(newsize=[y_factor * x_size, max_size, model_height]){
        if(flip_model == "yes") {
            mirror([0,1,0]) {
                rotate([180,180,0]) {
                    create(outline, cut_polygons);
                }
            }
        } else {
            create(outline, cut_polygons);
        }
    }
}

 // Module Section //
//----------------//

module create() {
    linear_extrude(height=1) {
        difference() {
            offset(r = -0) {
                offset(r = +outline_size) {
                    polygon(points = outline, convexity = 10);
                }
            }

            for(cut_polygon = [0:len(cut_polygons)]) {
                offset(r = +inline_edge_radius) {
                    offset(r = -inline_size - inline_edge_radius) {
                        polygon(points = cut_polygons[cut_polygon], convexity = 10);
                    }
                }
            }
        }
    }
}

```


[User]
I'm looking for an OpenSCAD design for a customizable origami hummingbird. I need to be able to adjust the overall size, the height of the model, and the thickness of both the outer and inner outlines. The inner outlines should also have rounded edges. I'd also like to be able to flip the model along its horizontal axis.

The basic shape of the hummingbird is based on a series of points and polygons that I can provide, and I want to be able to scale everything proportionally to maintain the aspect ratio. I'll give the point coordinates, as well as the polygons connecting them. The design should use linear extrusion to create a flat object with the specified height.

Essentially, I need a parametric design where I can easily control these dimensions and get a 2D hummingbird shape with outlines. I'm not concerned with any 3D folding or moving parts, it is just a single extruded piece with the outlines. Could you generate the OpenSCAD code for this? I'd prefer to not use any external libraries unless absolutely necessary.

[Assistant]
customizable_origami_hummingbird.scad:
```
/*
 * Customizable Origami - Hummingbird - https://www.thingiverse.com/thing:2638920
 * by Dennis Hofmann - https://www.thingiverse.com/mightynozzle/about
 * created 2017-11-11
 * version v1.0
 *
 * Changelog
 * --------------
 * v1.0:
 *      - final design
 * --------------
 *
 * This work is licensed under the Creative Commons - Attribution - NonCommercial - ShareAlike license.
 * https://creativecommons.org/licenses/by-nc-sa/3.0/
 */

 // Parameter Section //
//-------------------//

// preview[view:north, tilt:top]

// The maximum size of the longest side. The shorter side will be automatically resized in same ratio.
max_size_in_millimeter = 120; //[20:300]

// The height of the model.
model_height_in_millimeter = 5; //[0.2:0.2:100]

// Thickness of the outer outline.
outline_size_in_millimeter = 1.2; //[0.5:0.1:20]

// Thickness of the inner outline.
inline_size_in_millimeter = 0.7; //[0.5:0.1:20]

// Roundiness of the ends of the inner outlines.
inline_edge_radius_in_millimeter = 0.1; //[0.0:0.1:5]

// Flip model
flip_model = "no"; //[yes,no]

/*[hidden]*/
max_size = max_size_in_millimeter;
model_height = model_height_in_millimeter;
$fn=32;

// Outer Points
A1 = [18, 119];
A2 = [225, 119];
A3 = [286, 93];
A4 = [355, 99];
A5 = [428, 231];
A6 = [605, 104];
A7 = [822, 55];
A8 = [665, 223];
A9 = [549, 346];
A10 = [607, 501];
A11 = [597, 769];
A12 = [501, 671];
A13 = [419, 493];
A14 = [338, 417];
A15 = [262, 218];
A16 = [217, 158];

outline = [A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16];

// Inner Points
B1 = [390, 310];
B2 = [555, 475];

// Polygons
C1 = [A1, A2, A16];
C2 = [A15, A5, A4, A3, A2, A16];
C3 = [B1, A6, A7, A8];
C4 = [A6, A5, B1];
C5 = [B1, A15, A5];
C6 = [A15, A14, B1];
C7 = [A8, A9, B1];
C8 = [B1, A14, A13];
C9 = [A12, B2, A9, A10, A11];
C10 = [A12, B2, A13];
C11 = [B2, A9, A13];
C12 = [A9, B1, A13];

cut_polygons = [C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12];

min_x = A1[0];
min_y = A7[1];
max_x = A7[0];
max_y = A11[1];

x_size = max_x - min_x;
y_size = max_y - min_y;

x_factor = max_size / x_size;
y_factor = max_size / y_size;

inline_size = x_size > y_size ? inline_size_in_millimeter / x_factor / 2: inline_size_in_millimeter / y_factor / 2;
inline_edge_radius = x_size > y_size ? inline_edge_radius_in_millimeter / x_factor: inline_edge_radius_in_millimeter / y_factor;
outline_size = x_size > y_size ? outline_size_in_millimeter / x_factor - inline_size: outline_size_in_millimeter / y_factor - inline_size;

 // Program Section //
//-----------------//

if(x_size > y_size) {
    resize(newsize=[max_size, x_factor * y_size, model_height]){
        if(flip_model == "yes") {
            mirror([0,1,0]) {
                rotate([180,180,0]) {
                    create(outline, cut_polygons);
                }
            }
        } else {
            create(outline, cut_polygons);
        }
    }
} else {
    resize(newsize=[y_factor * x_size, max_size, model_height]){
        if(flip_model == "yes") {
            mirror([0,1,0]) {
                rotate([180,180,0]) {
                    create(outline, cut_polygons);
                }
            }
        } else {
            create(outline, cut_polygons);
        }
    }
}

 // Module Section //
//----------------//

module create() {
    linear_extrude(height=1) {
        difference() {
            offset(r = -0) {
                offset(r = +outline_size) {
                    polygon(points = outline, convexity = 10);
                }
            }

            for(cut_polygon = [0:len(cut_polygons)]) {
                offset(r = +inline_edge_radius) {
                    offset(r = -inline_size - inline_edge_radius) {
                        polygon(points = cut_polygons[cut_polygon], convexity = 10);
                    }
                }
            }
        }
    }
}

```


[User]
Hi, I'm looking to generate some low-poly vases using OpenSCAD. I like the concept of the "vase_lowpoly.scad" file that I've seen, and I want to be able to create something similar, but with more flexibility.

Specifically, I'd like the following parameters to be customizable:

*   **Shape:** I need options beyond just the ones included in the example code ("cylinder", "vase1", "vase2", "glass", "bowl", "cup1", "cup2", "cone"). I want to be able to define my own custom profile for the vase shape using an equation or a set of points. Maybe a cubic spline or a linear interpolation between points?
*   **Radius:** A basic radius parameter, similar to the original, but it should probably allow for different radii at the top and bottom for more unique shapes.
*   **Spikes:** The spike option is good, but instead of just "on" or "off", I want to be able to define the size and frequency of the spikes (not just on a checkerboard pattern). Perhaps an option to place spikes on a curve around the vase?
*   **Sides:** The number of sides is good, but I'd like to explore ways to create more organic "wobbly" shapes where the number of sides is somewhat variable (maybe a Perlin noise based vertex offset applied to each level?) I also need a way to make it not uniform - some areas should be more polygonal while some are more smooth.
*   **Levels:** The number of levels is fine, but I want the vertical spacing to be non-uniform and potentially follow a curve, with more levels concentrated at certain points.
*   **Twist:** The twisting option is great, but I need a more sophisticated control, like a curve or an equation defining the twist along the vase height. A random twist option that adds variation would also be nice.
*   **Wall Thickness:** It needs to be hollow, and I need to be able to control the wall thickness. I'd like the option to have variable thickness based on a function of the height.
*   **Base:** The base should be customizable with options like a flat base, a rounded base, or a pedestal-type base, with adjustable height, radius and shape.
*   **Top:** Similar to the base, the top should have some customization - options like straight, beveled, rounded, or even a flared top with configurable parameters.
*   **Materials:** I'd like to be able to add some materials to the code, specifically for color and texture mapping if possible. If not material, then basic color for previewing.

I'd also like the following:

*   It should use modules for clarity.
*   It should be well-documented so I can easily understand how to modify it.

I'm not familiar with using any of the complex libraries, so if that can be kept to a minimum, that would be great. If it needs one though, please don't hesitate to include it. I understand this might require more than one file if a library is needed.

Thanks!

[Assistant]
vase_lowpoly.scad:
```
/*

LOW POLY VASE FACTORY

Fernando Jerez 2017
License: CC

*/

// Style / Shape
shape = "cylinder"; // [cylinder: Cylinder, vase1:Vase, vase2:Vase 2, glass: Glass, bowl:Bowl, cup1: Cup, cup2: Cup 2, cone: Cone ]

// Radius
radius= 60; // [20:100]

// Spike size
spikes = 5; //[-20:20]

// Number of Sides
sides = 20; // [3:30]

// Number of Levels
levels = 10; // [3:30]

// Twisting factor
twist = 0; //[-1:0.1:1]

/* [Hidden] */

vase();

module vase(){

altura = 180 - 180%levels; // z-steps
step = floor(180/levels); // resolution in Z (1 is the best and slower)

stepc = 360/sides; // Don't touch!

puntos = [
    for(z = [0:step:altura])
        for(i = [0:stepc:359])
            let(

                // shape
                zrad  = (shape=="cylinder") ? 1 :
                        (shape=="vase1")    ? 0.7+ 0.4*sin(z*1.9) :
                        (shape=="vase2")    ? 0.6+ 0.4*pow(sin(z+60),2) :
                        (shape=="glass")    ? 0.6+ 0.4*pow(sin(z*0.7-30),2) :
                        (shape=="cup1")      ? 0.65+ 0.3 * cos(z*2+35) :
                        (shape=="cup2")     ? 0.6+ 0.35*cos(180 - z+50)*sin(180-z*2.5+45) :
                        (shape=="bowl")     ? 0.6+ 0.4 * sin(z*0.5) :
                        cos(z*0.5),

                rad2  = ((z/step)%2==1 && (i/stepc)%2==1)?spikes:0,
                g = z*twist,

                // vertex
                r     = rad2+  zrad* radius,
                px    = r*cos(i+g),
                py    = r*sin(i+g)

            )

            [px,py,z]
];

caras = concat(
    [
    for(z = [0:(altura/step)-1])
        for(s = [0:sides-1])
            let(
                // clockwise from left-down corner
                f1 = s + sides*z,
                f2 = s + sides*(z+1),
                f3 = ((s+1) % sides) + sides*(z+1),
                f4 = ((s+1) % sides) + sides*z
            )

            ( (s+z)%2==0) ? [f1,f2,f3] : [f2,f3,f4]

    ],
    [
    for(z = [0:(altura/step)-1])
        for(s = [0:sides-1])
            let(
                // clockwise from left-down corner
                f1 = s + sides*z,
                f2 = s + sides*(z+1),
                f3 = ((s+1) % sides) + sides*(z+1),
                f4 = ((s+1) % sides) + sides*z
            )
            ( (s+z)%2==0) ? [f3,f4,f1] : [f4,f1,f2]

    ],

    (shape!="cone")?[[ for(s = [sides-1:-1:0]) (altura/step)*(sides) + s]]:[], //top
    [[ for(s = [0:sides-1]) s]] //bottom

 );
 scale([1,1,(shape=="bowl")?0.33:1])
 polyhedron (points=puntos,faces = caras);

}
```


[User]
Hey, I'm looking to create a shelf mounting bracket for a metal plug-in style shelf, and I'd like to design it in OpenSCAD. I've got a decent idea of what I need, but could use some help putting it all together parametrically.

The basic concept is this: The bracket consists of a base plate that sits against the metal shelf frame and two clips that hook around the metal rods of the shelf. The base plate should have mounting holes for screws, although I might not use them.

Here are the key parameters I'd like to be able to control:

*   `metal_thickness`:  The thickness of the metal of the shelf frame, probably around 1.2mm.
*   `slot_depth`: The depth of the clips, to ensure a good fit. I think about 1.2mm would be appropriate.
*   `clip_length`: The length of the clips, maybe around 20mm.
*   `clip_width`: The width of the clips, around 14mm is fine for now.
*   `side_offset`: The offset of the base plate from one side of the shelf, I'm using 4mm at the moment.
*   `baseplate__width`:  The total width of the base plate, let's start with 35mm.
*   `baseplate_height`: The height of the base plate, I was using 5mm.
*   `roundness`: The diameter of the round edges of the base plate for nicer looks. 2mm radius would be good.
*   `mounting_hole_diameter`: The diameter of the screw mounting holes, 4mm seems standard.

I'd want the design to have the following features:

*   A baseplate with rounded corners (like a rectangle with a fillet on the edges).
*   Two clips, one on each side, perpendicular to the base plate to engage with the shelf frame.
*   Screw holes in the baseplate, likely 4-5 of them, spaced out evenly.

I'm thinking a few things might be helpful:
*  I need the ability to specify the number of screw holes, so if 4 is too many, we can reduce to 2 or 3.
*  It would be helpful if the screw holes were automatically placed such that they were centered and spread evenly across the area.
*  I will want to use mirror operations on some of the pieces, so we'd need to make sure we're keeping things symmetrical.

Could you help me design this in OpenSCAD? I do not have any pre-existing code, and I'm not using any of the big OpenSCAD libraries (BOSL, MCAD, etc) right now.

[Assistant]
28_-_shelf_mount_for_metal_plug_shelf.scad:
```
$fn                     = 90;
//thickness of the sheet metal:
metal_thickness         = 1.2;
//thickness of the clips:
slot_depth              = 1.2;
//length of the clips:
clip_length             = 20;
//width of the clips:
clip_width              = 14;

//offset from one side of the base plate:
side_offset             = 4;
//size of the base plate in x and y:
baseplate__width        = 35;
//height of the base plate:
baseplate_height        = 5;
//diameter of the round edges:
roundness               = 2;
//diameter of the screw holes:
mounting_hole_diameter  = 4;

//private:
baseplate_width         = baseplate__width - side_offset;

//the mounting plate:
rotate([90,0,0])
{
	difference()
	{
		minkowski()
		{
			cube([baseplate_width-roundness,baseplate_height,baseplate_width-roundness],center=true);
			rotate([0,90,90])
				cylinder( d=2, center=true );
		}
		screw_hole();
		translate([baseplate_width/2*0.6,0,baseplate_width/2*0.6])
			screw_hole();
		translate([-baseplate_width/2*0.6,0,-baseplate_width/2*0.6])
			screw_hole();
		translate([-baseplate_width/2*0.6,0,baseplate_width/2*0.6])
			screw_hole();
		translate([baseplate_width/2*0.6,0,-baseplate_width/2*0.6])
			screw_hole();
	}

	//the clips:
	translate([baseplate_width/2-metal_thickness/2,baseplate_height/2+clip_length/2,side_offset/2])
		clip();
	rotate([0,90,0])
		translate([baseplate_width/2-metal_thickness/2,baseplate_height/2+clip_length/2,-side_offset/2])
			clip();
}

module clip()
{
	cube([slot_depth,clip_length,clip_width],center=true);
}

module screw_hole()
{
	rotate([0,90,90])
		cylinder( d=mounting_hole_diameter, h=baseplate_height+1.1, center=true );
}
```


[User]
I'm looking to create a customizable 2D origami deer head, similar to the one described on Thingiverse. I'd like to be able to adjust the overall size, the height/thickness of the model, and the thickness of both the outer and inner outlines. Specifically, I need a parametric OpenSCAD file that allows me to:

1.  Set a `max_size_in_millimeter` parameter. The model's longest side should be scaled to this value, while the other side scales proportionally to maintain the aspect ratio.
2.  Set a `model_height_in_millimeter` to control the height/thickness of the extruded model.
3.  Set `outline_size_in_millimeter` to determine the thickness of the outer border.
4.  Set `inline_size_in_millimeter` to control the thickness of the inner cuts/lines.
5. Set `inline_edge_radius_in_millimeter` to control the roundness of the inner outlines.
6. Have a `flip_model` option, that can be "yes" or "no", to mirror the design if needed.

The design should use the provided coordinates for the outer points (`A1` through `A46`) and the inner points (`B1` through `B20`). It should also use the provided polygons definitions (`C1` through `C52`) to define the cutouts. I'm assuming that the `cut_polygons` list is used to define which polygons are to be cut out of the main outer shape.

Please generate the necessary OpenSCAD file(s) to implement this design. I don't need any additional libraries, just plain OpenSCAD. Thank you!

[Assistant]
customizable_origami_deer_head.scad:
```
/*
 * Customizable Origami - Deer Head - https://www.thingiverse.com/thing:2639873
 * by Dennis Hofmann - https://www.thingiverse.com/mightynozzle/about
 * created 2017-11-11
 * version v1.0
 *
 * Changelog
 * --------------
 * v1.0:
 *      - final design
 * --------------
 *
 * This work is licensed under the Creative Commons - Attribution - NonCommercial - ShareAlike license.
 * https://creativecommons.org/licenses/by-nc-sa/3.0/
 */

 // Parameter Section //
//-------------------//

// preview[view:north, tilt:top]

// The maximum size of the longest side. The shorter side will be automatically resized in same ratio.
max_size_in_millimeter = 120; //[20:300]

// The height of the model.
model_height_in_millimeter = 5; //[0.2:0.2:100]

// Thickness of the outer outline.
outline_size_in_millimeter = 1.4; //[0.5:0.1:20]

// Thickness of the inner outline.
inline_size_in_millimeter = 0.7; //[0.5:0.1:20]

// Roundiness of the ends of the inner outlines.
inline_edge_radius_in_millimeter = 0.2; //[0.0:0.1:5]

// Flip model
flip_model = "no"; //[yes,no]

/*[hidden]*/
max_size = max_size_in_millimeter;
model_height = model_height_in_millimeter;
$fn=32;

// Outer Points
A1 = [162, 115];
A2 = [177, 299];
A3 = [261, 238];
A4 = [285, 78];
A5 = [295, 265];
A6 = [205, 338];
A7 = [312, 457];
A8 = [474, 294];
A9 = [367, 475];
A10 = [517, 528];
A11 = [562, 595];
A12 = [588, 587];
A13 = [621, 597];
A14 = [664, 528];
A15 = [812, 479];
A16 = [717, 321];
A17 = [872, 463];
A18 = [977, 338];
A19 = [888, 278];
A20 = [904, 93];
A21 = [925, 256];
A22 = [1008, 308];
A23 = [1010, 116];
A24 = [1043, 333];
A25 = [902, 515];
A26 = [723, 572];
A27 = [701, 620];
A28 = [788, 582];
A29 = [994, 559];
A30 = [975, 653];
A31 = [872, 782];
A32 = [740, 815];
A33 = [836, 1090];
A34 = [784, 1273];
A35 = [601, 1382];
A36 = [415, 1271];
A37 = [369, 1093];
A38 = [435, 809];
A39 = [312, 778];
A40 = [205, 655];
A41 = [186, 555];
A42 = [391, 576];
A43 = [475, 619];
A44 = [453, 575];
A45 = [282, 509];
A46 = [138, 333];

outline = [A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27, A28, A29, A30, A31, A32, A33, A34, A35, A36, A37, A38, A39, A40, A41, A42, A43, A44, A45, A46];

// Inner Points
B1 = [580, 1048];
B2 = [579, 964];
B3 = [652, 985];
B4 = [508, 985];
B5 = [467, 1059];
B6 = [583, 1103];
B7 = [703, 1060];
B8 = [522, 806];
B9 = [639, 809];
B10 = [438, 720];
B11 = [732, 720];
B12 = [582, 648];
B13 = [340, 658];
B14 = [836, 659];
B15 = [793, 630];
B16 = [382, 628];
B17 = [759, 930];
B18 = [426, 930];
B19 = [714, 985];
B20 = [465, 984];

// Polygons
C1 = [A1, A46, A2];
C2 = [A2, A6, A5, A3];
C3 = [A3, A4, A5];
C4 = [A2, A46, A45, A7, A6];
C5 = [A45, A44, A10, A9, A7];
C6 = [A7, A8, A9];
C7 = [A44, A43, A11, A10];
C8 = [A13, A14, A26, A27];
C9 = [A14, A15, A17, A25, A26];
C10 = [A15, A16, A17];
C11 = [A17, A18, A22, A24, A25];
C12 = [A22, A23, A24];
C13 = [A22, A21, A19, A18];
C14 = [A21, A20, A19];
C15 = [B4, B1, B2];
C16 = [B2, B1, B3];
C17 = [B4, B5, B6, B1];
C18 = [B1, B6, B7, B3];
C19 = [B10, B12, A12, A11, A43];
C20 = [A12, B12, B11, A27, A13];
C21 = [A27, A28, B15, B11];
C22 = [A28, A29, B15];
C23 = [B15, A29, B14];
C24 = [B14, A29, A30];
C25 = [B14, A30, A31];
C26 = [B14, A31, B11];
C27 = [B14, B11, B15];
C28 = [B11, A32, A31];
C29 = [A32, B9, B11];
C30 = [B10, A43, A42, B16];
C31 = [A42, A41, B16];
C32 = [A41, B13, B16];
C33 = [A41, A40, B13];
C34 = [B13, B10, B16];
C35 = [A40, A39, B13];
C36 = [A39, B10, B13];
C37 = [A39, A38, B10];
C38 = [A38, B8, B10];
C39 = [B10, B12, B2, B4, B8];
C40 = [B12, B2, B3, B9, B11];
C41 = [A35, B6, B7];
C42 = [B6, A35, B5];
C43 = [A32, A33, B17];
C44 = [A34, B17, A33];
C45 = [A37, B18, A38];
C46 = [B7, B3, B9, B19];
C47 = [B9, B19, B17, A32];
C48 = [B5, B4, B8, B20];
C49 = [B8, A38, B18, B20];
C50 = [B18, A36, A37];
C51 = [B18, A36, A35, B5, B20];
C52 = [A35, A34, B17, B19, B7];

cut_polygons = [C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15, C16, C17, C18, C19, C20, C21, C22, C23, C24, C25, C26, C27, C28, C29, C30, C31, C32, C33, C34, C35, C36, C37, C38, C39, C40, C41, C42, C43, C44, C45, C46, C47, C48, C49, C50, C51, C52];

min_x = A46[0];
min_y = A4[1];
max_x = A24[0];
max_y = A35[1];

x_size = max_x - min_x;
y_size = max_y - min_y;

x_factor = max_size / x_size;
y_factor = max_size / y_size;

inline_size = x_size > y_size ? inline_size_in_millimeter / x_factor / 2: inline_size_in_millimeter / y_factor / 2;
inline_edge_radius = x_size > y_size ? inline_edge_radius_in_millimeter / x_factor: inline_edge_radius_in_millimeter / y_factor;
outline_size = x_size > y_size ? outline_size_in_millimeter / x_factor - inline_size: outline_size_in_millimeter / y_factor - inline_size;

 // Program Section //
//-----------------//

if(x_size > y_size) {
    resize(newsize=[max_size, x_factor * y_size, model_height]){
        if(flip_model == "yes") {
            mirror([0,1,0]) {
                rotate([180,180,0]) {
                    create(outline, cut_polygons);
                }
            }
        } else {
            create(outline, cut_polygons);
        }
    }
} else {
    resize(newsize=[y_factor * x_size, max_size, model_height]){
        if(flip_model == "yes") {
            mirror([0,1,0]) {
                rotate([180,180,0]) {
                    create(outline, cut_polygons);
                }
            }
        } else {
            create(outline, cut_polygons);
        }
    }
}

 // Module Section //
//----------------//

module create() {
    linear_extrude(height=1) {
        difference() {
            offset(r = -0) {
                offset(r = +outline_size) {
                    polygon(points = outline, convexity = 10);
                }
            }

            for(cut_polygon = [0:len(cut_polygons)]) {
                offset(r = +inline_edge_radius) {
                    offset(r = -inline_size - inline_edge_radius) {
                        polygon(points = cut_polygons[cut_polygon], convexity = 10);
                    }
                }
            }
        }
    }
}

```


[User]
Alright, I'm looking to design a parametric LM8UU linear bearing housing for my 3D printer, and I want it to be customizable in a few key ways. I'm aiming for something that's lighter than the standard metal holders, so I need to be able to adjust dimensions for optimal fit and material use.

Here's what I have in mind:

*   **Bearing Diameter:** The main parameter should be the outer diameter of the linear bearing itself. I'll be using LM8UUs, but I want the flexibility to use plastic bushings like the ones from thingiverse link in the description, or others. So, I need to be able to adjust this parameter. Let's call it `bushing_diam`. I'd probably like to have it default to 15.1 mm, but have a dropdown with some common sizes like 14.9, 15, 15.1, and 15.2.
*   **Screw Holes:** I want to include screw holes for mounting. I need a parameter, `screw_diam`, to adjust the screw hole diameter. I'd like this to be able to handle either standard screws or threaded holes, so it should default to 4.1mm for standard M4, but be adjustable (dropdown with 2.9, 3, 3.1, 3.9, 4, 4.1, 4.2) , and I'll need an option to enable or disable threads for those holes (Boolean parameter, let's call it `threads`). if threads are enabled, force the `screw_diam` to 4mm.
*   **Nut Recesses:** If using standard screws, I want to have recesses for nuts. I need a yes/no toggle for these (let's call it `nuts`), and if yes, the nut recesses should be appropriately sized for M4 nuts.
*   **Bottom Restriction:** I want to be able to choose whether or not to have a bottom restriction for the bearing, so that I can easily push the bearing through. A simple yes/no toggle `bottom` would work.
*   **Pins:** The design needs holes for pins to keep the bearings secure. I'd like those holes to be fixed and oriented correctly for easy insertion. Let's make the pin holes 0.9 mm.

For the threading, I think it will be best to implement them using ISO metric thread standards, as per the code provided and wiki link in it.

I think that about covers it. So, can you create an OpenSCAD file, or multiple files if needed, that would do this? I'm hoping to generate the housing itself and also include the thread generation code. No special library requirements as the code provided does not include any.

[Assistant]
LM8UU_housing.scad:
```
// copyright aeropic 2017

// play with this value to trim the screw diameter. (If you use threads set it to 4 mm)
screw_diam = 4.1; //[2.9,3,3.1,3.9,4,4.1,4.2]

// bushing outer diameter
bushing_diam = 15.1; //[14.9,15,15.1,15.2]

// do you want  M4 nuts ?
nuts = "yes"; //["yes","no"]

// do you want  threads ? (if yes set the screw diam to 4mm)
threads = "no"; //["no","yes"]

// do you want bottom restriction ?
bottom = "yes"; //["yes","no"]

/* [Hidden] */
$fn = 100;

// ISO Metric Thread Implementation
// Trevor Moseley
// 20/04/2014

// For thread dimensions see
//   http://en.wikipedia.org/wiki/File:ISO_and_UTS_Thread_Dimensions.svg

//--pitch-----------------------------------------------------------------------
// function for ISO coarse thread pitch (these are specified by ISO)
function get_coarse_pitch(dia) = lookup(dia, [
[1,0.25],[1.2,0.25],[1.4,0.3],[1.6,0.35],[1.8,0.35],[2,0.4],[2.5,0.45],[3,0.5],[3.5,0.6],[4,0.7],[5,0.8],[6,1],[7,1],[8,1.25],[10,1.5],[12,1.75],[14,2],[16,2],[18,2.5],[20,2.5],[22,2.5],[24,3],[27,3],[30,3.5],[33,3.5],[36,4],[39,4],[42,4.5],[45,4.5],[48,5],[52,5],[56,5.5],[60,5.5],[64,6],[78,5]]);

//--top level modules-----------------------------------------------------------
module thread_in(dia,hi,thr=$fn)
// make an inside thread (as used on a nut)
//  dia = diameter, 6=M6 etc
//  hi = height, 10=make a 10mm long thread
//  thr = thread quality, 10=make a thread with 10 segments per turn
{
	p = get_coarse_pitch(dia);
	thread_in_pitch(dia,hi,p,thr);
}

module thread_in_pitch(dia,hi,p,thr=$fn)
// make an inside thread (as used on a nut)
//  dia = diameter, 6=M6 etc
//  hi = height, 10=make a 10mm long thread
//  p=pitch
//  thr = thread quality, 10=make a thread with 10 segments per turn
{
	h=(cos(30)*p)/8;
	Rmin=(dia/2)-(5*h);	// as wiki Dmin
	s=360/thr;				// length of segment in degrees
	t1=(hi-p)/p;			// number of full turns
	r=t1%1.0;				// length remaining (not full turn)
	t=t1-r;					// integer number of turns
	n=r/(p/thr);			// number of segments for remainder
	for(tn=[0:t-1])
		translate([0,0,tn*p])	th_in_turn(dia,p,thr);
	for(sg=[0:n])
		th_in_pt(Rmin+0.1,p,s,sg+(t*thr),thr,h,p/thr);
}

//--low level modules-----------------------------------------------------------
module th_in_turn(dia,p,thr=$fn)
// make an single turn of an inside thread
//  dia = diameter, 6=M6 etc
//  p=pitch
//  thr = thread quality, 10=make a thread with 10 segments per turn
{
	h = (cos(30)*p)/8;
	Rmin = (dia/2) - (5*h);	// as wiki Dmin
	s = 360/thr;
	for(sg=[0:thr-1])
		th_in_pt(Rmin+0.1,p,s,sg,thr,h,p/thr);
}

module th_in_pt(rt,p,s,sg,thr,h,sh)
// make a part of an inside thread (single segment)
//  rt = radius of thread (nearest centre)
//  p = pitch
//  s = segment length (degrees)
//  sg = segment number
//  thr = segments in circumference
//  h = ISO h of thread / 8
//  sh = segment height (z)
{
	as = ((sg % thr) * s - 180);	// angle to start of seg
	ae = as + s -(s/100);		// angle to end of seg (with overlap)
	z = sh*sg;
	pp = p/2;
	//         2,5
	//          /|
	//     1,4 / |
 	//         \ |
	//          \|
	//         0,3
	//  view from front (x & z) extruded in y by sg
	//
	polyhedron(
		points = [
			[cos(as)*(rt+(5*h)),sin(as)*(rt+(5*h)),z],				//0
			[cos(as)*rt,sin(as)*rt,z+(3/8*p)],						//1
			[cos(as)*(rt+(5*h)),sin(as)*(rt+(5*h)),z+(3/4*p)],		//2
			[cos(ae)*(rt+(5*h)),sin(ae)*(rt+(5*h)),z+sh],			//3
			[cos(ae)*rt,sin(ae)*rt,z+(3/8*p)+sh],					//4
			[cos(ae)*(rt+(5*h)),sin(ae)*(rt+(5*h)),z+(3/4*p)+sh]],	//5
		faces = [
			[0,1,2],			// near face
			[3,5,4],			// far face
			[0,3,4],[0,4,1],	// left face
			[0,5,3],[0,2,5],	// bottom face
			[1,4,5],[1,5,2]]);	// top face
}

module four_screws(diam, faces) {
    translate  ([0,12,9]) rotate ([0,90,0]) cylinder(d= diam, h = 30, center = true, $fn =faces);

 translate  ([0,12,-9]) rotate ([0,90,0]) cylinder(d= diam, h = 30, center = true, $fn =faces);
 translate  ([0,-12,9]) rotate ([0,90,0]) cylinder(d= diam, h = 30, center = true, $fn =faces);translate  ([0,-12,-9]) rotate ([0,90,0]) cylinder(d= diam, h = 30, center = true, $fn =faces);
}

module four_threads() {

translate  ([4.2,12,9])rotate([0,90,0])thread_in(4,7);						// make an M4 x 7 ISO thread
    translate  ([4.2,12,-9])rotate([0,90,0])thread_in(4,7);						// make an M4 x 7 ISO thread
    translate  ([4.2,-12,9])rotate([0,90,0])thread_in(4,7);						// make an M4 x 7 ISO thread
    translate  ([4.2,-12,-9])rotate([0,90,0])thread_in(4,7);						// make an M4 x 7 ISO thread

}

module top(){
 * hull(){
      #translate ([8,0,14.45]) rotate ([0,0,-90])cube ([20,1.2,0.1],center = true);
    #translate ([8,0,12.8]) rotate ([0,0,-90])cube ([20,3,0.5],center = true);
  }
   if (threads == "yes") #four_threads();
difference(){
    hull(){
        translate ([9.5,0,0]) rotate ([0,0,-90])cube ([32,4,29],center = true);
        cylinder (d=bushing_diam+3, h = 29,center = true);
        }
#translate ([0,0,2])cylinder (d=bushing_diam, h = 29,center = true) ;
    if (bottom == "no") #translate ([0,0,0])cylinder (d=bushing_diam, h = 29,center = true);

 cylinder (d=bushing_diam*10/15, h = 50,center = true); // drill the bootom hole

 four_screws(screw_diam, 100); // drill the screws holes

 if (nuts == "yes") translate  ([-7,0,0])  # four_screws(8.2, 6);

rotate ([0,0,-90])#translate ([0,-5.5,15-3]) rotate ([0,90,0]) cylinder (d=0.9, h = 49,center = true); // insert the pin

 if (bottom == "no") rotate ([0,0,-90])#translate ([0,-5.5,-15+2.5]) rotate ([0,90,0]) cylinder (d=0.9, h = 49,center = true); // insert the bottom pin

}
}

top();

```


[User]
I'd like to create a customizable 2D origami-style Christmas star using OpenSCAD, similar to the design I saw on Thingiverse. The original is called "Customizable Origami - Christmas Star No. 1".

Here's what I need to be able to control:

*   **Overall Size:** I need to be able to set a maximum size for the star, and the design should scale proportionally to fit within that size. I should be able to specify this size in millimeters.
*   **Height:** I want to control the thickness of the star, also in millimeters, which will essentially be the extrusion height in OpenSCAD.
*   **Outline Thickness:** The star has an outer outline, and I need to control the thickness of this outline.
*   **Inner Outline Thickness:** It also has inner outlines for each "cut," and I need to control their thickness separately from the outer outline.
*   **Inner Outline Roundness:** The ends of the inner outlines should have rounded edges. I need to be able to set the radius of these rounded edges.
*   **Flipping:** I need an option to flip the entire model on the Y axis (mirror along the X-Z plane).

The star's basic shape is defined by 10 outer points and one inner point. The cut lines are defined by polygons made from those points. I can provide those if necessary, but it might be easier if your generated code figures out the exact geometry based on the user-provided parameters.

I expect the output to be a single `.scad` file that contains the necessary modules to generate the star. I don't need any special libraries besides the standard OpenSCAD library, nor do I need to import anything.

[Assistant]
customizable_origami_christmas_star_no1.scad:
```
/*
 * Customizable Origami - Christmas Star No. 1 - https://www.thingiverse.com/thing:2641203
 * by Dennis Hofmann - https://www.thingiverse.com/mightynozzle/about
 * created 2017-11-12
 * version v1.0
 *
 * Changelog
 * --------------
 * v1.0:
 *      - final design
 * --------------
 *
 * This work is licensed under the Creative Commons - Attribution - NonCommercial - ShareAlike license.
 * https://creativecommons.org/licenses/by-nc-sa/3.0/
 */

 // Parameter Section //
//-------------------//

// preview[view:north, tilt:top]

// The maximum size of the longest side. The shorter side will be automatically resized in same ratio.
max_size_in_millimeter = 120; //[20:300]

// The height of the model.
model_height_in_millimeter = 5; //[0.2:0.2:100]

// Thickness of the outer outline.
outline_size_in_millimeter = 1.4; //[0.5:0.1:20]

// Thickness of the inner outline.
inline_size_in_millimeter = 0.7; //[0.5:0.1:20]

// Roundiness of the ends of the inner outlines.
inline_edge_radius_in_millimeter = 0.3; //[0.0:0.1:5]

// Flip model
flip_model = "no"; //[yes,no]

/*[hidden]*/
max_size = max_size_in_millimeter;
model_height = model_height_in_millimeter;
$fn=32;

// Outer Points
A1 = [379, 1];
A2 = [495, 236];
A3 = [754, 275];
A4 = [567, 459];
A5 = [612, 719];
A6 = [377, 598];
A7 = [144, 719];
A8 = [189, 459];
A9 = [1, 275];
A10 = [262, 236];

outline = [A1, A2, A3, A4, A5, A6, A7, A8, A9, A10];

// Inner Points
B1 = [377, 388];

// Polygons
C1 = [A10, A1, B1];
C2 = [A1, A2, B1];
C3 = [A2, A3, B1];
C4 = [B1, A3, A4];
C5 = [B1, A4, A5];
C6 = [A5, A6, B1];
C7 = [B1, A6, A7];
C8 = [A7, A8, B1];
C9 = [B1, A9, A8];
C10 = [A9, A10, B1];

cut_polygons = [C1, C2, C3, C4, C5, C6, C7, C8, C9, C10];

min_x = A9[0];
min_y = A1[1];
max_x = A3[0];
max_y = A5[1];

x_size = max_x - min_x;
y_size = max_y - min_y;

x_factor = max_size / x_size;
y_factor = max_size / y_size;

inline_size = x_size > y_size ? inline_size_in_millimeter / x_factor / 2: inline_size_in_millimeter / y_factor / 2;
inline_edge_radius = x_size > y_size ? inline_edge_radius_in_millimeter / x_factor: inline_edge_radius_in_millimeter / y_factor;
outline_size = x_size > y_size ? outline_size_in_millimeter / x_factor - inline_size: outline_size_in_millimeter / y_factor - inline_size;

 // Program Section //
//-----------------//

if(x_size > y_size) {
    resize(newsize=[max_size, x_factor * y_size, model_height]){
        if(flip_model == "yes") {
            mirror([0,1,0]) {
                rotate([180,180,0]) {
                    create(outline, cut_polygons);
                }
            }
        } else {
            create(outline, cut_polygons);
        }
    }
} else {
    resize(newsize=[y_factor * x_size, max_size, model_height]){
        if(flip_model == "yes") {
            mirror([0,1,0]) {
                rotate([180,180,0]) {
                    create(outline, cut_polygons);
                }
            }
        } else {
            create(outline, cut_polygons);
        }
    }
}

 // Module Section //
//----------------//

module create() {
    linear_extrude(height=1) {
        difference() {
            offset(r = -0) {
                offset(r = +outline_size) {
                    polygon(points = outline, convexity = 10);
                }
            }

            for(cut_polygon = [0:len(cut_polygons)]) {
                offset(r = +inline_edge_radius) {
                    offset(r = -inline_size - inline_edge_radius) {
                        polygon(points = cut_polygons[cut_polygon], convexity = 10);
                    }
                }
            }
        }
    }
}

```


[User]
I'd like to create a customizable 2D origami panda head design in OpenSCAD. I'm looking for a parametric design where I can control the overall size, thickness of outlines, and edge roundness.

Here are the specific parameters I need:

*   **`max_size_in_millimeter`**:  The maximum dimension of the longest side of the design. The other side should scale proportionally to maintain the aspect ratio. Let's allow values from 20 to 300.
*   **`model_height_in_millimeter`**: The overall thickness (height) of the 2D design, which is basically the extrusion height. This should be adjustable from 0.2 to 100.
*   **`outline_size_in_millimeter`**:  Thickness of the outer outline.  Allow a range from 0.5 to 20.
*   **`inline_size_in_millimeter`**: Thickness of the inner outlines. Should also be adjustable from 0.5 to 20.
*   **`inline_edge_radius_in_millimeter`**: The radius for rounding the ends of the inner outlines, adjustable from 0 to 5.
*  **`flip_model`**: An option to flip the model horizontally, with "yes" or "no" choices.

The design itself is based on a set of predefined points, which will have to be in the code, and then a set of polygons that are to be cut out of the outline.

The outline points are:

```
A1 = [135, 173];
A2 = [139, 133];
A3 = [160, 106];
A4 = [189, 102];
A5 = [218, 125];
A6 = [271, 108];
A7 = [299, 108];
A8 = [352, 124];
A9 = [383, 102];
A10 = [409, 106];
A11 = [431, 132];
A12 = [434, 173];
A13 = [419, 193];
A14 = [425, 199];
A15 = [441, 271];
A16 = [426, 335];
A17 = [355, 387];
A18 = [316, 389];
A19 = [254, 389];
A20 = [215, 388];
A21 = [145, 336];
A22 = [129, 272];
A23 = [144, 199];
A24 = [151, 192];
```
The inner cutout points are:
```
B1 = [233, 204];
B2 = [251, 216];
B3 = [254, 236];
B4 = [220, 323];
B5 = [189, 305];
B6 = [181, 257];
B7 = [215, 228];
B8 = [336, 205];
B9 = [351, 212];
B10 = [354, 227];
B11 = [389, 257];
B12 = [382, 305];
B13 = [350, 323];
B14 = [336, 288];
B15 = [316, 239];
B16 = [320, 216];
B17 = [264, 324];
B18 = [307, 324];
B19 = [314, 333];
B20 = [286, 358];
B21 = [256, 333];
B22 = [248, 376];
B23 = [323, 376];
B24 = [219, 350];
B25 = [351, 351];
B26 = [219, 213];
B27 = [226, 158];
B28 = [343, 158];
B29 = [234, 287];
```

And here are the polygons that are used to cut out the inside:
```
C1 = [B26, B27, A5, A6, A7, A8, B28, B9, B8, B16, B2, B1];
C2 = [B17, B3, B2, B16, B15, B18];
C3 = [B17, B3, B29, B21];
C4 = [B18, B15, B14, B19];
C5 = [B19, B14, B13, B25];
C6 = [B19, B25, B23, B20];
C7 = [B20, B21, B24, B22];
C8 = [B21, B29, B4, B24];
C9 = [A20, B22, B23, A17, A18, A19];
C10 = [B4, B5, A21, A20, B22, B24];
C11 = [A17, B23, B25, B13, B12, A16];
C12 = [A21, B5, B6, A23, A22];
C13 = [B6, B7, B26, B27, A5, A24, A23];
C14 = [A8, A13, A14, B11, B10, B9, B28];
C15 = [B12, B11, A14, A15, A16];
```

I'd like the script to calculate the scaling factors to ensure the model fits within the `max_size_in_millimeter` and then use those scaling factors to generate the model, with the user's settings.  The script should extrude the final shape to the `model_height_in_millimeter` value after the scaling is performed.

Could you generate the OpenSCAD code for me?

[Assistant]
customizable_origami_panda_head.scad:
```
/*
 * Customizable Origami - Panda Head - https://www.thingiverse.com/thing:2643016
 * by Dennis Hofmann - https://www.thingiverse.com/mightynozzle/about
 * created 2017-11-13
 * version v1.0
 *
 * Changelog
 * --------------
 * v1.0:
 *      - final design
 * --------------
 *
 * This work is licensed under the Creative Commons - Attribution - NonCommercial - ShareAlike license.
 * https://creativecommons.org/licenses/by-nc-sa/3.0/
 */

 // Parameter Section //
//-------------------//

// preview[view:north, tilt:top]

// The maximum size of the longest side. The shorter side will be automatically resized in same ratio.
max_size_in_millimeter = 120; //[20:300]

// The height of the model.
model_height_in_millimeter = 5; //[0.2:0.2:100]

// Thickness of the outer outline.
outline_size_in_millimeter = 2.0; //[0.5:0.1:20]

// Thickness of the inner outline.
inline_size_in_millimeter = 0.7; //[0.5:0.1:20]

// Roundiness of the ends of the inner outlines.
inline_edge_radius_in_millimeter = 0.7; //[0.0:0.1:5]

// Flip model
flip_model = "no"; //[yes,no]

/*[hidden]*/
max_size = max_size_in_millimeter;
model_height = model_height_in_millimeter;
$fn=32;

// Outer Points
A1 = [135, 173];
A2 = [139, 133];
A3 = [160, 106];
A4 = [189, 102];
A5 = [218, 125];
A6 = [271, 108];
A7 = [299, 108];
A8 = [352, 124];
A9 = [383, 102];
A10 = [409, 106];
A11 = [431, 132];
A12 = [434, 173];
A13 = [419, 193];
A14 = [425, 199];
A15 = [441, 271];
A16 = [426, 335];
A17 = [355, 387];
A18 = [316, 389];
A19 = [254, 389];
A20 = [215, 388];
A21 = [145, 336];
A22 = [129, 272];
A23 = [144, 199];
A24 = [151, 192];

outline = [A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24];

// Inner Points
B1 = [233, 204];
B2 = [251, 216];
B3 = [254, 236];
B4 = [220, 323];
B5 = [189, 305];
B6 = [181, 257];
B7 = [215, 228];
B8 = [336, 205];
B9 = [351, 212];
B10 = [354, 227];
B11 = [389, 257];
B12 = [382, 305];
B13 = [350, 323];
B14 = [336, 288];
B15 = [316, 239];
B16 = [320, 216];
B17 = [264, 324];
B18 = [307, 324];
B19 = [314, 333];
B20 = [286, 358];
B21 = [256, 333];
B22 = [248, 376];
B23 = [323, 376];
B24 = [219, 350];
B25 = [351, 351];
B26 = [219, 213];
B27 = [226, 158];
B28 = [343, 158];
B29 = [234, 287];

// Polygons
C1 = [B26, B27, A5, A6, A7, A8, B28, B9, B8, B16, B2, B1];
C2 = [B17, B3, B2, B16, B15, B18];
C3 = [B17, B3, B29, B21];
C4 = [B18, B15, B14, B19];
C5 = [B19, B14, B13, B25];
C6 = [B19, B25, B23, B20];
C7 = [B20, B21, B24, B22];
C8 = [B21, B29, B4, B24];
C9 = [A20, B22, B23, A17, A18, A19];
C10 = [B4, B5, A21, A20, B22, B24];
C11 = [A17, B23, B25, B13, B12, A16];
C12 = [A21, B5, B6, A23, A22];
C13 = [B6, B7, B26, B27, A5, A24, A23];
C14 = [A8, A13, A14, B11, B10, B9, B28];
C15 = [B12, B11, A14, A15, A16];

cut_polygons = [C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15];

min_x = A22[0];
min_y = A4[1];
max_x = A15[0];
max_y = A18[1];

x_size = max_x - min_x;
y_size = max_y - min_y;

x_factor = max_size / x_size;
y_factor = max_size / y_size;

inline_size = x_size > y_size ? inline_size_in_millimeter / x_factor / 2: inline_size_in_millimeter / y_factor / 2;
inline_edge_radius = x_size > y_size ? inline_edge_radius_in_millimeter / x_factor: inline_edge_radius_in_millimeter / y_factor;
outline_size = x_size > y_size ? outline_size_in_millimeter / x_factor - inline_size: outline_size_in_millimeter / y_factor - inline_size;

 // Program Section //
//-----------------//

if(x_size > y_size) {
    resize(newsize=[max_size, x_factor * y_size, model_height]){
        if(flip_model == "yes") {
            mirror([0,1,0]) {
                rotate([180,180,0]) {
                    create(outline, cut_polygons);
                }
            }
        } else {
            create(outline, cut_polygons);
        }
    }
} else {
    resize(newsize=[y_factor * x_size, max_size, model_height]){
        if(flip_model == "yes") {
            mirror([0,1,0]) {
                rotate([180,180,0]) {
                    create(outline, cut_polygons);
                }
            }
        } else {
            create(outline, cut_polygons);
        }
    }
}

 // Module Section //
//----------------//

module create() {
    linear_extrude(height=1) {
        difference() {
            offset(r = -0) {
                offset(r = +outline_size) {
                    polygon(points = outline, convexity = 10);
                }
            }

            for(cut_polygon = [0:len(cut_polygons)]) {
                offset(r = +inline_edge_radius) {
                    offset(r = -inline_size - inline_edge_radius) {
                        polygon(points = cut_polygons[cut_polygon], convexity = 10);
                    }
                }
            }
        }
    }
}

```


[User]
I'm looking to create a customizable clamp design using OpenSCAD, and I'd like to be able to adjust several parameters. Here's what I'm thinking:

The basic shape is a cylindrical clamp, where a section is cut out to allow it to flex open. I need to control the inner diameter of the clamp, the overall length, and the wall thickness.

I also want the option to include a hexagonal nut recess on the outside of the clamp, perpendicular to the main cylinder axis, for securing the clamp with a bolt. This would require a separate diameter parameter for the hex nut. The bolt hole itself needs to be adjustable in size as well.

Finally, the cut-out section of the clamp needs a parameter that defines the width of the gap.

So, to summarize, I need a parametric OpenSCAD file that allows me to adjust:

*   Clamp Inner Diameter
*   Clamp Length
*   Clamp Wall Thickness
*   Option to add a Hex Nut Recess (Yes/No Toggle)
*   Hex Nut Diameter
*   Bolt Hole Diameter
*   Slit Width

Could you help me generate the appropriate OpenSCAD code? I don't have any preferred libraries, so go with what you think is best.

[Assistant]
clamp.scad:
```
$fn=50;

// Clamp length
length_numeric_slider = 10; //[10:50]

// Clamp inner diameter
dia_numeric_slider = 13; //[5:50]

// Clamp wall thickness
wall_numeric_slider = 10; //[2:10]

// Embed a hex nut
nut_drop_down_box = 0; // [0:no, 1:yes]

// Hex nut diameter
nut_dia_numeric_slider = 9; // [5:30]

// Bolthole diameter
bolt_dia_numeric_slider = 5.5; // [3:20]

// Slit width
slit_width_numeric_slider = 2; // [1:5]

clamp(dia_numeric_slider, length_numeric_slider, wall_numeric_slider, nut_drop_down_box, nut_dia_numeric_slider, bolt_dia_numeric_slider, slit_width_numeric_slider);

module clamp(d1, h, wall, nuthole, nuthole_dia, bolt_dia, slit)
{
    outerdia = d1 + wall;

    difference() {
        hull() {
            cylinder(d=outerdia, h=h);
            translate([outerdia/2+1, -outerdia/2, h/2])
            rotate([0, 90, 90])
            cylinder(d=10, h=outerdia);
        }
        translate([0, 0, -1])
        cylinder(d=d1, h=h+2);

        translate([outerdia/2+1, -outerdia/2-1, h/2])
        rotate([0, 90, 90])
        cylinder(d=bolt_dia, h=outerdia+2);

        if (nuthole == 1) {
            translate([outerdia/2+1, -outerdia/2-0.1, h/2])
            rotate([0, 90, 90])
            cylinder(d=nuthole_dia, h=4, $fn=6);
        }
        translate([0, -slit/2, -1])
        cube([outerdia, slit, h+2]);

     }

}

```


[User]
Hey, I'm looking to design a parametric spinner for an electric glider, specifically for a folding prop. I've seen a design that's pretty close, but I need something that's totally customizable.

Here's what I'm thinking:

The basic shape should be a hyperboloid, kind of like a bullet shape. I need to be able to adjust the "roundness" of that shape with an exponent – something between linear (exponent of 1) and more hyperbolic (exponent of 2).  I'll also need to be able to control the overall radius and height of the spinner.

The spinner needs to have a wall thickness that I can control. There'll be a hole in the center for the motor shaft. I also need to be able to add two screw holes, oriented axially, for securing the spinner. I'd like to control the diameter of those screw holes and the distance between them, too.

The spinner will have an internal disc to support the spinner and the screw holes.  The height of this disc should be adjustable.

I need to be able to specify the width and height of a block that will need to be cut out of the spinner to allow for the folding propeller mechanism. This should be optional, so if I don't need the cutout I can generate a solid spinner.

There needs to be a way to add radial screw holes too, for the propeller itself, and set the diameter and offset for them.

I want some adjustable supporting fins on the disc part and under the cutout, with independent thickness parameters for the fins and support structure. I'd like to optionally control whether this support structure is included.

Finally, I’d like to add an optional chamfer at the bottom outside edge of the spinner.

For this, I think I'll need OpenSCAD, and I don’t think I'll be using any external libraries. It should all be contained in one single .scad file.

[Assistant]
spinner_universal.scad:
```
// Parametric Spinner cap for Electric Motor Folding Prop
// Design by Henning Stoecklein 23.2.2014
// Version 13.11.2017 for customizer (default: Epsilon XL3 with 5mm Shaft)
//
// ****** Free Usage for non-commercial use only *******
//
// WARNING: Folding props create high forces - use at your own risc!

// Cap shape polynomic exponent (1=linear, 2=hyperbolic)
cap_p = 1.6 ; // [1.1:0.05:2.0]

// Spinner radius (unprecise, so try out...)
cap_radius = 19.8  ; // [12:0.5:30]

// Spinner height (unprecise, so try out...)
cap_height= 33;	 // [18:0.5:40]

// Cap wall thickness
thick = 1.1 ; // [0.8:0.1:2.5]

 // Diameter of motor shaft hole
dcenter = 5.4 ; // [4:0.1:12]

// Diameter of 2 axial M2 screw holes
dScrewM2 = 1.6 ; // [1.2:0.1:2.5]

// Distance of 2 axial M2 screw holes
distScrewM2 = 20 ; // [15:0.5:40]

 // Height of center disc
disc_h = 3.0 ; // [2:0.1:4]

// Y width of prop center piece block
zblock_y = 12.6;

// Z cap_height of prop center piece block (0 for glider nose w/o center piece)
zblock_z = 10.5; //  [0:0.1:20]

screw_d = 3.2  ;    // Screw hole diameter
screw_offs = 5.0 ;  // Screw x position offset
hresol = 20;		// cap_height step resolution (15 is OK)
wresol = 3;		// cap mm step angle resolution (3 is OK)

// Thickness of support fins
fin = 1.1 ; // [0.6:0.1:2]

// Thickness of support block
sup = 0.5 ; // [0.4:0.1:0.8]

// Support structure below center piece block cutout
support = 1 ; // [0:No, 1:Yes]

// Cutout for prop center piece (0 = solid spinner for pure glider nose)
centercut = 1 ; // [0:No, 1:Yes]

// Chamfer at bottom outside
bottomchamfer = 1 ; // [0:No, 1:Yes]

// Internal scale factors for cap calculation
step = hresol/cap_radius;
fhe  = cap_height/pow(cap_radius,cap_p);

// *********************************************************
// Select top level object here
spinnercap() ;
//
// *********************************************************

//********* Position of polygon points ********
//             #1                    #2
//        (r+1, (r+1)^p)     (thick+r+1, (r+1)^p))
//
//       #0                 #3
//   (r, r^p)         (thick+r, r^p)
//*************************************

// Function to define cap_height of point on Hyperboloid surface at radius r
function hypt (r)= cap_height-fhe*pow(r,cap_p) ;

// Filled Hyperboloid with inner diameter
module hyperbel_inner()
{
  for (i = [0:hresol-1]) {
     assign (r = i/step)
     polygon (points=
       [[0, fhe*pow(r,cap_p)],
        [0, fhe*pow(r+1/step,cap_p)],
        [r+1/step, fhe*pow(r+1/step,cap_p)],
        [r, fhe*pow(r,cap_p)]],
        paths=[[0,3,2,1]]) ;
  }
}

// Filled Hyperboloid with outer diameter
module hyperbel_outer()
{
  for (i = [0:hresol-1]) {
     assign (r = i/step)
     polygon (points=
       [[0, fhe*pow(r,cap_p)],
        [0, fhe*pow(r+1/step,cap_p)],
        [thick+r+1/step, fhe*pow(r+1/step,cap_p)],
		[thick+r, fhe*pow(r,cap_p)]],
        paths=[[0,3,2,1]]) ;
  }
}

module spinnercap()
{
  difference() {
    union()
    {
    spinner() ;

    // Holding Disc with fins and M2 screw holes
    difference() {
      intersection() {
        union() {

          // Center holding disc
          translate ([0,0, zblock_z+disc_h/2]) cylinder (r=cap_radius, h=disc_h, center=true, $fn=20) ;

         // Fins around center holding disc
         for (i = [0:7])
         {
            rotate ([0,0,27+i*140/8]) hull()
            {
              translate ([8, 0, zblock_z])  cube ([0.1,fin,0.1]) ;
              translate ([cap_radius, 0, zblock_z])  cube ([0.1,fin,0.1]) ;
              translate ([cap_radius, 0, 0]) cube ([0.2,fin,0.1]) ;
            }
            rotate ([0,0,180+27+i*140/8]) hull()
            {
              translate ([8, 0, zblock_z])  cube ([0.1,fin,0.1]) ;
              translate ([cap_radius, 0, zblock_z])  cube ([0.1,fin,0.1]) ;
              translate ([cap_radius, 0, 0]) cube ([0.2,fin,0.1]) ;
            }
          } // for

          // 2 domes for axial M2 screws
          translate ([+distScrewM2/2, 0, zblock_z+disc_h+1.5])
                cylinder (r1=3+dScrewM2, r2=1.2+dScrewM2, h=3, center=true, $fn=20) ;
         translate ([-distScrewM2/2, 0, zblock_z+disc_h+1.5])
                cylinder (r1=3+dScrewM2, r2=1.2+dScrewM2, h=3, center=true, $fn=20) ;
        } // union

        spinnersurface() ;

      } // intersect

      // Center hole for motor shaft
      translate ([0,0,11.75-4.8/2]) cylinder (r=dcenter/2, h=20, center=true, $fn=20) ;

      // M2 axial screw holes
      translate ([+distScrewM2/2, 0, zblock_z+disc_h/2]) cylinder (r=dScrewM2/2, h=12, center=true, $fn=20) ;
      translate ([-distScrewM2/2, 0, zblock_z+disc_h/2]) cylinder (r=dScrewM2/2, h=12, center=true, $fn=20) ;
    } // diff

/*
    // Chamfer between holding disk and spinner cap
    difference() {
       translate ([0,0, zblock_z-1]) cylinder (r=17, h=2, center=true, $fn=40) ;     // Disk (r see r1 above)
       translate ([0,0, zblock_z-1]) cylinder (r2=14, r1=17, h=2.05, center=true, $fn=40) ;
     }
*/
   } // union

   // Bottom chamfer cutout
   if (bottomchamfer == 1)
      for (i = [1:8:360])
          rotate ([0, 0, i]) translate ([1.9+cap_radius, 0, 0]) rotate ([0,-45,0]) cube ([2, 20, 2], center=true) ;

   if (centercut == 1)
   {
      // Cutout for Prop folding centerpiece
      translate ([0, 0, zblock_z/2]) cube ([80, zblock_y, zblock_z], center=true);

      // 2 radial Screw holes
     translate ([-screw_offs, 15, zblock_z-8/2]) rotate ([90,0,0]) cylinder (r=screw_d/2, h=20, center=true, $fn=20) ;
     translate ([+screw_offs,-15, zblock_z-8/2]) rotate ([90,0,0]) cylinder (r=screw_d/2, h=20, center=true, $fn=20) ;
   } // if centercut

  } // union

  // Put support structure under baseblock cutout
  if (support == 1)
  {
    difference ()
    {
     union ()
     {
      translate ([0, zblock_y*0.22, zblock_z/2]) cube ([2*cap_radius, sup, zblock_z], center=true);
      translate ([-cap_radius+0.5, 0, zblock_z/2]) cube ([sup, 12*0.5, zblock_z], center=true);

      translate ([0, -zblock_y*0.22, zblock_z/2]) cube ([2*cap_radius, sup, zblock_z], center=true);
      translate ([cap_radius-0.5, 0, zblock_z/2]) cube ([sup, 12*0.5, zblock_z], center=true);
    } // union

	// Disassembly break holes near center hole
    translate ([11,-1.3-0.5,10]) cube ([2,1.0,1.0]) ;
    translate ([11,+1.3-0.5,10]) cube ([2,1.0,1.0]) ;

	// Center hole
    translate ([0,0,11.75-4.8/2]) cylinder (r=1+dcenter/2, h=20, center=true, $fn=20) ;

    translate ([-13,-1.3-0.5,10]) cube ([2,1.0,1.0]) ;
    translate ([-13,+1.3-0.5,10]) cube ([2,1.0,1.0]) ;

    translate ([-7.8,-5,7]) cube ([1.0,10,4]) ;
    translate ([6.8,-5,7]) cube ([1.0,10,4]) ;
  } // diff

  difference ()
  {
     translate ([0,0, 11/2]) cylinder (r=7.4, h=11, $fn=8, center=true) ;  // Octagon support dome
     translate ([0,0, 11/2]) cylinder (r=6.8, h=11.05, $fn=8, center=true) ;

     // Disassembly break holes
    for (i = [0:20])
       rotate ([0,0,i*360/20])  translate ([5,0,zblock_z-1.5/2]) cube ([3,1.0,1.5]) ;

   } // diff
 } // if support
} // module

// Subtract Outer from Inner hyperbolic shell to create spinner cap
module spinner()
{
  difference() {
    translate ([0,0,cap_height]) rotate ([180,0,0])
      rotate_extrude (convexity = 100, $fa=wresol) hyperbel_outer();
    translate ([0,0,cap_height-thick]) rotate ([180,0,0])
      rotate_extrude (convexity = 100, $fa=wresol) hyperbel_inner();
  }
}

// Define outer hyperbolic shell for boolean cut operations
module spinnersurface()
{
    translate ([0,0,cap_height]) rotate ([180,0,0])
      rotate_extrude (convexity = 100, $fa=wresol) hyperbel_outer();
}

```


[User]
I'd like to create a customizable 2D origami football design using OpenSCAD. I'm providing the basic structure and parameters I'd like to be configurable, based on the existing design I have.

Here are the key aspects:

1.  **Overall Shape:** The design should be based on a series of interconnected polygons forming the shape of a football (soccer ball). I can provide the specific coordinates for the outer outline and internal cut lines. These will be defined as `outline` (outer points), and a series of cut polygons `C1`, `C2`, etc. which are defined by `B` points.

2.  **Customizable Size:**
    *   `max_size_in_millimeter`: This will determine the maximum dimension of the longest side. The other side should automatically scale proportionally. This must be adjustable by the user.
    *   `model_height_in_millimeter`: This sets the thickness or height of the extruded 2D model. Also, must be adjustable by the user.

3.  **Thickness Control:**
    *   `outline_size_in_millimeter`: Specifies the thickness of the outer border. This must be adjustable by the user.
    *   `inline_size_in_millimeter`:  Sets the thickness of the inner cut lines. This needs to be adjustable as well.
    *   `inline_edge_radius_in_millimeter`: Controls the roundness of the corners for the inner lines. This must also be adjustable.

4.  **Flipping:**
    *   `flip_model`: A boolean flag or a string with options to mirror the design along the Y axis. The user should be able to set this to 'yes' or 'no'.

5.  **Coordinate Scaling:**  The coordinates for the points (A1, A2, B1, etc.) are all hardcoded as provided. The scaling should calculate the correct proportional sizes of `outline_size` and `inline_size` based on the provided max size.

6.  **Structure:** The design will use `linear_extrude` to create the 3D effect and offsets for generating the outlines and inner cut lines. It will be a difference between a slightly larger polygon that creates the outline, and the cut lines.

7.  **Libraries:** I don't expect any libraries to be needed here except possibly for error checking, if that's included. It's a relatively simple 2D design.

Please generate the OpenSCAD code for this based on these requirements. I don't need a single scad file with the data; just give me code that would run.

[Assistant]
customizable_origami_football.scad:
```
/*
 * Customizable Origami - Football - https://www.thingiverse.com/thing:2644010
 * by Dennis Hofmann - https://www.thingiverse.com/mightynozzle/about
 * created 2017-11-14
 * version v1.0
 *
 * Changelog
 * --------------
 * v1.0:
 *      - final design
 * --------------
 *
 * This work is licensed under the Creative Commons - Attribution - NonCommercial - ShareAlike license.
 * https://creativecommons.org/licenses/by-nc-sa/3.0/
 */

 // Parameter Section //
//-------------------//

// preview[view:north, tilt:top]

// The maximum size of the longest side. The shorter side will be automatically resized in same ratio.
max_size_in_millimeter = 120; //[20:300]

// The height of the model.
model_height_in_millimeter = 5; //[0.2:0.2:100]

// Thickness of the outer outline.
outline_size_in_millimeter = 1.8; //[0.5:0.1:20]

// Thickness of the inner outline.
inline_size_in_millimeter = 0.7; //[0.5:0.1:20]

// Roundiness of the ends of the inner outlines.
inline_edge_radius_in_millimeter = 1.0; //[0.0:0.1:5]

// Flip model
flip_model = "no"; //[yes,no]

/*[hidden]*/
max_size = max_size_in_millimeter;
model_height = model_height_in_millimeter;
$fn=32;

// Outer Points
A1 = [99, 309];
A2 = [215, 184];
A3 = [391, 57];
A4 = [483, 38];
A5 = [717, 41];
A6 = [764, 57];
A7 = [1079, 279];
A8 = [1135, 489];
A9 = [1166, 672];
A10 = [1148, 712];
A11 = [1005, 1008];
A12 = [803, 1119];
A13 = [638, 1161];
A14 = [431, 1139];
A15 = [241, 1038];
A16 = [120, 897];
A17 = [41, 714];
A18 = [33, 507];

outline = [A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18];

// Inner Points
B1 = [175, 304];
B2 = [375, 170];
B3 = [522, 296];
B4 = [401, 522];
B5 = [186, 523];
B6 = [873, 156];
B7 = [783, 286];
B8 = [926, 505];
B9 = [1091, 492];
B10 = [1060, 280];
B11 = [545, 746];
B12 = [808, 739];
B13 = [873, 940];
B14 = [660, 1071];
B15 = [462, 959];
B16 = [246, 943];
B17 = [114, 732];
B18 = [1040, 912];

// Polygons
C1 = [A1, A2, A3, A4, B2, B1];
C2 = [B2, A4, A5, B6, B7, B3];
C3 = [A5, A6, A7, B10, B6];
C4 = [A10, B9, B10, A7, A8, A9];
C5 = [B8, B7, B3, B4, B11, B12];
C6 = [B8, B9, A10, B18, B13, B12];
C7 = [A11, B18, A10, A9];
C8 = [A11, B18, B13, B14, A13, A12];
C9 = [B14, B15, B16, A15, A14, A13];
C10 = [B15, B11, B4, B5, B17, B16];
C11 = [B17, B5, B1, A1, A18, A17];

cut_polygons = [C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11];

min_x = A18[0];
min_y = A4[1];
max_x = A9[0];
max_y = A13[1];

x_size = max_x - min_x;
y_size = max_y - min_y;

x_factor = max_size / x_size;
y_factor = max_size / y_size;

inline_size = x_size > y_size ? inline_size_in_millimeter / x_factor / 2: inline_size_in_millimeter / y_factor / 2;
inline_edge_radius = x_size > y_size ? inline_edge_radius_in_millimeter / x_factor: inline_edge_radius_in_millimeter / y_factor;
outline_size = x_size > y_size ? outline_size_in_millimeter / x_factor - inline_size: outline_size_in_millimeter / y_factor - inline_size;

 // Program Section //
//-----------------//

if(x_size > y_size) {
    resize(newsize=[max_size, x_factor * y_size, model_height]){
        if(flip_model == "yes") {
            mirror([0,1,0]) {
                rotate([180,180,0]) {
                    create(outline, cut_polygons);
                }
            }
        } else {
            create(outline, cut_polygons);
        }
    }
} else {
    resize(newsize=[y_factor * x_size, max_size, model_height]){
        if(flip_model == "yes") {
            mirror([0,1,0]) {
                rotate([180,180,0]) {
                    create(outline, cut_polygons);
                }
            }
        } else {
            create(outline, cut_polygons);
        }
    }
}

 // Module Section //
//----------------//

module create() {
    linear_extrude(height=1) {
        difference() {
            offset(r = -0) {
                offset(r = +outline_size) {
                    polygon(points = outline, convexity = 10);
                }
            }

            for(cut_polygon = [0:len(cut_polygons)]) {
                offset(r = +inline_edge_radius) {
                    offset(r = -inline_size - inline_edge_radius) {
                        polygon(points = cut_polygons[cut_polygon], convexity = 10);
                    }
                }
            }
        }
    }
}

```


[User]
Hi! I'm looking to create a parametric battery holder in OpenSCAD, similar to the one I found on Thingiverse but I'd like to have some extra control over it. The basic idea is a cylindrical battery case, with cutouts around each cell and between them to save on material. I need it to handle multiple cells in a row, and the number of cells should be customizable. I've got some dimensions in mind, but I'd like them to be parametric so I can reuse the design for various battery types.

Specifically, I need these parameters to be adjustable:

*   **Battery Type:** I'd like presets for AAA, AA, C, D, and 18650 batteries, including the cap dimensions.
*   **Custom Dimensions:** I should be able to override the presets with my own length, diameter, and cap dimensions for custom battery sizes.
*   **Number of Cells:** The design should handle 2 or more cells.
*   **Wall Thickness:** The thickness of the holder's walls should be adjustable.
*   **Internal Cutout Height:** I'd like to control how deep the internal cutouts between the cells go - maybe even have an option to make it zero for no cut out.

The design should consist of two parts: the main case and a lid.

For the case, it should have:

*   Individual cylindrical cavities for each cell, including space for the positive cap.
*   External cutouts along the sides to save material.
*   Internal cutouts between cells.

The lid should:

*   Fit snugly over the case, and have recesses to fit onto the positive end of the cells.
*   Also have a snap-fit mechanism.

It would be amazing if the design can be easily adapted and re-used, so a well-parameterized and modular design is a must! And please make the code understandable! No need to optimize for speed of rendering. I don't have a specific library in mind, so feel free to use whatever works best.

[Assistant]
battery_case_v1-2.scad:
```

//Some common battery sizes.
type = "AAA";// ["AAA":AAA, "AA":AA, "C":C, "D":D, "18":18650, "custom":Custom]

numCells = 4;

//Length for custom cells (pre-set: 18500)(add some allowance to all to allow an easier fit)
custom_length = 52;
//Diameter for custom cells (pre-set: 18500)
custom_diameter = 18.4;
// Diameter of the + cap
custom_cap_dia = 0;
// Height of the + above the main cell
custom_cap_len = 0;
// Height of the internal cutout (zero leaves just a sincle circle removed from the center of the inner wall)
custom_x_cut = 0;

/* [Tweaks] */
// Thickness of the walls of the holder. You may want to adjust this for a thin wall thickness that works well with your printer. (and the cell size)
wall = 1.2;

//Hidden
$fn=120;

// Pre-set sizes (main Len, main Dia, cap Len, cap Dia, between cells Cutout Len)
if (type=="AAA"){
Case(44.5,10.7, 1, 4, 14);
Lid(44.5,10.7, 1, 4);
%translate([0,10.7*2,0]) dummyBatt(44.5,10.7, 0.8, 3.8);
};
if (type=="AA"){
Case(50.5,14.3, 1.2, 5.4, 18);
Lid(50.5,14.3, 1.2, 5.4);
%translate([0,14.3*2,0]) dummyBatt(50.5,14.3, 1.2, 5.3);
};
if (type=="C"){
Case(47,26.2, 2.2, 7.6, 16);
Lid(47,26.2, 2.2, 7.6);
%translate([0,26.5*2,0]) dummyBatt(47,26.2, 2.2, 7.5 );
};
if (type=="D"){
Case(57,33.7, 2.75, 9, 22);
Lid(57,33.7, 2.75, 9);
%translate([0,33.7*2,0]) dummyBatt(57,33.7, 2.75, 9 );
};
if (type=="18"){
Case(66.5,18.4, 2, 6.4, 24);
Lid(66.5,18.4, 2, 6.4);
%translate([0,18.4*2,0]) dummyBatt(66.5,18.4, 2.75, 9);
};
if (type=="custom"){
Case(custom_length, custom_diameter, custom_cap_len, custom_cap_dia, custom_x_cut);
Lid(custom_length, custom_diameter, custom_cap_len, custom_cap_dia);
%translate([0,custom_diameter*2,0]) dummyBatt(custom_length, custom_diameter, custom_cap_len, custom_cap_dia);
};

module dummyBatt(mLen, mDia, cLen, cDia) {
  union(){
    cylinder(d=mDia,mLen);
    translate([0,0,mLen]) cylinder(d=cDia,cLen);
  }
}

/* Case Body */
module Case(mLen, mDia, cLen, cDia, xCut){
  cellOffset = mDia+wall;
  difference(){
    for(i=[0:numCells-1]){
      difference(){
        translate([cellOffset*i,0,0]) cylinder(d=mDia+2*wall,mLen+cLen+wall-0.001);
        rotate([180,0,0]) translate([cellOffset*i,0,-mLen-cLen-wall]) dummyBatt(mLen, mDia, cLen, cDia);
        // Cutout the outside walls
        rotate([90,0,0]) translate([cellOffset*i,mDia+wall,-mDia+wall]) hull() {
          translate([0,mLen-2*mDia-wall,0]) cylinder(d=.8*mDia,mDia*1.6); cylinder(d=.8*mDia,mDia*1.6);
      }
    }
  }
  // Cutout the inner walls
  rotate([90,0,90]) translate([0,(mLen-xCut)/2,0]) hull() {
    translate([0,xCut,0]) cylinder(d=mDia/3.5,cellOffset*(numCells-1)); cylinder(d=mDia/3.5,cellOffset*(numCells-1));
  }
}
}

/* Lid */
module Lid(mLen, mDia, cLen, cDia){
 cellOffset = mDia+wall;
 translate([0, -2*mDia, 0])
 difference(){
  for(i=[0:numCells-1]){
    difference(){
      translate([cellOffset*i,0,0])
        cylinder(d=mDia+2*wall+2*wall,5+wall+cLen);
      translate([cellOffset*i,0,wall])
        cylinder(d=cDia,cLen);
    }
  }
  for(i=[0:numCells-1]){
    // main cylinder cuttout to allow lid to snap fit
    // has to be done like this to cut out all the walls between the cells
    translate([cellOffset*i,0,wall+cLen])
      cylinder(d=mDia+2*wall+0.1,5+2*wall+cLen);
  }
  }
}
```


[User]
I'd like to create a customizable 2D origami fox design using OpenSCAD. I want to be able to control the overall size, the height of the model, and the thickness of both the outer and inner outlines. I'm thinking I'd like it to be based on the design I saw here: [link to thingiverse thing] which includes the following set of coordinate points for the outer outline and inner cut lines.

The outer outline coordinates are:
```
A1 = [17, 367];
A2 = [149, 378];
A3 = [488, 325];
A4 = [555, 294];
A5 = [715, 318];
A6 = [976, 295];
A7 = [1187, 301];
A8 = [1378, 223];
A9 = [1644, 45];
A10 = [1615, 187];
A11 = [1663, 213];
A12 = [1688, 300];
A13 = [1799, 346];
A14 = [1770, 377];
A15 = [1660, 377];
A16 = [1573, 389];
A17 = [1387, 562];
A18 = [1410, 886];
A19 = [1481, 908];
A20 = [1499, 951];
A21 = [1414, 952];
A22 = [1292, 661];
A23 = [1215, 779];
A24 = [1212, 904];
A25 = [1272, 941];
A26 = [1275, 983];
A27 = [1212, 983];
A28 = [1147, 932];
A29 = [1146, 815];
A30 = [1098, 631];
A31 = [1051, 606];
A32 = [891, 751];
A33 = [880, 851];
A34 = [940, 874];
A35 = [964, 919];
A36 = [868, 917];
A37 = [802, 729];
A38 = [843, 635];
A39 = [811, 642];
A40 = [800, 672];
A41 = [611, 764];
A42 = [548, 872];
A43 = [583, 917];
A44 = [582, 955];
A45 = [503, 942];
A46 = [523, 747];
A47 = [638, 639];
A48 = [686, 441];
A49 = [396, 576];
A50 = [94, 507];
A51 = [32, 403];
```

And the inner cut lines (polygons) are:
```
C1 = [A1, A51, A2];
C2 = [A51, A50, A3, A2];
C3 = [A4, A5, A48, A49, A50, A3];
C4 = [A5, A6, B1, A39, A40, A41, A47, A48];
C5 = [A6, A7, A30, A31, B2, B1];
C6 = [A7, A8, A16];
C7 = [A8, A10, A16];
C8 = [A8, A9, A10];
C9 = [A10, A11, A12, A16];
C10 = [A12, A15, A16];
C11 = [A12, A13, A14, A15];
C12 = [A7, A16, A17, A22, A23, A30];
C13 = [A17, A22, A21, A18];
C14 = [A18, A19, A20, A21];
C15 = [A24, A25, A26, A27];
C16 = [A27, A28, A29, A30, A23, A24];
C17 = [B1, B2, A38, A39];
C18 = [B2, A31, A32, A37, A38];
C19 = [A37, A32, A33, A36];
C20 = [A33, A34, A35, A36];
C21 = [A47, A41, A42, A45, A46];
C22 = [A42, A43, A44, A45];
```
Where `B1 = [874, 515];` and `B2 = [977, 571];`

I'd also like an option to flip the model so it's a mirror image if needed. It would be great to have the inner outline edges rounded too - that was a nice touch in the thingiverse design.

Could you create a parametric OpenSCAD file for this? I don't need any special libraries.

[Assistant]
customizable_origami_fox.scad:
```
/*
 * Customizable Origami - Fox - https://www.thingiverse.com/thing:2646196
 * by Dennis Hofmann - https://www.thingiverse.com/mightynozzle/about
 * created 2017-11-15
 * version v1.0
 *
 * Changelog
 * --------------
 * v1.0:
 *      - final design
 * --------------
 *
 * This work is licensed under the Creative Commons - Attribution - NonCommercial - ShareAlike license.
 * https://creativecommons.org/licenses/by-nc-sa/3.0/
 */

 // Parameter Section //
//-------------------//

// preview[view:north, tilt:top]

// The maximum size of the longest side. The shorter side will be automatically resized in same ratio.
max_size_in_millimeter = 120; //[20:300]

// The height of the model.
model_height_in_millimeter = 5; //[0.2:0.2:100]

// Thickness of the outer outline.
outline_size_in_millimeter = 1.4; //[0.5:0.1:20]

// Thickness of the inner outline.
inline_size_in_millimeter = 0.7; //[0.5:0.1:20]

// Roundiness of the ends of the inner outlines.
inline_edge_radius_in_millimeter = 0.3; //[0.0:0.1:5]

// Flip model
flip_model = "no"; //[yes,no]

/*[hidden]*/
max_size = max_size_in_millimeter;
model_height = model_height_in_millimeter;
$fn=32;

// Outer Points
A1 = [17, 367];
A2 = [149, 378];
A3 = [488, 325];
A4 = [555, 294];
A5 = [715, 318];
A6 = [976, 295];
A7 = [1187, 301];
A8 = [1378, 223];
A9 = [1644, 45];
A10 = [1615, 187];
A11 = [1663, 213];
A12 = [1688, 300];
A13 = [1799, 346];
A14 = [1770, 377];
A15 = [1660, 377];
A16 = [1573, 389];
A17 = [1387, 562];
A18 = [1410, 886];
A19 = [1481, 908];
A20 = [1499, 951];
A21 = [1414, 952];
A22 = [1292, 661];
A23 = [1215, 779];
A24 = [1212, 904];
A25 = [1272, 941];
A26 = [1275, 983];
A27 = [1212, 983];
A28 = [1147, 932];
A29 = [1146, 815];
A30 = [1098, 631];
A31 = [1051, 606];
A32 = [891, 751];
A33 = [880, 851];
A34 = [940, 874];
A35 = [964, 919];
A36 = [868, 917];
A37 = [802, 729];
A38 = [843, 635];
A39 = [811, 642];
A40 = [800, 672];
A41 = [611, 764];
A42 = [548, 872];
A43 = [583, 917];
A44 = [582, 955];
A45 = [503, 942];
A46 = [523, 747];
A47 = [638, 639];
A48 = [686, 441];
A49 = [396, 576];
A50 = [94, 507];
A51 = [32, 403];

outline = [A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27, A28, A29, A30, A31, A32, A33, A34, A35, A36, A37, A38, A39, A40, A41, A42, A43, A44, A45, A46, A47, A48, A49, A50, A51];

// Inner Points
B1 = [874, 515];
B2 = [977, 571];

// Polygons
C1 = [A1, A51, A2];
C2 = [A51, A50, A3, A2];
C3 = [A4, A5, A48, A49, A50, A3];
C4 = [A5, A6, B1, A39, A40, A41, A47, A48];
C5 = [A6, A7, A30, A31, B2, B1];
C6 = [A7, A8, A16];
C7 = [A8, A10, A16];
C8 = [A8, A9, A10];
C9 = [A10, A11, A12, A16];
C10 = [A12, A15, A16];
C11 = [A12, A13, A14, A15];
C12 = [A7, A16, A17, A22, A23, A30];
C13 = [A17, A22, A21, A18];
C14 = [A18, A19, A20, A21];
C15 = [A24, A25, A26, A27];
C16 = [A27, A28, A29, A30, A23, A24];
C17 = [B1, B2, A38, A39];
C18 = [B2, A31, A32, A37, A38];
C19 = [A37, A32, A33, A36];
C20 = [A33, A34, A35, A36];
C21 = [A47, A41, A42, A45, A46];
C22 = [A42, A43, A44, A45];

cut_polygons = [C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15, C16, C17, C18, C19, C20, C21, C22];

min_x = A1[0];
min_y = A9[1];
max_x = A13[0];
max_y = A26[1];

x_size = max_x - min_x;
y_size = max_y - min_y;

x_factor = max_size / x_size;
y_factor = max_size / y_size;

inline_size = x_size > y_size ? inline_size_in_millimeter / x_factor / 2: inline_size_in_millimeter / y_factor / 2;
inline_edge_radius = x_size > y_size ? inline_edge_radius_in_millimeter / x_factor: inline_edge_radius_in_millimeter / y_factor;
outline_size = x_size > y_size ? outline_size_in_millimeter / x_factor - inline_size: outline_size_in_millimeter / y_factor - inline_size;

 // Program Section //
//-----------------//

if(x_size > y_size) {
    resize(newsize=[max_size, x_factor * y_size, model_height]){
        if(flip_model == "yes") {
            mirror([0,1,0]) {
                rotate([180,180,0]) {
                    create(outline, cut_polygons);
                }
            }
        } else {
            create(outline, cut_polygons);
        }
    }
} else {
    resize(newsize=[y_factor * x_size, max_size, model_height]){
        if(flip_model == "yes") {
            mirror([0,1,0]) {
                rotate([180,180,0]) {
                    create(outline, cut_polygons);
                }
            }
        } else {
            create(outline, cut_polygons);
        }
    }
}

 // Module Section //
//----------------//

module create() {
    linear_extrude(height=1) {
        difference() {
            offset(r = -0) {
                offset(r = +outline_size) {
                    polygon(points = outline, convexity = 10);
                }
            }

            for(cut_polygon = [0:len(cut_polygons)]) {
                offset(r = +inline_edge_radius) {
                    offset(r = -inline_size - inline_edge_radius) {
                        polygon(points = cut_polygons[cut_polygon], convexity = 10);
                    }
                }
            }
        }
    }
}

```


[User]
I'd like to generate a customizable 2D origami Christmas star using OpenSCAD. The star should be based on the provided point data, which defines both the outer shape and internal cut patterns.

Specifically, I need the following:

*   **Overall Shape:** The star is defined by an outer polygon using points A1 through A20.
*   **Cut Patterns:** The inner cut patterns are formed by polygons C1 through C25, which use points A and B. The B points define the corners of the internal cuts.
*   **Customization:**
    *   `max_size_in_millimeter`:  A parameter to control the maximum size of the longest side of the star. The shorter side should scale proportionally.
    *   `model_height_in_millimeter`: The overall height of the extruded model.
    *   `outline_size_in_millimeter`:  The thickness of the outer outline.
    *   `inline_size_in_millimeter`: The thickness of the inner lines.
    *   `inline_edge_radius_in_millimeter`: The radius of the rounded corners on the inner cut paths.
    *   `flip_model`: A boolean "yes"/"no" parameter to mirror the model along the Y axis.
*   **Functionality:**
    *   The design should be extruded to the specified `model_height_in_millimeter`.
    *   The outer shape should be created by offsetting a polygon by the `outline_size_in_millimeter`.
    *   The inner cut paths should be created by offsetting each `cut_polygons` by `inline_size_in_millimeter` using `inline_edge_radius_in_millimeter` to round the corners. These cuts should be subtracted from the outer shape.
    *   The final model should scale uniformly, such that if the maximum width is set to 100mm, and the actual width is calculated to be 200mm (before scaling), then the whole model will be scaled to 50%.
    *   The units are in millimeters.

I don't need any external libraries, just a single SCAD file. Could you generate that for me, please?

[Assistant]
customizable_origami_christmas_star_no2.scad:
```
/*
 * Customizable Origami - Christmas Star No2 - https://www.thingiverse.com/thing:2648532
 * by Dennis Hofmann - https://www.thingiverse.com/mightynozzle/about
 * created 2017-11-15
 * version v1.0
 *
 * Changelog
 * --------------
 * v1.0:
 *      - final design
 * --------------
 *
 * This work is licensed under the Creative Commons - Attribution - NonCommercial - ShareAlike license.
 * https://creativecommons.org/licenses/by-nc-sa/3.0/
 */

 // Parameter Section //
//-------------------//

// preview[view:north, tilt:top]

// The maximum size of the longest side. The shorter side will be automatically resized in same ratio.
max_size_in_millimeter = 120; //[20:300]

// The height of the model.
model_height_in_millimeter = 5; //[0.2:0.2:100]

// Thickness of the outer outline.
outline_size_in_millimeter = 1.8; //[0.5:0.1:20]

// Thickness of the inner outline.
inline_size_in_millimeter = 0.7; //[0.5:0.1:20]

// Roundiness of the ends of the inner outlines.
inline_edge_radius_in_millimeter = 0.4; //[0.0:0.1:5]

// Flip model
flip_model = "no"; //[yes,no]

/*[hidden]*/
max_size = max_size_in_millimeter;
model_height = model_height_in_millimeter;
$fn=32;

// Outer Points
A1 = [112, 527];
A2 = [426, 489];
A3 = [346, 190];
A4 = [615, 355];
A5 = [752, 47];
A6 = [889, 347];
A7 = [1162, 180];
A8 = [1084, 479];
A9 = [1411, 525];
A10 = [1159, 733];
A11 = [1412, 959];
A12 = [1092, 979];
A13 = [1160, 1285];
A14 = [887, 1116];
A15 = [750, 1444];
A16 = [632, 1105];
A17 = [357, 1280];
A18 = [425, 978];
A19 = [86, 975];
A20 = [363, 752];

outline = [A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20];

// Inner Points
B1 = [268, 909];
B2 = [411, 786];
B3 = [463, 826];
B4 = [444, 910];
B5 = [683, 1073];
B6 = [753, 1025];
B7 = [819, 1069];
B8 = [748, 1254];
B9 = [1233, 900];
B10 = [1046, 327];
B11 = [450, 341];
B12 = [589, 410];
B13 = [488, 480];
B14 = [911, 409];
B15 = [1014, 474];
B16 = [1106, 778];
B17 = [1073, 904];
B18 = [1050, 820];
B19 = [933, 462];
B20 = [559, 475];
B21 = [278, 572];
B22 = [462, 620];
B23 = [755, 219];
B24 = [752, 400];
B25 = [1046, 620];
B26 = [1231, 572];
B27 = [930, 959];
B28 = [1043, 1117];
B29 = [572, 964];
B30 = [463, 1124];
B31 = [621, 750];
B32 = [666, 595];
B33 = [831, 588];
B34 = [886, 746];
B35 = [753, 842];
B36 = [748, 916];
B37 = [544, 777];
B38 = [618, 528];
B39 = [876, 525];
B40 = [956, 775];
B41 = [754, 700];

// Polygons
C1 = [A2, A3, A4, B12, B11, B13];
C2 = [B11, B12, B20, B13];
C3 = [A6, A7, A8, B15, B10, B14];
C4 = [B10, B15, B19, B14];
C5 = [A10, A11, A12, B17, B9, B16];
C6 = [B16, B9, B17, B18];
C7 = [A14, A15, A16, B5, B8, B7];
C8 = [B7, B8, B5, B6];
C9 = [A18, A19, A20, B2, B1, B4];
C10 = [B2, B1, B4, B3];
C11 = [A2, B13, B20, B12, A4, A5, B23, B38, B21, A1];
C12 = [A5, B23, B39, B26, A9, A8, B15, B19, B14, A6];
C13 = [A9, A10, B16, B18, B17, A12, A13, B28, B40, B26];
C14 = [A13, A14, B7, B6, B5, A16, A17, B30, B36, B28];
C15 = [B30, B37, B21, A1, A20, B2, B3, B4, A18, A17];
C16 = [B21, B22, B32, B24, B23, B38];
C17 = [B23, B39, B26, B25, B33, B24];
C18 = [B26, B25, B34, B27, B28, B40];
C19 = [B28, B36, B30, B29, B35, B27];
C20 = [B29, B31, B22, B21, B37, B30];
C21 = [B22, B41, B29, B31];
C22 = [B24, B41, B22, B32];
C23 = [B24, B33, B25, B41];
C24 = [B25, B34, B27, B41];
C25 = [B35, B29, B41, B27];

cut_polygons = [C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15, C16, C17, C18, C19, C20, C21, C22, C23, C24, C25];

min_x = A19[0];
min_y = A5[1];
max_x = A11[0];
max_y = A15[1];

x_size = max_x - min_x;
y_size = max_y - min_y;

x_factor = max_size / x_size;
y_factor = max_size / y_size;

inline_size = x_size > y_size ? inline_size_in_millimeter / x_factor / 2: inline_size_in_millimeter / y_factor / 2;
inline_edge_radius = x_size > y_size ? inline_edge_radius_in_millimeter / x_factor: inline_edge_radius_in_millimeter / y_factor;
outline_size = x_size > y_size ? outline_size_in_millimeter / x_factor - inline_size: outline_size_in_millimeter / y_factor - inline_size;

 // Program Section //
//-----------------//

if(x_size > y_size) {
    resize(newsize=[max_size, x_factor * y_size, model_height]){
        if(flip_model == "yes") {
            mirror([0,1,0]) {
                rotate([180,180,0]) {
                    create(outline, cut_polygons);
                }
            }
        } else {
            create(outline, cut_polygons);
        }
    }
} else {
    resize(newsize=[y_factor * x_size, max_size, model_height]){
        if(flip_model == "yes") {
            mirror([0,1,0]) {
                rotate([180,180,0]) {
                    create(outline, cut_polygons);
                }
            }
        } else {
            create(outline, cut_polygons);
        }
    }
}

 // Module Section //
//----------------//

module create() {
    linear_extrude(height=1) {
        difference() {
            offset(r = -0) {
                offset(r = +outline_size) {
                    polygon(points = outline, convexity = 10);
                }
            }

            for(cut_polygon = [0:len(cut_polygons)]) {
                offset(r = +inline_edge_radius) {
                    offset(r = -inline_size - inline_edge_radius) {
                        polygon(points = cut_polygons[cut_polygon], convexity = 10);
                    }
                }
            }
        }
    }
}

```