from reading the code on the mobile, it seems the last ":" should have been
a ";" to end your function defenition
tir. 5. apr. 2022 10.26 skrev 3dcase via Discuss <discuss@lists.openscad.org
:
---------- Forwarded message ----------
From: 3dcase 3dcase@protonmail.com
To: "discuss@lists.openscad.org" discuss@lists.openscad.org
Cc:
Bcc:
Date: Tue, 05 Apr 2022 08:26:26 +0000
Subject: [OpenSCAD] parser error: syntax error....but cannot find it!
Hello at the Openscad forum,
trying my first code with a lookup function from a list, and I get a
parser error: syntax error. The problem is that I cannot find what it wants
from me. I copied an existing syntax, but I must be missing something
because that works and mine does not.
A hint with a little explanation would be really appreciated.
$fn=60;
//flat point set screw is according ISO 4026
//cone point set screw is according ISO 4027
//cup point set screw is according ISO 4029
//example
//iso_4026(size=1.6, length=3);
pointdiameter=0;
socket=1;
pitch=2;
//size==X ? [pointdiameter, socket, pitch]:
function socketsetscrewsizes(size)=
size==1.6 ? [0.8 , 0.78 , 0.35]:
size==2 ? [1 , 0.98 , 0.4]:
size==2.5 ? [1.5 , 1.4 , 0.45]:
size==3 ? [2 , 1.66 , 0.5]:
size==4 ? [2.5 , 2.23 , 0.7]:
size==5 ? [3.5 , 2.8 , 0.8]:
size==6 ? [4 , 3.36 , 1]:
size==8 ? [5.5 , 4.5 , 1.25]:
size==10 ? [7 , 5.66 , 1.5]:
size==12 ? [8.5 , 6.8 , 1.75]:
size==16 ? [12 , 9,1 , 2]:
size==20 ? [15 , 11.44 , 2.5]:
size==24 ? [18 , 13.6 , 3]:
((this below is the line with the error. It puts it at the first bracket
before "size"))
function pointdiameter(size) = socketsetscrewsizes(size)[ pointdiameter];
function socket(size) = socketsetscrewsizes(size)[ socket];
function pitch(size) = socketsetscrewsizes(size)[ pitch];
pd = pointdiameter(size);
s = socket(size);
pitch = pitch(size);
l = length;
offset = (size-pd)/2;
module iso_4026(size , length) {
difference() {
hull() {
cylinder(h=l,d=pd);
translate([0,0,pitch])cylinder(h=l-pitch-offset,d=size)
}
cylinder(h=size*s, d=s, $fn=6,center=true);
}
}
Sent with ProtonMail https://protonmail.com/ secure email.
---------- Forwarded message ----------
From: 3dcase via Discuss discuss@lists.openscad.org
To: "discuss@lists.openscad.org" discuss@lists.openscad.org
Cc: 3dcase 3dcase@protonmail.com
Bcc:
Date: Tue, 05 Apr 2022 08:26:26 +0000
Subject: [OpenSCAD] parser error: syntax error....but cannot find it!
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org