PHPackages                             a.kraemer/openscad-version-creator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. a.kraemer/openscad-version-creator

ActiveProject[Utility &amp; Helpers](/categories/utility)

a.kraemer/openscad-version-creator
==================================

A script to process JSON input files and generate output files for OpenSCAD projects.

v1.0.0(1y ago)016proprietaryPHPPHP &gt;=8.1

Since May 4Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/betobetok/openscad-version-creator)[ Packagist](https://packagist.org/packages/a.kraemer/openscad-version-creator)[ RSS](/packages/akraemer-openscad-version-creator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

OpenSCAD Version Creator
========================

[](#openscad-version-creator)

**OpenSCAD Version Creator** is a script designed to process JSON input files and generate output files for OpenSCAD projects.

Features
--------

[](#features)

- Processes configurations defined in JSON files.
- Generates multiple versions of 3D models in formats such as `.stl` and `.png`.
- Compatible with PHP 8.1 or higher.
- Uses a PSR-4-based autoloading system.

Requirements
------------

[](#requirements)

- **PHP**: &gt;= 8.1
- **Composer**: To manage dependencies.
- **OpenSCAD**: To render 3D models.

Installation
------------

[](#installation)

1. Clone this repository to your local machine:

    ```
    git clone betobetok/openscad-version-creator
    cd VersionCreator
    ```
2. Install dependencies using Composer:

    ```
    composer install
    ```
3. Install OpenSCAD:

    - **Windows**:

        1. Download the installer from the [OpenSCAD website](https://openscad.org/downloads.html).
        2. Run the installer and follow the instructions.
        3. Ensure the OpenSCAD executable is added to your system's PATH.
    - **Linux**:

        1. Use your package manager to install OpenSCAD. For example: ```
            sudo apt update
            sudo apt install openscad
            ```
        2. Verify the installation by running: ```
            openscad --version
            ```
    - **macOS**:

        1. Install Homebrew if you haven't already: ```
            /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
            ```
        2. Use Homebrew to install OpenSCAD: ```
            brew install --cask openscad
            ```
        3. Verify the installation by running: ```
            openscad --version
            ```
4. Ensure OpenSCAD is installed and accessible from the command line.

Usage
-----

[](#usage)

### Running the Script

[](#running-the-script)

The main script is located at `bin/openscad-executor`. You can run it from the command line:

```
php bin/openscad-executor
```

### Configuration

[](#configuration)

The script uses JSON files to define input configurations. An example configuration file can be found in `example_config.json`.

#### Example Configuration: `example_config.json`

[](#example-configuration-example_configjson)

This file defines the parameters and variables used to generate multiple versions of 3D models. Below is an explanation of its structure:

- **`set_name`**: Defines the naming pattern for the generated models. Placeholders (e.g., `($font)`, `($fontSize)`) will be replaced with actual values during processing.
- **`set`**: Specifies the type of each variable in the configuration:

    - `-array`: Indicates that the variable is a list of predefined values.
    - `-range`: Indicates that the variable is a range of numeric values.
    - Other values (e.g., `"15"`) are treated as static values.
- **`variables`**: Contains the actual values for each variable:

    - **`$font`**: A list of font styles to be used in the models.
    - **`$fontSize`**: A numeric range `[0:0.1:2]` specifying font sizes from 0 to 2, incrementing by 0.1.
    - **`cut_corners`**: A boolean array (`true` or `false`) indicating whether corners should be cut.
    - **`name`**: A list of names for different shapes (e.g., `tetrahedron`, `cube`, etc.).

#### Example Breakdown

[](#example-breakdown)

```
{
    "set_name": "dice5-1_($font)__($fontSize)__(cut_corners)__(name)",
    "set": {
        "$font": "-array",
        "$fontSize": "-range",
        "cut_corners": "-array",
        "name": "-array",
        "size": "15"
    },
    "variables": {
        "$font": [
            "Centaur:style=Regular",
            "Century:style=Regular",
            "Chiller:style=Regular"
        ],
        "$fontSize": "[0:0.1:2]",
        "cut_corners": [
            "true",
            "false"
        ],
        "name": [
            "tetrahedron",
            "cube",
            "octahedron"
        ]
    }
}
```

- **`set_name`**: The output file names will follow the pattern `dice5-1____`.
- **`$font`**: The script will iterate through the list of fonts.
- **`$fontSize`**: The script will generate models for font sizes between 0 and 2, incrementing by 0.1.
- **`cut_corners`**: Models will be generated with and without cut corners.
- **`name`**: Models will be named after the specified shapes.

This configuration will generate multiple combinations of models based on the defined variables and their values.

### Generating Models

[](#generating-models)

The script will generate `.stl` and `.png` files in the configured output directory.

### Example: Using the `Executor` Class

[](#example-using-the-executor-class)

The `Executor` class is the main entry point for processing SCAD files and generating outputs. Below is an example of how to use it in a PHP script:

#### Example Script

[](#example-script)

```
