superCAD

Description

The output is code. Currently supported:

A Library for Processing to export in cad software through code. This library is based on rawDXF.
Similarly to rawDXF, you need to call

beginRaw("superCAD.exportFormat", "outputPath.ext"); [...] endRaw();
inside your draw(); method.

superCAD was first designed for the P5v135 era.
superCAD is working with processing v1.0.

Download

Demo

*note: this example also show a library I'm working on. The export part is at the end.



Similar to rawDXF

Example 1.

Download example's source code (superCAD.pde)
/**
  *  Example by Guillaume LaBelle
  *     for superCAD exporter
  */

import superCAD.*;

String cadSoftware, ext;
boolean record = false;

void setup() {
  size(500, 500, P3D);
}

void draw() 
{
  background(0, 0, 26);

  //You call the renderer like:
  //    superCAD.AutoLISP --> .lsp
  //    superCAD.PovRAY   --> .pov
  //    superCAD.Rhino    --> .rvb
  //    superCAD.SketchUP --> .rb
  //    superCAD.Maya     --> .mel
  //    superCAD.ObjFile  --> .obj
  //    superCAD.ArchiCAD --> .gdl
  if(record)
    beginRaw("superCAD."+cadSoftware, "output."+ext);      


  ////////////////////////////////////////
  ////////////////////////////////////////
  //A nasty fuzzy geometry here:

  translate(width/2, height/2); 
  scale(.5f);

  for(int i=0; i<50; i++) {
    pushMatrix();
    rotateY(random(2*PI));
    rotateX(random(2*PI));
    translate(random(width/2)-random(width),random(width)-random(width),random(width)-random(width));
    box(random(width)*0.1f,random(width)*0.1f,random(width)*0.1f);
    popMatrix();
  }
  ////////////////////////////////////////
  ////////////////////////////////////////


  if (record) {
    endRaw();
    record = false;
  }

} 

void keyPressed() {

  switch(key){
  case 'r': 
    cadSoftware = "Rhino"; 
    ext = "rvb"; 
    break;
  case 's': 
    cadSoftware = "SketchUP"; 
    ext = "rb";
    break;
  case 'a': 
    cadSoftware = "AutoLISP"; 
    ext = "lsp";
    break;
  case 'p': 
    cadSoftware = "PovRAY"; 
    ext = "pov";
    break;
  case 'm': 
    cadSoftware = "Maya"; 
    ext = "mel";
    break; 
  case 'o': 
    cadSoftware = "ObjFile"; 
    ext = "obj";
    break;       
  case 'c': 
    cadSoftware = "ArchiCAD"; 
    ext = "gdl";
    break;       
  }
  record = true;
}



Very minimal interaction

Example 2.

import superCAD.*;

void setup() {
  size(500, 500, P3D);
  SuperCAD.init(this);
  SuperCAD.mode("AutoLISP");
  SuperCAD.fileName("myCADFile");
}

//Everything is handled automatically. No need to set begin|end.
void draw() 
{
  background(70);
  box(random(width),random(width),random(width));
} 

void keyPressed(){
  SuperCAD.recordNextFrame();
  //..or (in replacement to SuperCAD.mode();) in setup();
  //      you could specify a mode here:
  //SuperCAD.recordNextFrame("Rhino");
}



More complex loops and newLayer("layerName") method.

Example 3.

import superCAD.*;

void setup() {
  size(500, 500, P3D);
  SuperCAD.init(this);
  SuperCAD.mode("AutoLISP");
  SuperCAD.fileName("defaultName");
}

void draw() 
{
  background(70);

  //SuperCAD.fileName("myFile"+frameCount);
  SuperCAD.loop();
  SuperCAD.newLayer("FirstFloor");
  box(1,2,3); //...

  SuperCAD.newLayer("SecondFloor");
  box(4,5,6); //...

  SuperCAD.stop();

  SuperCAD.loop("rvb","myFile"+frameCount);
  box(7,8,9);
  SuperCAD.stop();
} 

void keyPressed() {
  //Automatic check with SuperCAD keys
  SuperCAD.keyCheck();
  //...or explicitly launch a specific recorder in case of conflicts
  if(key=='j')
    SuperCAD.recordNextFrame("SketchUP");
}


Changelog

Future developments for the superCAD involve a better structure
and the implementation of features such Groups or Layering, CSG.
Since those concepts are free in processing (where there is no
common standards for this), this library have been integrated to
the current development of the ANAR+ which support a more
advanced geometric structures.

While the development will primarily based on ANAR+, superCAD
will be maintained for more elementary usages.

superCAD v##: (Future dev..)

superCAD v07: (January 2010)

superCAD v06: (January 2010)

superCAD v05: (January 2009)

superCAD v04: (January 2009)

superCAD v03: (November 2008)

superCAD v02: (September 2008)

superCAD v01: (September 2008)

superCAD v00: (August 2008)



Code

Browse

Contact

Guillaume LaBelle
gll{a)spaceKIT.ca www: LaBelle.spaceKIT.ca
Processing.org