Save a PShape on Hard Drive (please help)

hello all,

I am generating an PShape from a CSG (with JCSG) and wanted to ask whether I can save the PShape in one go.

like (pseudo code)

PShape myShape;
.......
myShape.save(sketchPath("")+"sample.obj");

Any ideas?

(too long for an mcve)

Didn’t find anything here: Reference / Processing.org

What I tried

What I tried is to save a CSG instead PShape: (see link below) (didn’t work)

  //-------
  // DIRECT COMMANDS 

  else if (key=='s') {

    // make PShape from cubes
    make_csgResult(); // one CORE function
    // save union as stl
    try {
      FileUtil.write(
        Paths.get(sketchPath("sample.obj")), 
        cubeResult.toObjString()
        );
    } 
    catch (IOException ex) {
      ex.printStackTrace();
    }//catch
  } // else if

  //
  else if (key=='l') {
    println("loading");
    //load shape into Processing
    csgResult = loadShape(sketchPath("sample.obj"));
    // change state 
    stateProgram = STATE_SHOW_PSHAPE;
  }

  //-------

Background:

For more information about what I mean with making a PShape from CSG :

see java - Is it possible to use jcsg library with Processing? - Stack Overflow

Thanks to all!

Warm regards,

Chrisir

if you just want the mesh

a PShape save function is something that has been talked about alot in the past but due to the nature of the PShape it’s a complex beast to wrangle.

note: the library talked about in that tweet is here and can be imported via sketch. I don’t know the details of the PShape you are creating and what properties you need to export so it’s difficult to offer anything more. Best of luck.

1 Like