JSCAD User Group
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    How to run JSCAD from another application ?

    Scheduled Pinned Locked Moved Design Discussions
    20 Posts 3 Posters 5.2k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • gilboonetG Offline
      gilboonet @hrgdavor
      last edited by

      @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.
      Capture d’écran de 2021-05-14 11-23-52.png. 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.

      z3devZ 1 Reply Last reply Reply Quote 0
      • gilboonetG Offline
        gilboonet
        last edited by

        I will try to do it using the react component from this topic : https://openjscad.nodebb.com/topic/248/react-library-v2

        1 Reply Last reply Reply Quote 0
        • hrgdavorH Offline
          hrgdavor
          last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • z3devZ Offline
            z3dev @hrgdavor
            last edited by

            @hrgdavor super idea.

            For now, maybe a new page in the user guide would help.

            hrgdavorH 1 Reply Last reply Reply Quote 0
            • z3devZ Offline
              z3dev @gilboonet
              last edited by

              @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.

              hrgdavorH gilboonetG 2 Replies Last reply Reply Quote 0
              • hrgdavorH Offline
                hrgdavor @z3dev
                last edited by

                For now, maybe a new page in the user guide would help.

                ok, I am ok with that, but for what part exactly ? 🙂

                z3devZ 1 Reply Last reply Reply Quote 0
                • hrgdavorH Offline
                  hrgdavor @z3dev
                  last edited by

                  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.

                  1 Reply Last reply Reply Quote 0
                  • z3devZ Offline
                    z3dev @hrgdavor
                    last edited by

                    @hrgdavor sorry

                    A page that showcases various usage of JSCAD.

                    1 Reply Last reply Reply Quote 0
                    • gilboonetG Offline
                      gilboonet @z3dev
                      last edited by

                      @z3dev That's great news.

                      1 Reply Last reply Reply Quote 0
                      • hrgdavorH Offline
                        hrgdavor
                        last edited by

                        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.

                        630abd82-3a5c-4d06-a373-3c784b6f4d92-image.png

                        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.

                        44f72e7a-dc53-4dbb-808e-b704abbdb869-image.png

                        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 ?

                        gilboonetG 1 Reply Last reply Reply Quote 0
                        • gilboonetG Offline
                          gilboonet @hrgdavor
                          last edited by

                          @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.

                          hrgdavorH 1 Reply Last reply Reply Quote 0
                          • hrgdavorH Offline
                            hrgdavor @gilboonet
                            last edited by

                            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 ?

                            gilboonetG 1 Reply Last reply Reply Quote 0
                            • gilboonetG Offline
                              gilboonet @hrgdavor
                              last edited by

                              @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.

                              hrgdavorH 1 Reply Last reply Reply Quote 0
                              • hrgdavorH Offline
                                hrgdavor @gilboonet
                                last edited by

                                @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.

                                gilboonetG 1 Reply Last reply Reply Quote 0
                                • gilboonetG Offline
                                  gilboonet @hrgdavor
                                  last edited by gilboonet

                                  @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.

                                  1 Reply Last reply Reply Quote 0

                                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                  With your input, this post could be even better 💗

                                  Register Login
                                  • First post
                                    Last post
                                  Powered by NodeBB | Contributors