How to run JSCAD from another application ?
-
Hello, long ago, I wrote this html/js application that allow the user to graphically build a polygon net, same structure as a polyhedron but only on 2d, and I used JSCAD (V1) to render the net (my data is into parameter w that I hided). I would like to port this app to V2 but I have absolutely no clue how I can do that as V2 architecture is too complex for me to be able to tweak it as I did with V1. Is there a project somewhere where I can see how to run JSCAD from another application ?
-
@hrgdavor yes, the method I used was what was available but any other could replace it. The purpose is to get data from the embedded jscad script and create a pdf file from it that can then be downloaded or directly viewed into the browser.
-
@gilboonet if not localStorage, postMessage could work ... as design is running in worker.
and I will look into how to integrate more closely so we can communicate with the embeded jscad script.
-
@hrgdavor Yes, it can be found here :
- html (derived from min.html of v1) with the .jscad code https://github.com/gilboonet/gilboonet.github.io/blob/master/OpenJSCAD.org/packages/web/scripts.html
- js (derived from index.js of v1) with the code to create pdf, (creePDF) : https://github.com/gilboonet/gilboonet.github.io/blob/master/OpenJSCAD.org/packages/web/dist/scripts.js
To work the .jscad needs to push data into an array (see creePDF to see possibles types of data) that is then put into a localStorage parameter. The script that's into the textarea with id="zc_tranches02" contains the script for the V1 2 axis slicer and it pushes data that way. But, as I didn't manage to have localStorage work with V2, I don't know if it is possible.
-
PDF button fires a node js script that read that file and create a pdf from it, as I didn't find a way to fire that button with V2 I didn't add it.
can u share that script ?
-
@hrgdavor You did really nice improvements. On the V2 version I don't export to PDF, but only to a big SVG. On the V1 version that exports to PDF, my scripts create a file with data on what needs to be rendered (triangle, text, line, next page, etc) and the PDF button fires a node js script that read that file and create a pdf from it, as I didn't find a way to fire that button with V2 I didn't add it.
-
Hi ,
I have taken your script and added some performance improvements to enable cool user interaction with the slicer
http://3d.hrg.hr/jscad/three/threejscad.html?uri=examples/sqed/index.js
by default "model preview" is ON and you can see the slices in 3D superimposed over the selected obj model.
speed improvements mean you can move sliders and have live preview.
if you uncheck the "model preview" you will get the 2d view of the parts with all the cuts for interconnecting like in the original version.
I will look into making a a new type of param that is file upload/url so that way users can use your script with their model just by accessing the website and no needing to know how to tweak the script.
this version ov jscad viewer has only stl export (I was lazy and it is only one I use) ... how did you generate PDF ?
-
@z3dev That's great news.
-
@hrgdavor sorry
A page that showcases various usage of JSCAD.
-
There’s a new projection function in the works. Hopefully, it will be available in one or two weeks.
there is need for projection and slice ...
although one could make a thin slice with subtract and then use projection to make a 2d shape out of it.
-
For now, maybe a new page in the user guide would help.
ok, I am ok with that, but for what part exactly ?
-
@gilboonet said in How to run JSCAD from another application ?:
Last week, I started to explain to someone how to make basic patterns for scroll saw, and I struggled to explain to him that there's no built-in function for projection and that he needs to use the functions that I wrote for that as a workaround. That made this basic project to hard for a beginner.
There’s a new projection function in the works. Hopefully, it will be available in one or two weeks.
-
@hrgdavor super idea.
For now, maybe a new page in the user guide would help.
-
That is a very interesting use-case.
One thing that comes to mind is that for example if you can have an additional type of parameter (file) we could make a script that returns empty array in the begining and then when file is uploaded into that paremeter (local file, or external url) the you can play with other options.
It would be a type of script that would work directy on the openjscad.xyz ... and of-course in that case emdbeded in your website for example.
I will look into it and see if I can incorporate support for the use-case in the new jscad website.
-
I will try to do it using the react component from this topic : https://openjscad.nodebb.com/topic/248/react-library-v2
-
@hrgdavor With V1 I was able to make a little page where users could choose a model (or import one) then a jscad script, so that the script runs using the model to do something.
. It worked but was buggy with some CSG operations on some models. For those who wanted to learn JSCAD it was possible to export to .jscad and have the full script to learn from it. And for scripts that create lots of 2d data, it exported to multipage pdf. Sadly I don't know how to do the same with V2.For the moment, I made a V2 version of the "tranchage / 2 axes" (2 axis slicer) that makes a skeleton and is useful to make cardboard furniture, but it cannot be used online and need to be download locally in order to be able to add 3d model to be processed, so it's not easy to put that on a website, and I'm making those devs not only for myself but mostly for other cardboard craftsperson and most of them have no knowledge of computer science and they don't understand how to use it. It is here : https://github.com/gilboonet/gilboonet.github.io/blob/master/sq_edit/sqed.zip (uncompress the zip into a folder, and open it as a project from jscad, it can use any .obj file that you put into the folder, enter its name (without .obj) into "volume" parameter)
Last week, I started to explain to someone how to make basic patterns for scroll saw, and I struggled to explain to him that there's no built-in function for projection and that he needs to use the functions that I wrote for that as a workaround. That made this basic project to hard for a beginner.
I'm currently working on a project that I stared very long time ago when JSCAD was alpha : a furniture customizer, I will add a post on the forum when I have a first working example.
-
One of the things other users have asked for is to have a showcase page/website to link to interesting projects using jscad and of course if those projects link back that helps too.
This would help to build an active community and give incentive for others to join.
I am sure @z3dev would like this too.
I would not go overboard with big ideas, but instead small steps in that direction (like that url proposal for integration and sharing). I would like to connect with you as you are active here (from what I can see) .
-
@hrgdavor Hello, yes I saw that, thank you. I am not on my pc as it is upgrading to new Ubuntu version this morning. I already migrated all my most used scripts to V2 and now I'm trying to do the same with the others like this project. My aim is to have as little dependencies as possible, I already converted my unfolder to vanilla JS and it allowed me to make an automatic version that goes much faster than JSCAD version, but I know that it was only possible because it didn't use CSG, for all projects using CSG JSCAD is the best solution for me. I will take a look at your discussion about embedability of JSCAD, that's really what I'm looking for.
-
@gilboonet I have sent you my email in the chat section of this forum, so we can get in touch as I would like to work closely with you regarding the jscad integrations.
-
Hi,
I am actually in process of taking apart jscad web V2. The devs that made it are gone and the framework used is confusing for me.
I have an alternative engine that I know how to setup with already few nice improvements that I woul like to bring back to openjscad.xyz
http://3d.hrg.hr/jscad/three/threejscad.html?uri=examples/parametric_butt_hinge_3.7.js
drag and drop of files like openjscad does not work, but you can run scripts with uri=parameter.
I have seen few cool projects of yours that use openjscad in the forums here, and I am interested in helping you bringing them to V2. you have a pretty interesting set of use-cases and it would be great to support them.
I have also created a discussion page to improve embedability of jscad:
https://github.com/jscad/OpenJSCAD.org/discussions/837
that mentions tight integration via postMessage but there are few security concerns.