inspecting fuctions

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

inspecting fuctions

DanS
What do people do for debugging functions given that echo() doesn't work inside them?

I'd prefer not to stream debugging output into the return value of the function.

Virus-free. www.avast.com

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
tp3
Reply | Threaded
Open this post in threaded view
|

Re: inspecting fuctions

tp3
On 02/10/2018 09:39 PM, Dan Shriver wrote:
> What do people do for debugging functions given that echo()
> doesn't work inside them?
>
It is available for functions in the nightly builds.

For some info, see:
https://github.com/openscad/openscad/pull/1830

There's still some todo:
https://github.com/openscad/openscad/issues/1859

ciao,
   Torsten.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
-- Torsten
Reply | Threaded
Open this post in threaded view
|

Re: inspecting fuctions

Troberg
In reply to this post by DanS
I break up the function into simpler parts and test them individually.
Sometimes, I do this through breaking it up into many smaller function, and
one function which puts it all together, sometimes I do it by commenting out
parts of the function temporarily for testing purposes.



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: inspecting fuctions

nophead
I use this function to echo any part of an expression.

// Echo expression and return it
function echoit(x) = echo(x) x;


Before function echo was added I sometimes had to resort to translating code into Python to debug it.

On 11 February 2018 at 12:02, Troberg <[hidden email]> wrote:
I break up the function into simpler parts and test them individually.
Sometimes, I do this through breaking it up into many smaller function, and
one function which puts it all together, sometimes I do it by commenting out
parts of the function temporarily for testing purposes.



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: inspecting fuctions

RobWLakes
In reply to this post by Troberg
For those who are concerned about "libraries", could a Save option be included in OpenSCAD that has an "archive" feature that simply saves the target file and any referenced library, or subfile into a ZIP file(for example).
With gigabytes so cheap these days, this would not cost much??
No doubt over time, changes to the OpenSCAD IDEmight render any particular example 'broken' but at least anyone else coming along behind would have a complete snapshot of the original working design to begin with.
It would also make sharing OpenSCAD designs easier?
Cheers.
Rob
Cheers, RobW

On 11 February 2018 11:02:04 pm AEDT, Troberg <[hidden email]> wrote:
I break up the function into simpler parts and test them individually.
Sometimes, I do this through breaking it up into many smaller function, and
one function which puts it all together, sometimes I do it by commenting out
parts of the function temporarily for testing purposes.



--
Sent from: http://forum.openscad.org/



OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Rob W
Lake Tyers Beach,
Victoria, Australia
Reply | Threaded
Open this post in threaded view
|

Re: inspecting fuctions

frankv
I first write the code as a module to debug it, then translate it into a function. e.g.



module Arc(centre, radius, angle1, angle2, step = 10, dir=false) {
    a1 = dir ? angle1 : angle2;
    a2 = dir ? angle2 : angle1;
       
    polygon([for (a = [a1 > a2 ? a1 - 360 : a1:step:a2]) [centre[0] + radius * cos(a), centre[1] + radius * sin(a)]]);
        }

function arc(centre, radius, angle1, angle2, dir = false, step = 10) =
    let(a1 = dir ? angle1 : angle2)
    let(a2 = dir ? angle2 : angle1)
    [for (a = [a1 > a2 ? a1 - 360: a1:step:a2]) [centre[0] + radius * cos(a), centre[1] + radius * sin(a)]];


On Mon, Feb 12, 2018 at 1:24 AM, Rob Ward <[hidden email]> wrote:
For those who are concerned about "libraries", could a Save option be included in OpenSCAD that has an "archive" feature that simply saves the target file and any referenced library, or subfile into a ZIP file(for example).
With gigabytes so cheap these days, this would not cost much??
No doubt over time, changes to the OpenSCAD IDEmight render any particular example 'broken' but at least anyone else coming along behind would have a complete snapshot of the original working design to begin with.
It would also make sharing OpenSCAD designs easier?
Cheers.
Rob
Cheers, RobW

On 11 February 2018 11:02:04 pm AEDT, Troberg <[hidden email]> wrote:
I break up the function into simpler parts and test them individually.
Sometimes, I do this through breaking it up into many smaller function, and
one function which puts it all together, sometimes I do it by commenting out
parts of the function temporarily for testing purposes.



--
Sent from: http://forum.openscad.org/



OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: inspecting fuctions

DanS
In reply to this post by tp3
Torsten

on the downloads (http://www.openscad.org/downloads.html) I see a 2018.01.06 build, and I installed that on top of what I had.  But it does not seem to have echo() for functions.

Where do I go to grab a nightly build?  The OS is 64 bit windows 7

Virus-free. www.avast.com

On Sat, Feb 10, 2018 at 4:53 PM, Torsten Paul <[hidden email]> wrote:
On 02/10/2018 09:39 PM, Dan Shriver wrote:
What do people do for debugging functions given that echo()
doesn't work inside them?

It is available for functions in the nightly builds.

For some info, see:
https://github.com/openscad/openscad/pull/1830

There's still some todo:
https://github.com/openscad/openscad/issues/1859

ciao,
  Torsten.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: inspecting fuctions

doug.moen
You need to go into Preferences >> Features and enable the "echo expression" feature.

On 11 February 2018 at 15:28, Dan Shriver <[hidden email]> wrote:
Torsten

on the downloads (http://www.openscad.org/downloads.html) I see a 2018.01.06 build, and I installed that on top of what I had.  But it does not seem to have echo() for functions.

Where do I go to grab a nightly build?  The OS is 64 bit windows 7

Virus-free. www.avast.com

On Sat, Feb 10, 2018 at 4:53 PM, Torsten Paul <[hidden email]> wrote:
On 02/10/2018 09:39 PM, Dan Shriver wrote:
What do people do for debugging functions given that echo()
doesn't work inside them?

It is available for functions in the nightly builds.

For some info, see:
https://github.com/openscad/openscad/pull/1830

There's still some todo:
https://github.com/openscad/openscad/issues/1859

ciao,
  Torsten.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
tp3
Reply | Threaded
Open this post in threaded view
|

Re: inspecting fuctions

tp3
In reply to this post by DanS
On 02/11/2018 09:28 PM, Dan Shriver wrote:
> on the downloads I see a 2018.01.06 build, and I installed
> that on top of what I had.  But it does not seem to have
> echo() for functions.
>
You may need to go into Preferences->Features to enable it.

ciao,
   Torsten.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
-- Torsten
Reply | Threaded
Open this post in threaded view
|

Re: inspecting fuctions

DanS
After enabling it works, thanks Doug / Torsten

Virus-free. www.avast.com

On Sun, Feb 11, 2018 at 3:36 PM, Torsten Paul <[hidden email]> wrote:
On 02/11/2018 09:28 PM, Dan Shriver wrote:
on the downloads I see a 2018.01.06 build, and I installed that on top of what I had.  But it does not seem to have
echo() for functions.

You may need to go into Preferences->Features to enable it.


ciao,
  Torsten.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: inspecting fuctions

NateTG
In reply to this post by tp3
tp3 wrote
> On 02/11/2018 09:28 PM, Dan Shriver wrote:
>> on the downloads I see a 2018.01.06 build, and I installed
>> that on top of what I had.  But it does not seem to have
>> echo() for functions.
>>
> You may need to go into Preferences->Features to enable it.
>
> ciao,
>    Torsten.

That's not showing for me on version 2018.01.22




--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org