discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: python support for openscad

SP
Sanjeev Prabhakar
Sun, Jul 23, 2023 4:07 PM

In the past I have shared few examples which probably are very difficult to
do in pure openscad.

Python is a very convenient, easy to learn and use language as per me.

Is probably not more than 2 years that I started learning python. I
wouldn't call myself proficient in the language but at the least I could
make few very complicated models through this.

In the past I have shared few examples which probably are very difficult to do in pure openscad. Python is a very convenient, easy to learn and use language as per me. Is probably not more than 2 years that I started learning python. I wouldn't call myself proficient in the language but at the least I could make few very complicated models through this.
SP
Sanjeev Prabhakar
Sun, Jul 23, 2023 4:34 PM

example attached where a fillet is created:
calculations for this are done in python.
[image: Screenshot 2023-07-22 at 9.41.49 PM.png]

On Sun, 23 Jul 2023 at 21:37, Sanjeev Prabhakar sprabhakar2006@gmail.com
wrote:

In the past I have shared few examples which probably are very difficult
to do in pure openscad.

Python is a very convenient, easy to learn and use language as per me.

Is probably not more than 2 years that I started learning python. I
wouldn't call myself proficient in the language but at the least I could
make few very complicated models through this.

example attached where a fillet is created: calculations for this are done in python. [image: Screenshot 2023-07-22 at 9.41.49 PM.png] On Sun, 23 Jul 2023 at 21:37, Sanjeev Prabhakar <sprabhakar2006@gmail.com> wrote: > In the past I have shared few examples which probably are very difficult > to do in pure openscad. > > Python is a very convenient, easy to learn and use language as per me. > > Is probably not more than 2 years that I started learning python. I > wouldn't call myself proficient in the language but at the least I could > make few very complicated models through this. > > > >
TP
Torsten Paul
Sun, Jul 23, 2023 4:45 PM

On 23.07.23 18:34, Sanjeev Prabhakar wrote:

example attached where a fillet is created:
calculations for this are done in python.

That is great stuff, but in my view it would belong into the geometry
engine.

Maybe you can help with the calculation side of that?

ciao,
Torsten.

On 23.07.23 18:34, Sanjeev Prabhakar wrote: > example attached where a fillet is created: > calculations for this are done in python. That is great stuff, but in my view it would belong into the geometry engine. Maybe you can help with the calculation side of that? ciao, Torsten.
RW
Rogier Wolff
Sun, Jul 23, 2023 4:59 PM

On Sun, Jul 23, 2023 at 09:37:10PM +0530, Sanjeev Prabhakar wrote:

In the past I have shared few examples which probably are very difficult to
do in pure openscad.

Python is a very convenient, easy to learn and use language as per me.

Is probably not more than 2 years that I started learning python. I
wouldn't call myself proficient in the language but at the least I
could make few very complicated models through this.

I agree that a procedural language addition to openscad would be very
useful. Some things are much easier to express procedurally than the
way openscad would like you to formulate things.

For example building up an array element by element is awkward in
openscad, while "natural" in a procedural language.

It took me a long time to figure out why a module using a global
variable wouldn't instantiate in two different ways when I changed the
global variable between calls. (back then openscad didn't have the
warning that is generated nowadays).

I agree with the openscad folks that it is an advantage that an
openscad script is just "data": It cannot affect your computer beyond
bogging it down for a while while trying to render it. Just like a
"word processor documuent" should be.

How about allowing the python extension to be activated by a
commandline argument but also by using a different binary name.

pyopenscad, popenscad or maybe openpyscad. (That last one... might not
be such a good idea... ). And a different extension.

For those that are paranoid (and those that don't have python at
compile-time) it should remain possible to compile without python
support.

I'm hoping such a construction would satisfy both ends of this
discussion.

Roger.

--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
f equals m times a. When your f is steady, and your m is going down
your a is going up.  -- Chris Hadfield about flying up the space shuttle.

On Sun, Jul 23, 2023 at 09:37:10PM +0530, Sanjeev Prabhakar wrote: > In the past I have shared few examples which probably are very difficult to > do in pure openscad. > > Python is a very convenient, easy to learn and use language as per me. > Is probably not more than 2 years that I started learning python. I > wouldn't call myself proficient in the language but at the least I > could make few very complicated models through this. I agree that a procedural language addition to openscad would be very useful. Some things are much easier to express procedurally than the way openscad would like you to formulate things. For example building up an array element by element is awkward in openscad, while "natural" in a procedural language. It took me a long time to figure out why a module using a global variable wouldn't instantiate in two different ways when I changed the global variable between calls. (back then openscad didn't have the warning that is generated nowadays). I agree with the openscad folks that it is an advantage that an openscad script is just "data": It cannot affect your computer beyond bogging it down for a while while trying to render it. Just like a "word processor documuent" should be. How about allowing the python extension to be activated by a commandline argument but also by using a different binary name. pyopenscad, popenscad or maybe openpyscad. (That last one... might not be such a good idea... ). And a different extension. For those that are paranoid (and those that don't have python at compile-time) it should remain possible to compile without python support. I'm hoping such a construction would satisfy both ends of this discussion. Roger. -- ** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 ** ** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 ** f equals m times a. When your f is steady, and your m is going down your a is going up. -- Chris Hadfield about flying up the space shuttle.
SP
Sanjeev Prabhakar
Sun, Jul 23, 2023 4:59 PM

Thanks

It's a little complicated to explain,  but the main thing is calculating
the intersection line between 2 solids.

Once you get the intersection line,  then it's not so difficult to create
any fillet.

On Sun, 23 Jul 2023, 22:16 Torsten Paul, Torsten.Paul@gmx.de wrote:

On 23.07.23 18:34, Sanjeev Prabhakar wrote:

example attached where a fillet is created:
calculations for this are done in python.

That is great stuff, but in my view it would belong into the geometry
engine.

Maybe you can help with the calculation side of that?

ciao,
Torsten.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Thanks It's a little complicated to explain, but the main thing is calculating the intersection line between 2 solids. Once you get the intersection line, then it's not so difficult to create any fillet. On Sun, 23 Jul 2023, 22:16 Torsten Paul, <Torsten.Paul@gmx.de> wrote: > On 23.07.23 18:34, Sanjeev Prabhakar wrote: > > example attached where a fillet is created: > > calculations for this are done in python. > > That is great stuff, but in my view it would belong into the geometry > engine. > > Maybe you can help with the calculation side of that? > > ciao, > Torsten. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
RW
Rogier Wolff
Sun, Jul 23, 2023 5:03 PM

On Sun, Jul 23, 2023 at 06:45:41PM +0200, Torsten Paul wrote:

On 23.07.23 18:34, Sanjeev Prabhakar wrote:

example attached where a fillet is created:
calculations for this are done in python.

That is great stuff, but in my view it would belong into the geometry
engine.

Maybe you can help with the calculation side of that?

This specific case of "a fillet" is something that might be welcome in
openscad. But that is not the point that Sanjeev is trying to make.

There are manythings that are relatively easy to do in
python-enhanced-openscad, that are hard to do in vanilla openscad. Not
just fillets. His example might make sense to "Oh, but we want that to
be possible in plain openscad". You can't keep saying that for
everything that anybody can come up with.

Roger. 

--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
f equals m times a. When your f is steady, and your m is going down
your a is going up.  -- Chris Hadfield about flying up the space shuttle.

On Sun, Jul 23, 2023 at 06:45:41PM +0200, Torsten Paul wrote: > On 23.07.23 18:34, Sanjeev Prabhakar wrote: > > example attached where a fillet is created: > > calculations for this are done in python. > > That is great stuff, but in my view it would belong into the geometry > engine. > > Maybe you can help with the calculation side of that? This specific case of "a fillet" is something that might be welcome in openscad. But that is not the point that Sanjeev is trying to make. There are manythings that are relatively easy to do in python-enhanced-openscad, that are hard to do in vanilla openscad. Not just fillets. His example might make sense to "Oh, but we want that to be possible in plain openscad". You can't keep saying that for everything that anybody can come up with. Roger. -- ** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 ** ** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 ** f equals m times a. When your f is steady, and your m is going down your a is going up. -- Chris Hadfield about flying up the space shuttle.
TP
Torsten Paul
Sun, Jul 23, 2023 5:04 PM

On 23.07.23 18:59, Sanjeev Prabhakar wrote:

Once you get the intersection line,  then it's not so difficult to create any fillet.

I have not looked at the details, but my understanding from some discussion
in the Manifold repository is there are IDs in the CSG output that detail to
which part the new faces belong. From that it should be possible to get the
information which vertices are that intersection line.

Maybe we can try some demo code separate from OpenSCAD to see if we can get
your algorithm into Manifold based C++ code.

ciao,
Torsten.

On 23.07.23 18:59, Sanjeev Prabhakar wrote: > Once you get the intersection line,  then it's not so difficult to create any fillet. I have not looked at the details, but my understanding from some discussion in the Manifold repository is there are IDs in the CSG output that detail to which part the new faces belong. From that it should be possible to get the information which vertices are that intersection line. Maybe we can try some demo code separate from OpenSCAD to see if we can get your algorithm into Manifold based C++ code. ciao, Torsten.
RW
Rogier Wolff
Sun, Jul 23, 2023 5:10 PM

On Sun, Jul 23, 2023 at 10:29:34PM +0530, Sanjeev Prabhakar wrote:

Thanks

It's a little complicated to explain,  but the main thing is calculating
the intersection line between 2 solids.

Once you get the intersection line,  then it's not so difficult to create
any fillet.

I'm guessing that it can become complicated.
Try this:

fillet_radius = 3;
dist = 10;
size = 10;

fillet (radius= fillet_radius) {
cube ([size2+dist, size, size]);
cube ([size, size, 2
size]);
translate ([size+dist, 0,0]) cube ([size, size, 2*size]);
}

Easy. But what if dist is reduced to below 2*fillet_radius ? You can
intersect the radii but then you'll get a sharp inside corner that the
fillet is supposed to be preventing.

And what if dist is reducted to below 1*fillet_radius ? Does the space
between the objects fill completely with fillet?

In the general case, this is quite hard.

Roger. 

--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
f equals m times a. When your f is steady, and your m is going down
your a is going up.  -- Chris Hadfield about flying up the space shuttle.

On Sun, Jul 23, 2023 at 10:29:34PM +0530, Sanjeev Prabhakar wrote: > Thanks > > It's a little complicated to explain, but the main thing is calculating > the intersection line between 2 solids. > > Once you get the intersection line, then it's not so difficult to create > any fillet. I'm guessing that it can become complicated. Try this: fillet_radius = 3; dist = 10; size = 10; fillet (radius= fillet_radius) { cube ([size*2+dist, size, size]); cube ([size, size, 2*size]); translate ([size+dist, 0,0]) cube ([size, size, 2*size]); } Easy. But what if dist is reduced to below 2*fillet_radius ? You can intersect the radii but then you'll get a sharp inside corner that the fillet is supposed to be preventing. And what if dist is reducted to below 1*fillet_radius ? Does the space between the objects fill completely with fillet? In the general case, this is quite hard. Roger. -- ** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 ** ** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 ** f equals m times a. When your f is steady, and your m is going down your a is going up. -- Chris Hadfield about flying up the space shuttle.
TP
Torsten Paul
Sun, Jul 23, 2023 5:11 PM

On 23.07.23 18:59, Rogier Wolff wrote:

I'm hoping such a construction would satisfy both ends of this
discussion.

The related logic is already merged into OpenSCAD master and the
PR adding the actual Python interface is accepted in spirit, just
pending some detailed code review. So it's only a matter of finding
the time, no general open discussion.

https://github.com/openscad/openscad/pull/4702

Getting builds to enable this feature is going to be a challenge,
as I mentioned before, but we'll have to see if we can get some
help with that.

ciao,
Torsten.

On 23.07.23 18:59, Rogier Wolff wrote: > I'm hoping such a construction would satisfy both ends of this > discussion. The related logic is already merged into OpenSCAD master and the PR adding the actual Python interface is accepted in spirit, just pending some detailed code review. So it's only a matter of finding the time, no general open discussion. https://github.com/openscad/openscad/pull/4702 Getting builds to enable this feature is going to be a challenge, as I mentioned before, but we'll have to see if we can get some help with that. ciao, Torsten.
SP
Sanjeev Prabhakar
Sun, Jul 23, 2023 5:13 PM

Sure
I will try to explain the logic maybe in a day or two for the benefit of
all who maybe interested in geometry manipulations.

Sure I will try to explain the logic maybe in a day or two for the benefit of all who maybe interested in geometry manipulations.