Maintaining and debugging scripts

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

Maintaining and debugging scripts

Peter O.

I’ve been working on a aerodynamics project for modelling alternative shapes for some weeks now using OpenSCAD. The shapes are dynamically generated upon a list of parameters, sometimes calculating several (sub)shapes depending on surrounding shapes.

 

Now that my code is going towards 1000+ lines I must restructure and refactor it. OpenSCAD uses a scripting language and I’m running into some problems that others might have experienced too but I cannot find much information about: Are there any tools that ease the development of (large) scripts?

 

What I’m really missing is:

 

A debugger and breakpoints

I’m now debugging using echo statements, which is in fact back to the 80’s. It seems to be impossible to stop the script at an arbitrary point. Not even a pause statement.

 

Code refactoring / renaming

Is a simple text search and replace that doesn’t know any context.

 

Warnings

For example constants that are defined but never used.

 

Any ideas?


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

Re: Maintaining and debugging scripts

OpenSCAD mailing list-2
How many separate modules do you have now?

I was able to break a project up into about 10 modules. Each one is under 80 lines and most are much smaller.

It is probably quite different but the final project consists of over 300 identifiable pieces, each one of which is generated using parameters.


If you can refactor it successfully, you should be able to test each module separately which helps a lot.

You may have to create some test scaffolding but these might be worthwhile in reducing the time to test and in reducing the complexity of debugging individual shapes or sub-assemblies.

I hope that these comments help.

Ron

On 2020-08-05 10:05 a.m., [hidden email] wrote:

I’ve been working on a aerodynamics project for modelling alternative shapes for some weeks now using OpenSCAD. The shapes are dynamically generated upon a list of parameters, sometimes calculating several (sub)shapes depending on surrounding shapes.

 

Now that my code is going towards 1000+ lines I must restructure and refactor it. OpenSCAD uses a scripting language and I’m running into some problems that others might have experienced too but I cannot find much information about: Are there any tools that ease the development of (large) scripts?

 

What I’m really missing is:

 

A debugger and breakpoints

I’m now debugging using echo statements, which is in fact back to the 80’s. It seems to be impossible to stop the script at an arbitrary point. Not even a pause statement.

 

Code refactoring / renaming

Is a simple text search and replace that doesn’t know any context.

 

Warnings

For example constants that are defined but never used.

 

Any ideas?


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

-- 
Ron Wheeler
Artifact Software
438-345-3369
[hidden email]

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

Re: Maintaining and debugging scripts

nophead
Using assert() instead of echo with stop on first warning is a bit like a breakpoint in that you will get a stack trace as well as any info you add to the assert message.

On Wed, 5 Aug 2020 at 16:26, Ron Wheeler via Discuss <[hidden email]> wrote:
How many separate modules do you have now?

I was able to break a project up into about 10 modules. Each one is under 80 lines and most are much smaller.

It is probably quite different but the final project consists of over 300 identifiable pieces, each one of which is generated using parameters.


If you can refactor it successfully, you should be able to test each module separately which helps a lot.

You may have to create some test scaffolding but these might be worthwhile in reducing the time to test and in reducing the complexity of debugging individual shapes or sub-assemblies.

I hope that these comments help.

Ron

On 2020-08-05 10:05 a.m., [hidden email] wrote:

I’ve been working on a aerodynamics project for modelling alternative shapes for some weeks now using OpenSCAD. The shapes are dynamically generated upon a list of parameters, sometimes calculating several (sub)shapes depending on surrounding shapes.

 

Now that my code is going towards 1000+ lines I must restructure and refactor it. OpenSCAD uses a scripting language and I’m running into some problems that others might have experienced too but I cannot find much information about: Are there any tools that ease the development of (large) scripts?

 

What I’m really missing is:

 

A debugger and breakpoints

I’m now debugging using echo statements, which is in fact back to the 80’s. It seems to be impossible to stop the script at an arbitrary point. Not even a pause statement.

 

Code refactoring / renaming

Is a simple text search and replace that doesn’t know any context.

 

Warnings

For example constants that are defined but never used.

 

Any ideas?


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

-- 
Ron Wheeler
Artifact Software
438-345-3369
[hidden email]
_______________________________________________
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: Maintaining and debugging scripts

Tim V. Shaporev
In reply to this post by Peter O.
For search and rename I use UNIX tools (e.g. MinGW for Windoze):
grep, sed, vi/vim

grep could also help to find all instances of the given name.

Just my $0.02
Tim

On 8/5/2020 5:05 PM, [hidden email] wrote:

> I’ve been working on a aerodynamics project for modelling alternative
> shapes for some weeks now using OpenSCAD. The shapes are dynamically
> generated upon a list of parameters, sometimes calculating several
> (sub)shapes depending on surrounding shapes.
>
> Now that my code is going towards 1000+ lines I must restructure and
> refactor it. OpenSCAD uses a scripting language and I’m running into
> some problems that others might have experienced too but I cannot find
> much information about: Are there any tools that ease the development of
> (large) scripts?
>
> What I’m really missing is:
>
> A debugger and breakpoints
>
> I’m now debugging using echo statements, which is in fact back to the
> 80’s. It seems to be impossible to stop the script at an arbitrary
> point. Not even a pause statement.
>
> Code refactoring / renaming
>
> Is a simple text search and replace that doesn’t know any context.
>
> Warnings
>
> For example constants that are defined but never used.
>
> Any ideas?
>
>
> _______________________________________________
> 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: Maintaining and debugging scripts

khackbarth
In reply to this post by Peter O.

I’d love that functionality – and be willing to pay for it.  I’ve already donated to OpenSCAD and I hope that others are doing the same.

 

Maybe the people who develop OpenSCAD will consider developing it.  I know that there are some complexities around order of statement execution that can make things very complex.

 

From: [hidden email] <[hidden email]>
Sent: Wednesday, August 5, 2020 8:06 AM
To: [hidden email]
Subject: [OpenSCAD] Maintaining and debugging scripts

 

I’ve been working on a aerodynamics project for modelling alternative shapes for some weeks now using OpenSCAD. The shapes are dynamically generated upon a list of parameters, sometimes calculating several (sub)shapes depending on surrounding shapes.

 

Now that my code is going towards 1000+ lines I must restructure and refactor it. OpenSCAD uses a scripting language and I’m running into some problems that others might have experienced too but I cannot find much information about: Are there any tools that ease the development of (large) scripts?

 

What I’m really missing is:

 

A debugger and breakpoints

I’m now debugging using echo statements, which is in fact back to the 80’s. It seems to be impossible to stop the script at an arbitrary point. Not even a pause statement.

 

Code refactoring / renaming

Is a simple text search and replace that doesn’t know any context.

 

Warnings

For example constants that are defined but never used.

 

Any ideas?


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

Re: Maintaining and debugging scripts

DonGar
This doesn't help with debugging, but you can get somewhat smarter editing using Visual Studio Code with the SCAD extension.


On Wed, Aug 5, 2020 at 10:25 AM <[hidden email]> wrote:

I’d love that functionality – and be willing to pay for it.  I’ve already donated to OpenSCAD and I hope that others are doing the same.

 

Maybe the people who develop OpenSCAD will consider developing it.  I know that there are some complexities around order of statement execution that can make things very complex.

 

From: [hidden email] <[hidden email]>
Sent: Wednesday, August 5, 2020 8:06 AM
To: [hidden email]
Subject: [OpenSCAD] Maintaining and debugging scripts

 

I’ve been working on a aerodynamics project for modelling alternative shapes for some weeks now using OpenSCAD. The shapes are dynamically generated upon a list of parameters, sometimes calculating several (sub)shapes depending on surrounding shapes.

 

Now that my code is going towards 1000+ lines I must restructure and refactor it. OpenSCAD uses a scripting language and I’m running into some problems that others might have experienced too but I cannot find much information about: Are there any tools that ease the development of (large) scripts?

 

What I’m really missing is:

 

A debugger and breakpoints

I’m now debugging using echo statements, which is in fact back to the 80’s. It seems to be impossible to stop the script at an arbitrary point. Not even a pause statement.

 

Code refactoring / renaming

Is a simple text search and replace that doesn’t know any context.

 

Warnings

For example constants that are defined but never used.

 

Any ideas?

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


--
Don

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

Re: Maintaining and debugging scripts

CasaDelGato
On Wed Aug 05 10:56:24 PDT 2020 [hidden email] said:

>This doesn't help with debugging, but you can get somewhat smarter editing
>using Visual Studio Code with the SCAD extension.
>
>On Wed, Aug 5, 2020 at 10:25 AM <[hidden email]> wrote:
>
>> I?d love that functionality ? and be willing to pay for it.  I?ve already
>> donated to OpenSCAD and I hope that others are doing the same.
>>
>> What I?m really missing is:
>>
>> Code refactoring / renaming
I keep hoping that somebody will make an SCAD plugin for Eclipse.


--

Bobcats and Cougars, oh my!  http://john.casadelgato.com/Pets
_______________________________________________
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: Maintaining and debugging scripts

tp3
On 05.08.20 20:34, John Lussmyer wrote:
> I keep hoping that somebody will make an SCAD plugin
> for Eclipse.

I'd prefer a Language Server implementation in OpenSCAD as
that would support any editor supporting this interface.

https://github.com/openscad/openscad/issues/2629

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: Maintaining and debugging scripts

thehans

Yeah suport for Language Server Protocol would be really nice.
I think this could go a long way in terms of helping with refactoring in other IDEs etc, but would also be quite a large project in itself.

One other small trick I sometimes use (mostly to "prettify" other's scripts) is the "Design" -> "Display AST..." menu item, which displays the code formmatted with consistent indentation, and can be copy-pasted back into the source file.  It still has some limitations with includes and uses, and will re-order assignments, functions, and module definitions... but it can be nice if original indentation is all over the place.

On Wed, Aug 5, 2020 at 1:44 PM Torsten Paul <[hidden email]> wrote:
On 05.08.20 20:34, John Lussmyer wrote:
> I keep hoping that somebody will make an SCAD plugin
> for Eclipse.

I'd prefer a Language Server implementation in OpenSCAD as
that would support any editor supporting this interface.

https://github.com/openscad/openscad/issues/2629

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: Maintaining and debugging scripts

OpenSCAD mailing list-2
In reply to this post by CasaDelGato
What would you like in the editor that the OpenSCAD editor lacks?

- Outline view?
- Snippets?
- Projects


On 2020-08-05 2:34 p.m., John Lussmyer wrote:
On Wed Aug 05 10:56:24 PDT 2020 [hidden email] said:
This doesn't help with debugging, but you can get somewhat smarter editing
using Visual Studio Code with the SCAD extension.

On Wed, Aug 5, 2020 at 10:25 AM [hidden email] wrote:

I?d love that functionality ? and be willing to pay for it.  I?ve already
donated to OpenSCAD and I hope that others are doing the same.

What I?m really missing is:

Code refactoring / renaming
I keep hoping that somebody will make an SCAD plugin for Eclipse.


--

Bobcats and Cougars, oh my!  http://john.casadelgato.com/Pets

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

-- 
Ron Wheeler
Artifact Software
438-345-3369
[hidden email]

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

Re: Maintaining and debugging scripts

OpenSCAD mailing list-2
The thing which I'd really like is an optional Block view like BlockSCAD:

https://www.blockscad3d.com/

William


-----Original Message-----
From: Ron Wheeler via Discuss <[hidden email]>
To: [hidden email]
Cc: Ron Wheeler <[hidden email]>
Sent: Wed, Aug 5, 2020 9:29 pm
Subject: Re: [OpenSCAD] Maintaining and debugging scripts

What would you like in the editor that the OpenSCAD editor lacks?

- Outline view?
- Snippets?
- Projects


On 2020-08-05 2:34 p.m., John Lussmyer wrote:
On Wed Aug 05 10:56:24 PDT 2020 [hidden email] said:
This doesn't help with debugging, but you can get somewhat smarter editing
using Visual Studio Code with the SCAD extension.

On Wed, Aug 5, 2020 at 10:25 AM [hidden email] wrote:

I?d love that functionality ? and be willing to pay for it.  I?ve already
donated to OpenSCAD and I hope that others are doing the same.

What I?m really missing is:

Code refactoring / renaming
I keep hoping that somebody will make an SCAD plugin for Eclipse.


--

Bobcats and Cougars, oh my!  http://john.casadelgato.com/Pets

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

-- 
Ron Wheeler
Artifact Software
438-345-3369
[hidden email]
_______________________________________________
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: Maintaining and debugging scripts

CasaDelGato
In reply to this post by OpenSCAD mailing list-2
On Wed Aug 05 18:29:40 PDT 2020 [hidden email] said:
>What would you like in the editor that the OpenSCAD editor lacks?
>
>- Outline view?
>- Snippets?
>- Projects

Syntax checking
auto code formatting
code-completion



--

Bobcats and Cougars, oh my!  http://john.casadelgato.com/Pets
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Maintaining and debugging scripts

jon_bondy
If you do this, please allow it to be turned off as an option

On 8/5/2020 10:08 PM, John Lussmyer wrote:

> On Wed Aug 05 18:29:40 PDT 2020 [hidden email] said:
>> What would you like in the editor that the OpenSCAD editor lacks?
>>
>> - Outline view?
>> - Snippets?
>> - Projects
> Syntax checking
> auto code formatting
> code-completion
>

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

Re: Maintaining and debugging scripts

Peter O.
In reply to this post by OpenSCAD mailing list-2

I have 20 modules and I can identify about 7 sections in my code that can be broken up in different files:

  • Parameters.scad (contains all external parameters)
  • Intermediate_results.scad (contains all intermediate constants to size, rotate and translate the objects)
  • Modules.scad (Contains all modules. Might be split up into more files)
  • Drawing.scad (contains the actual drawing statements)
  • Debug_statements.scad (A big one. Contains all debug echo’s)
  • Export.scad (contains all echo stuff to export results to the outside world)
  • Visualization_options.scad (contains Booleans which parts are drawn and which not)

 

The project calculates the size and position of all individual pieces and there might be several thousands of them.

 

From: Discuss <[hidden email]> On Behalf Of Ron Wheeler via Discuss
Sent: Wednesday, August 5, 2020 17:26
To: [hidden email]
Cc: Ron Wheeler <[hidden email]>
Subject: Re: [OpenSCAD] Maintaining and debugging scripts

 

How many separate modules do you have now?

I was able to break a project up into about 10 modules. Each one is under 80 lines and most are much smaller.

It is probably quite different but the final project consists of over 300 identifiable pieces, each one of which is generated using parameters.


If you can refactor it successfully, you should be able to test each module separately which helps a lot.

You may have to create some test scaffolding but these might be worthwhile in reducing the time to test and in reducing the complexity of debugging individual shapes or sub-assemblies.

I hope that these comments help.

Ron

On 2020-08-05 10:05 a.m., [hidden email] wrote:

I’ve been working on a aerodynamics project for modelling alternative shapes for some weeks now using OpenSCAD. The shapes are dynamically generated upon a list of parameters, sometimes calculating several (sub)shapes depending on surrounding shapes.

 

Now that my code is going towards 1000+ lines I must restructure and refactor it. OpenSCAD uses a scripting language and I’m running into some problems that others might have experienced too but I cannot find much information about: Are there any tools that ease the development of (large) scripts?

 

What I’m really missing is:

 

A debugger and breakpoints

I’m now debugging using echo statements, which is in fact back to the 80’s. It seems to be impossible to stop the script at an arbitrary point. Not even a pause statement.

 

Code refactoring / renaming

Is a simple text search and replace that doesn’t know any context.

 

Warnings

For example constants that are defined but never used.

 

Any ideas?



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



-- 
Ron Wheeler
Artifact Software
438-345-3369
[hidden email]

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

Re: Maintaining and debugging scripts

Peter O.
In reply to this post by nophead

Thanks! I will try that.

 

From: Discuss <[hidden email]> On Behalf Of nop head
Sent: Wednesday, August 5, 2020 18:03
To: OpenSCAD general discussion <[hidden email]>
Subject: Re: [OpenSCAD] Maintaining and debugging scripts

 

Using assert() instead of echo with stop on first warning is a bit like a breakpoint in that you will get a stack trace as well as any info you add to the assert message.

 

On Wed, 5 Aug 2020 at 16:26, Ron Wheeler via Discuss <[hidden email]> wrote:

How many separate modules do you have now?

I was able to break a project up into about 10 modules. Each one is under 80 lines and most are much smaller.

It is probably quite different but the final project consists of over 300 identifiable pieces, each one of which is generated using parameters.


If you can refactor it successfully, you should be able to test each module separately which helps a lot.

You may have to create some test scaffolding but these might be worthwhile in reducing the time to test and in reducing the complexity of debugging individual shapes or sub-assemblies.

I hope that these comments help.

Ron

On 2020-08-05 10:05 a.m., [hidden email] wrote:

I’ve been working on a aerodynamics project for modelling alternative shapes for some weeks now using OpenSCAD. The shapes are dynamically generated upon a list of parameters, sometimes calculating several (sub)shapes depending on surrounding shapes.

 

Now that my code is going towards 1000+ lines I must restructure and refactor it. OpenSCAD uses a scripting language and I’m running into some problems that others might have experienced too but I cannot find much information about: Are there any tools that ease the development of (large) scripts?

 

What I’m really missing is:

 

A debugger and breakpoints

I’m now debugging using echo statements, which is in fact back to the 80’s. It seems to be impossible to stop the script at an arbitrary point. Not even a pause statement.

 

Code refactoring / renaming

Is a simple text search and replace that doesn’t know any context.

 

Warnings

For example constants that are defined but never used.

 

Any ideas?

 

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



-- 
Ron Wheeler
Artifact Software
438-345-3369
[hidden email]

_______________________________________________
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: Maintaining and debugging scripts

Peter O.
In reply to this post by Tim V. Shaporev
Notepad++ has comparable options.
OpenSCAD's search & replace should be used with care as it doesn't have
options like case sensitivity and whole words only.
In the beginning I messed up my code regularly using the replace option.

Peter

-----Original Message-----
From: Discuss <[hidden email]> On Behalf Of Tim V.
Shaporev
Sent: Wednesday, August 5, 2020 19:00
To: [hidden email]
Subject: Re: [OpenSCAD] Maintaining and debugging scripts

For search and rename I use UNIX tools (e.g. MinGW for Windoze):
grep, sed, vi/vim

grep could also help to find all instances of the given name.

Just my $0.02
Tim

On 8/5/2020 5:05 PM, [hidden email] wrote:

> I've been working on a aerodynamics project for modelling alternative
> shapes for some weeks now using OpenSCAD. The shapes are dynamically
> generated upon a list of parameters, sometimes calculating several
> (sub)shapes depending on surrounding shapes.
>
> Now that my code is going towards 1000+ lines I must restructure and
> refactor it. OpenSCAD uses a scripting language and I'm running into
> some problems that others might have experienced too but I cannot find
> much information about: Are there any tools that ease the development
> of
> (large) scripts?
>
> What I'm really missing is:
>
> A debugger and breakpoints
>
> I'm now debugging using echo statements, which is in fact back to the
> 80's. It seems to be impossible to stop the script at an arbitrary
> point. Not even a pause statement.
>
> Code refactoring / renaming
>
> Is a simple text search and replace that doesn't know any context.
>
> Warnings
>
> For example constants that are defined but never used.
>
> Any ideas?
>
>
> _______________________________________________
> 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: Maintaining and debugging scripts

OpenSCAD mailing list-2
In reply to this post by Peter O.
Looks like you have a very well thought out plan.

It sounds like you are right about breaking up Modules.scad. That should make it easier to test.

Ron

On 2020-08-06 7:41 a.m., [hidden email] wrote:

I have 20 modules and I can identify about 7 sections in my code that can be broken up in different files:

  • Parameters.scad (contains all external parameters)
  • Intermediate_results.scad (contains all intermediate constants to size, rotate and translate the objects)
  • Modules.scad (Contains all modules. Might be split up into more files)
  • Drawing.scad (contains the actual drawing statements)
  • Debug_statements.scad (A big one. Contains all debug echo’s)
  • Export.scad (contains all echo stuff to export results to the outside world)
  • Visualization_options.scad (contains Booleans which parts are drawn and which not)

 

The project calculates the size and position of all individual pieces and there might be several thousands of them.

 

From: Discuss [hidden email] On Behalf Of Ron Wheeler via Discuss
Sent: Wednesday, August 5, 2020 17:26
To: [hidden email]
Cc: Ron Wheeler [hidden email]
Subject: Re: [OpenSCAD] Maintaining and debugging scripts

 

How many separate modules do you have now?

I was able to break a project up into about 10 modules. Each one is under 80 lines and most are much smaller.

It is probably quite different but the final project consists of over 300 identifiable pieces, each one of which is generated using parameters.


If you can refactor it successfully, you should be able to test each module separately which helps a lot.

You may have to create some test scaffolding but these might be worthwhile in reducing the time to test and in reducing the complexity of debugging individual shapes or sub-assemblies.

I hope that these comments help.

Ron

On 2020-08-05 10:05 a.m., [hidden email] wrote:

I’ve been working on a aerodynamics project for modelling alternative shapes for some weeks now using OpenSCAD. The shapes are dynamically generated upon a list of parameters, sometimes calculating several (sub)shapes depending on surrounding shapes.

 

Now that my code is going towards 1000+ lines I must restructure and refactor it. OpenSCAD uses a scripting language and I’m running into some problems that others might have experienced too but I cannot find much information about: Are there any tools that ease the development of (large) scripts?

 

What I’m really missing is:

 

A debugger and breakpoints

I’m now debugging using echo statements, which is in fact back to the 80’s. It seems to be impossible to stop the script at an arbitrary point. Not even a pause statement.

 

Code refactoring / renaming

Is a simple text search and replace that doesn’t know any context.

 

Warnings

For example constants that are defined but never used.

 

Any ideas?



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



-- 
Ron Wheeler
Artifact Software
438-345-3369
[hidden email]

-- 
Ron Wheeler
Artifact Software
438-345-3369
[hidden email]

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

Re: Maintaining and debugging scripts

onealexharms
In reply to this post by DonGar
My workflow has been to open up the file(s) in my editor of choice, and have only the preview window and the console open from openscad. Simply never  using the openscad editor has been much nicer. I found some openscad syntax highlighting for vim, so I’m set there.

Lately I’ve been developing some scripts to use the command line interface, and the terminal program I’m using can display graphics (kitty) so I’m not interacting with the GUI at all anymore, which is even better. 

The script is bash, and it’s in github, under the name openscad-cli. Note, the readme is outdated because it’s baby and I haven’t made it a thing yet. I’m only telling y’all in case it helps somebody with their projects. 

(I really love openscad, and I’m glad the GUI exists. I’d never have gotten started otherwise.)

Note: If anything I said seems like gibberish and you’d like to know more, please ask. I’m happy to share more. 

On Aug 5, 2020, at 13:57, Don Garrett <[hidden email]> wrote:


This doesn't help with debugging, but you can get somewhat smarter editing using Visual Studio Code with the SCAD extension.


On Wed, Aug 5, 2020 at 10:25 AM <[hidden email]> wrote:

I’d love that functionality – and be willing to pay for it.  I’ve already donated to OpenSCAD and I hope that others are doing the same.

 

Maybe the people who develop OpenSCAD will consider developing it.  I know that there are some complexities around order of statement execution that can make things very complex.

 

From: [hidden email] <[hidden email]>
Sent: Wednesday, August 5, 2020 8:06 AM
To: [hidden email]
Subject: [OpenSCAD] Maintaining and debugging scripts

 

I’ve been working on a aerodynamics project for modelling alternative shapes for some weeks now using OpenSCAD. The shapes are dynamically generated upon a list of parameters, sometimes calculating several (sub)shapes depending on surrounding shapes.

 

Now that my code is going towards 1000+ lines I must restructure and refactor it. OpenSCAD uses a scripting language and I’m running into some problems that others might have experienced too but I cannot find much information about: Are there any tools that ease the development of (large) scripts?

 

What I’m really missing is:

 

A debugger and breakpoints

I’m now debugging using echo statements, which is in fact back to the 80’s. It seems to be impossible to stop the script at an arbitrary point. Not even a pause statement.

 

Code refactoring / renaming

Is a simple text search and replace that doesn’t know any context.

 

Warnings

For example constants that are defined but never used.

 

Any ideas?

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


--
Don
_______________________________________________
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