@z3dev Thanks a lot, it is always helpful to understand the reason of specific behaviors. My design has one path for the outline that will be cut, and lines for the folds. To remove the black fill I can try to turn the path to a polygon.
Posts made by gilboonet

RE: Simple 2d parametric design

RE: Simple 2d parametric design
Hello, I now made the parametric version, here. The only parameter is width (largeur) that is the outer width of the frame obtained when 4 pieces are assembled together. I needed to juggle with cm and inches to make it right.
Here is a screenshot of what I have. When I view the generated svg into my browser (Firefox, bottom right), I have red and blue lines, even if there is a black fill that is certainly default because I didn't use black on the jscad script.
The other screenshot if from my laptop on win10 that I need to use my blade cutter software. I imported the svg and was able to prepare it for cut.
The only drawback for the moment is that the svg imported on Inkscape (top right of first screenshot) loses the red and blue lines, but editing the svg won't be needed for such a simple design.

RE: Simple 2d parametric design
@hrgdavor Thank you for your reply. I'm giving it a try.
On top left the svg that my unfolder generated
On bottom left the svg generated by JSCAD, I needed to edit it by hand to add colors. I think the parametric part won't be hard, I just need to translate the second path (poly2). I'm still need to know what unit is used (I suspect it is inches) because the final scale is not the same as the original one. 
Simple 2d parametric design
Hello, is it possible to use JSCAD to make a parametric 2d design ? I made a basic frame pattern from a 20x20x5 3d model, and unfolded its pattern that is made of 4x the same piece. I figured that this pattern can be used to make frames of any length only by changing the distance between the top and the bottom. Do you have hints to do such design ? Could I make it with 2 different kinds of line (the solid red is for cuts and the dotted maroon is for mountain folds) ?

RE: Best way to get started with JSCAD
@RunningUtes Hello, https://openjscad.xyz/dokuwiki/doku.php?id=en:jscad_design_guide is as close as possible to a getting started section. I often use its code to start new designs.
What I am now used to add is :
add this first require :
require jscad = require('@jscad/modeling')
then change others to :
require { ... } = jscad.xxxWhat a new user must be aware of is that the requires are compulsory and maybe it could be a nice resource to have a list, because when you start you don't know what to use and what is the needed require to add to use something. It's a good way to make one dig the doc and the code, but it might be too much for beginners.
The functional syntax (I mean main = () => { and so on) is maybe a little odd for people who are not hardcore developers, so the examples are useful.

RE: V2 feedback
@z3dev I think I get it now, it means that there's no simpler way to make the slices than what I already did at first.

RE: V2 feedback
@z3dev In order to simplify my process, I'm trying to directly use project to make the slices, and I'm beginning with an example, but I don't understand how to make several slices. First I used origin but it does not seem to work, then I'm translating the oldObject and it does not work, everytime I have the same slice.
here's my latest code :const jscad = require('@jscad/modeling') const { ellipsoid } = jscad.primitives const { project } = jscad.extrusions const { translateX, translateY, translateZ, center } = jscad.transforms const main = () => { const vol = ellipsoid({radius: [10, 15, 20], segments: 12}) let r = [] for(let i = 0, dx = 80; i < 50; i += 10, dx += 40){ r.push( translateX(dx, center({}, project({axis:[1,0,0]}, translateZ(i, vol)))) ) } r.push(vol) return r } module.exports = { main }
Maybe do I need to translate the object prior to the projection ?

RE: V2 feedback
@z3dev Yes I'm creating the slices for each axis from intersection of the model and a translated cuboid, then I create notches made from intersections of those slices, 1st axis slices have top half of those intersections subtracted and 2nd axis slices have bottom half, so they fit. Code is :
const main = (params) => { const sc = 1, ep = params.ep *2 //const vv = require('./' + params.v + '.obj') const vv = require('./' + params.v) const vol = center({}, rotateX(degToRad(90), vv)) //const vol = center({}, vv) let r = [], rH = [], rV = [] let bV = measureBoundingBox(vol) // Recup parametres const pv = Object.values(params) const lH = pv.slice(0,10).filter(Number).map(x => (x50)/100) const lV = pv.slice(10,20).filter(Number).map(x => (x50)/100) // 1°) Traverses en X (H) fH = bV[1][0]  bV[0][0] mH = (bV[1][0] + bV[0][0]) / 2 var trH = cuboid( { size: [ ep, 1+bV[1][1] bV[0][1], 1+bV[1][2]  bV[0][2] ]} ) for (let i = 0; i < lH.length; i++){ var t = intersect(vol, translateX(fH * lH[i], trH)) if (t.polygons.length > 0) rH.push(t) } // 2°) Traverses en Y (V) fV = bV[1][1]  bV[0][1] mV = (bV[1][1] + bV[0][1]) / 2 var trV = cuboid( { size: [ 1+ bV[1][0]  bV[0][0], ep, 1+ bV[1][2]  bV[0][2] ]} ) for (let i = 0; i < lV.length; i++){ var t = intersect(vol, translateY(fV * lV[i], trV)) if (t.polygons.length > 0) rV.push(t) } // 3°) Entrecroisement var ur = union(intersect(union(rH), union(rV))); var tmp = scission(ur) console.log(tmp.length) var eS = [], eH = [], eV = []; for(let i=0; i< tmp.length; i++){ let p = tmp[i]; let b = measureBoundingBox(p), //d = vec3.subtract(b[1], b[0]); d = [b[1][0]b[0][0], b[1][1]b[0][1], b[1][2]b[0][2]]; let c1 = translate([b[0][0], b[0][1] + ep/2, b[0][2]], cuboid({size: [d[0], d[1]*2, d[2]]})); let c2 = translate([b[0][0] + ep/2, b[0][1], b[1][2]], cuboid({size: [d[0]*2, d[1], d[2]]})); eH.push(intersect(tmp[i], c1)); eV.push(intersect(tmp[i], c2)); } rH = rH.map(x=> subtract(x, eV)); rV = rV.map(x=> subtract(x, eH)); if(params.mode == '3'){ // 3d r.push(colorize([0,1,0,0.8], translateX(70, subtract(vol, [rH,rV])))); r.push(colorize([0.5,0.0,0], translateX(70, rH.shift()))); if(rH.length > 0){ r.push(colorize([1,0,0], translateX(70, rH))); } r.push(colorize([0,0,0.5], translateX(70, rV.shift()))); if(rV.length > 0){ r.push(colorize([0,0,1], translateX(70, rV))); } } else { // 2d var dk = Math.max(fV, fH) *1.1 for(let ih = 0; ih < rH.length; ih++){ let b = measureBoundingBox(rH[ih]); //r.push(translateX(dk *ih, union(vol2surf(rH[ih], 'x', b[0][0])))) r.push(translateX(dk *ih, union(project({axis:[1,0,0]}, rH[ih])))) } for(let iv = 0; iv < rV.length; iv++){ let b = measureBoundingBox(rV[iv]); //r.push(translate([dk *iv, dk  params.dky], union(vol2surf(rV[iv], 'y', b[0][1])))) r.push(translate([dk *iv, dk  params.dky], union(project({axis:[0,1,0]}, rV[iv])))) } } return r; }
Stack trace is maybe (I'm using Firefox) :
fromPoints blob:https://openjscad.xyz/333c3c92e91a42a78b4b7dc2cdc255ce:555 m blob:https://openjscad.xyz/333c3c92e91a42a78b4b7dc2cdc255ce:1389 map selfhosted:224 projectGeom3 blob:https://openjscad.xyz/333c3c92e91a42a78b4b7dc2cdc255ce:1389 n blob:https://openjscad.xyz/333c3c92e91a42a78b4b7dc2cdc255ce:1389 map selfhosted:224 project blob:https://openjscad.xyz/333c3c92e91a42a78b4b7dc2cdc255ce:1389 main blob:https://openjscad.xyz/333c3c92e91a42a78b4b7dc2cdc255ce line 38 > Function:137 instanciateDesign blob:https://openjscad.xyz/333c3c92e91a42a78b4b7dc2cdc255ce:5 rebuildSolids blob:https://openjscad.xyz/333c3c92e91a42a78b4b7dc2cdc255ce:8 onmessage blob:https://openjscad.xyz/333c3c92e91a42a78b4b7dc2cdc255ce:11

V2 feedback
Hello, I'm updating my 2 axis slicer, replacing my functions by scission() and project(). And I'm having an odd error with project(). My volume is centered, and when I try to slice on the Y axis on some places that are <0 I have :
Error : the given points must define a closed geometry with three or more points Line: 555"
My test volume is symetric, and when I slice symetrically, it works. But what is odd is that at the left of the <0 part of the volume I can also slice. For the moment I will use my script with scission() and my pseudoprojection function vol2surf().
There's also another thing, when I use the script for some time, adding, moving and removing slices and also switching from 3d to 2d, the script hangs and I need to reload the page, sometimes, the script loads without the parameters, and I need to reload it again. There's maybe a memory issue, but I only have 8 Gb of RAM.
I'm also starting to create parametric furniture which is my main goal and was impossible to do as long as there were those Tjunctions errors that are now overcome, and it looks promising. For the moment I'm exporting a furniture model to .STL, then import it when I want to slice it.

RE: using vector operations (subtract)
@z3dev Thanks, I will change to subtract(a, a, b)

using vector operations (subtract)
Hello,
yesterday I needed to modify my 2 axis slicer script for it to be compatible with latest v2 version. The error shown into web console was about subtract, so I first thought there was a problem with CSG subtract and discarded the code using it, but indeed it was vec3.subtract that I'm using as a replacement of now deprecated minus(). I replaced it with//d = vec3.subtract(b[1], b[0]); d = [b[1][0]b[0][0], b[1][1]b[0][1], b[1][2]b[0][2]];
but isn't there anymore a way to use vector operations like subtract() because it helps keeping the code easy to read.

RE: basic design for projection
Here's a first test :
The output is the same as it was with my function. 
RE: basic design for projection
@z3dev I will try it ASAP and will give back some feedback.

basic design for projection
Here is the basic design where it would be useful to use a projection function. In order to make simple scroll saw pattern, I was asked to make a generic script that users could easily change. For the moment it's using my function vol2surf that "works" as a projection even if it far from that.
I saw that a projection function is now available (projectionOfPoint), how can I use it to replace mine ?
the project is here, it's in a .zip because it uses an external 3d model

RE: 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.

RE: How to run JSCAD from another application ?
@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.

RE: Some designs...
@z3dev That's cool designs. Maybe you can add links to open them in JSCAD like
Which reminds me that I have such links on several places but with old site that I need to replace.

RE: How to run JSCAD from another application ?
@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.

RE: designs for blade cutter (svg)
@hrgdavor Yes that's this one. (the Maker comes with a finepoint blade and a rotary blade)