Wings 3D Development Forum

Full Version: OpenJSCAD plugin - exporter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
These days I found at Twitter someone (Gilb-r Duval) who uses Wings3D to create models which are turned into papercraft objects.

To do that he uses an intermediary program to convert the exported .obj into a .jscad which is the important format in the process. So, as it didn't seem to be hard to create an exporter I tried to create one and here is it: wpc_jscad.beam

It was made for v2.2.4. To install it just download the file and use the option at File->Install Plug-In or Path and find the plugin file where you download it.




This video shows his workflow (still with the extra step):
Hello, I tried your plugin and it works fine to export polyhedron to jscad. It can already be very useful, but to be able to use it on my workflow, it needs to provide one more information : an array giving the group number of each face. Ideally a color would be enough, but the data available on obj format is material group, so I used it. I use this supplemental information to easily split the volume into separate parts to unfold separately, but the faces coloring could certainly find more uses.
gilboonet, thanks for your feedback.
For some reason your post was not automatically approved and I was missing it.

I Attached my test file, so I would like you could to use it in your workflow and give me back the files you generated using it (.obj and .jscad). This way I can try to make the changes, add options and make possible the exporter to be more useful. Smile
Hello, here is what I got when using your test file with my workflow.

I added materials from colors (select body, RMB, Vertex Attributes, Colors to Materials) then exported it to obj.

On the .jscad file, what I take from the materials is for each face the group where he belongs, and it is on the member called 'groups'. This information can be replaced by face color.
Thanks for the files.

When I looked at the docs I was not sure about what we would need to export the objects, so I used the simple option. Smile

By looking into .jscad file it looks like something is missing once the main function statement is absent:

PHP Code:
function main() {
    return <
something>



(12-13-2019, 01:40 PM)gilboonet Wrote: [ -> ]On the .jscad file, what I take from the materials is for each face the group where he belongs, and it is on the member called 'groups'. This information can be replaced by face color.
In this case, the .jscad file you send has a function which returns:
PHP Code:
return {faces:facesvertices:verticesgroups:groupsfaceCsg:faceCsgcsg:csg}; 
But, this seems to not be a valid object definition returned - at least using the https://openjscad.org/

So, maybe the site is limited or do your create a custom .jscad file for other application?
Indeed, my workflow creates a .jscad file that is not standalone but is used as a library from another jscad script. That way I can use it with as input of another script.
It is meant to be used as follow :
include "file.jscad"

function main() {
let a = volume()
}

But it is even more complex because as include doesn't work on windows OS anymore, I changed my workflow by injecting the function () into the other jscad that uses it
So, if we have an export option to set the file to be used in a include that would to work. Right?!

And how those properties:values are used by jscad?

I'm just trying to enable the way you use, but keeping the content valid.
Yesterday, after make the post above I realised that properties were arbitrary. You defined that. It's just JScript a sintax we can use.

So, the PM I sent you at Twitter is more pertinent. Smile
Something like that could work

volume = function () {
let faces =[[1,12,3],[3,12,7],[5,14,1],[7,14,5],[12,1,13], ... ],
vertices = [[0.11063329,-0.83372273,-2.1072196],[0.11063329,-0.83372273,-0.1072196], ... ],
groups = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4],
faceCsg = faces.map(m => CSG.Polygon.createFromPoints(m.map(n => vertices[n]))),
csg = CSG.fromPolygons(faceCsg);
return {faces:faces, vertices:vertices, groups:groups, faceCsg:faceCsg, csg:csg};
};

function main () {
return volume().csg;
}
Yeah. I did that yesterday before PM you. Including group colors too. I just needed to realise it's JScript code.

What I'm looking for is a way to avoid that unique volume attribution once we can be exporting multiple objects.
Pages: 1 2