Getting Started - tomasf/Cadova GitHub Wiki
Getting Started
tl;dr: Create a new executable Swift package with Cadova as a dependency, import it, define your geometry inside
Model(...) { ... }
and run the program to generate a 3MF file.
1. Install Swift
If you're on macOS, the easiest path is to install the latest version of Xcode.
For Windows and Linux, install Swift directly from swift.org. We also recommend VS Code with the Swift extension for a smooth editing experience. On Linux, the Fontconfig library is required; install it with sudo apt-get install libfontconfig1-dev
.
2. Create a new Swift executable package
mkdir gizmo
cd gizmo
swift package init --type executable
3. Add Cadova as a dependency
Edit Package.swift
:
// swift-tools-version: 6.0
import PackageDescription
let package = Package(
name: "gizmo",
platforms: [.macOS(.v14)],
dependencies: [
.package(url: "https://github.com/tomasf/Cadova.git", .upToNextMinor(from: "0.1.0")),
],
targets: [
.executableTarget(
name: "gizmo",
dependencies: ["Cadova"],
swiftSettings: [.interoperabilityMode(.Cxx)]
)
]
)
4. Use Cadova
Edit main.swift
:
import Cadova
await Model("gizmo") {
Box([10, 10, 5])
.subtracting {
Sphere(diameter: 10)
.translated(z: 5)
}
}
Run it in your IDE or on the command line using swift run
. This will generate a gizmo.3mf
file in the current directory. You can open it in your slicer or viewer.
On macOS, using Cadova Viewer is recommended for the best experience. It will automatically reload the view when the model file changes.
To speed up the setup of a new model package, you can use the template GitHub repo.