JSCAD User Group

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    1. Home
    2. sheffieldnick
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 6
    • Best 0
    • Controversial 0
    • Groups 0

    sheffieldnick

    @sheffieldnick

    0
    Reputation
    4
    Profile views
    6
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    sheffieldnick Unfollow Follow

    Latest posts made by sheffieldnick

    • RE: Website "load a file" functionality?

      @gilboonet Thanks, but I'm not interested in running my own custom version of the site. I just want to link to the public website, hence the request to add this feature.

      posted in General Discussions
      sheffieldnick
      sheffieldnick
    • RE: Website "load a file" functionality?

      @sheffieldnick said in Website "load a file" functionality?:

      It should be very easy to support data: URIs, and you wouldn't need the backend process to get around CORS issues, etc.

      Looking at the V1 source (which is what the public site is running?), it appears the loading is done in /packages/web/src/ui/examples.js in function loadInitialExample(). Adding something like this would probably work:

      const isData = documentUri ? documentUri.match(/(data:\S+)$/) !== null : false
      
      ...
      
          } else if (isData) { // base64-encoded data example, e.g. https://openjscad.org/#data:...
            loadLocalStorage(atob(documentUri.split(',')[1]), params)
      
      posted in General Discussions
      sheffieldnick
      sheffieldnick
    • RE: Website "load a file" functionality?

      @z3dev Thanks. I've done some searches of previous threads but couldn't find anything directly relevant.

      Here is my site that dynamically generates a small piece of JSCAD code for 3D printing a stencil alignment jig for PCBs:

      https://climbers.net/sbc/kicad-pcb-panelization-javascript/

      at the moment I'm just asking users to copy'n'paste the code into the jscad.org website, but it would be great if you could add support for loading content with data: URIs so that I could provide a simple link and avoid the extra copy'n'paste steps.

      It should be very easy to support data: URIs, and you wouldn't need the backend process to get around CORS issues, etc.

      posted in General Discussions
      sheffieldnick
      sheffieldnick
    • RE: Website "load a file" functionality?

      Thanks 🙂 It doesn't seem to support data: URIs? e.g.

      https://www.openjscad.org/#data:text/javascript;charset=utf-8;base64,ZnVuY3Rpb24gbWFpbiAoKSB7DQogIHJldHVybiB1bmlvbigNCiAgICBjdWJlKHtzaXplOiBbMjAyLDEwNCw0XX0pLA0KICAgIGN5bGluZGVyKHtyOiAyLCBoOiA2fSkudHJhbnNsYXRlKFsxMCw1LDRdKSwNCiAgICBjeWxpbmRlcih7cjogMiwgaDogNn0pLnRyYW5zbGF0ZShbMjAyLTEwLDUsNF0pDQogICk7DQp9

      should load the script:

      function main() {
        return union(
          cube({size: [202,104,4]}),
          cylinder({r: 2, h: 6}).translate([10,5,4]),
          cylinder({r: 2, h: 6}).translate([202-10,5,4])
        );
      }
      

      Thanks

      posted in General Discussions
      sheffieldnick
      sheffieldnick
    • Website "load a file" functionality?

      Hi,

      I'm new to OpenJSCAD. Is there an API on the openjscad.org site to load & render a supplied JSCAD script as a URL parameter? e.g.

      https://www.openjscad.org/?file=https://my.url/something.jscad

      or

      https://www.openjscad.org/?script=function main () {...

      I have a web page that generates a jscad file with javascript, and I'd like to be able to render it on the openjscad.org site with just a single click.

      Thanks

      posted in General Discussions
      sheffieldnick
      sheffieldnick