Outils pour utilisateurs

Outils du site


lancer_openscad_processing

Lancer OpenSCAD avec Processing

import java.io.*;
File repertoire;
 
void setup() {
  size(200, 200);
  repertoire = new File(sketchPath());
}
 
void draw() {
}
 
void mousePressed() {
  String[] cmd = {"/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD", 
    "-o", 
    "test.png", 
    "-D", 
    "param = [10, 20, 30]", 
    "test.scad"};
 
  Process p;
  try {
    p = Runtime.getRuntime().exec(cmd, new String[0], repertoire);
    p.waitFor();
    float error = p.exitValue();
    println("Erreur = " + error);
  } 
  catch (InterruptedException e) {
    e.printStackTrace();
  } 
  catch (IOException e) {
    e.printStackTrace();
  }
}

Fichier OpenSCAD à placer dans le répertoire du projet Processing

param = [0]; // La constante doit être initialisée afin que la compilation puisse se dérouler
echo(param);
cube([param[0], param[1], param[2]]);
lancer_openscad_processing.txt · Dernière modification : 2019/10/18 15:07 de Mushussu