简体   繁体   中英

Is there a way to incorporate the OpenSCAD compiler in java or any other programming language?

I am currently using OpenScad to create a template code (where I insert values to the input variables) in order to generate 3D models.

The reason I am doing this is part of a larger project where I want to iteratively generate 3D models based on an evolutionary algorithm applied to the input variables where user preference will dictate the direction of evolution. (user choose a model from a selection of models and new models will be generated from the chosen model, rinse and repeat)

I want to be able to design a user interface for this. Is it possible for me to use the OpenScad compiler (and renderer if possible) in a programming language like Java (where I can design a UI for my program)?

PS I am a beginner so go easy on me

OpenSCAD is written in C++, so while integration with Java is possible, it's not something I'd recommend as it's probably a fair bit of work.

We're discussing adding a user-definable GUI like this to OpenSCAD. It's still being discussed with some early results published. All this is kind of in the expert domain until it's done, but see here for ideas/inspiration/info:

For an easier starting point for beginners, perhaps OpenJSCAD is good? That would give you a web app, which you could change to add your own GUI controls: http://openjscad.org/

See here for an example of someone who wrote their own UI on top of OpenJSCAD: http://custom.3dprintler.com/

All of these solutions still require a bit of tinkering - nothing is plug & play : /

It will be easier to use the OpenSCAD CLI in your program, something like:

PrintWriter writer = new PrintWriter("input.scad", "UTF-8");
writer.println("cube();");
writer.close();

Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("openscad -o output.stl input.scad");

and then you can just use another library to display the STL file.

You can read more about the OpenSCAD CLI here: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_OpenSCAD_in_a_command_line_environment

BowlerStudio from Commonwealth Robotics is a full robot design, development, programming, testing stack, which includes 3D CAD:

https://github.com/CommonWealthRobotics/BowlerStudio

programmed in Java and using an extension of Java code for 3D modeling, it should be familiar and workable to folks who know that programming language.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM