Website "load a file" functionality?
-
@zorglups there's a bug in the V1 proxy script, remote.pl, and this prevents files to be loaded properly if the file (URL) does not have a proper extention.
a fix has been made, and the V2 website is running the fixed version of remote.pl
but you need to provide a URL which accesses a V2 design, such as...
https://www.jscad.xyz?uri=https://www.thingiverse.com/download:8705160
OR
https://www.jscad.xyz#https://www.thingiverse.com/download:8705160
-
@zorglups The syntax is not ?url=[your_url] but #[your_url]. But on this case, the url is a download url, the script must be downloaded then dropped to OpenJSCAD.org file drop zone (bottom left frame).
-
Strangely enough, the following link won't work:
https://openjscad.org/?uri=https://www.thingiverse.com/download:106799This is said because it would make easy to let people open an openjscad object from a link in the thingiverse description.
The error is:
Uncaught Error: The JSCAD script must contain a function main() which returns one or more CSG or CAG solids.
Line: 89,col: 7Tjere is a main() though.
-
@sheffieldnick this would be a nice addition, but V2 is the main focus now. we would welcome changes to make this part of V2.
-
@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.
-
@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)
-
@sheffieldnick As V2 is on active development, I don't think that new functionality could be add to V1, but I'm only a user not a developer. This project could maybe help you :
https://github.com/danmarshall/jscad-gallery
Or you could also do a fork. Long ago, I added some functionalities to OpenJSCAD v0.5 so the user can select a data file that will load openJSCAD with a .jscad file and populate it with parameters, but it's very old code (from 2016) that's not on github... http://gilboo.carton.free.fr/OJSC5/edit_ner2.html -
@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.
-
@sheffieldnick sorry, but only full URLs are supported.
there's a backend process involved, that down loads the URL contents, and posts the contents to the WEB UI.
i think that you are trying to create a custom website using a JSCAD design in the back ground. if so you can look at some of the previous threads posted here, so on the issue list.
-
@sheffieldnick I don't remember that it handles data protocol, only used if with file names
-
Thanks It doesn't seem to support data: URIs? e.g.
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
-
This post is deleted! -
Hello, it can be done like that, put a "#" after openJSCAD.org then the url of your script.
https://openjscad.org/#https://raw.githubusercontent.com/gilboonet/designs/master/make_pattern.jscad