Nabble has removed Mailing-list integration.
Posts created here DO NOT GET SENT TO THE MAILING LIST.
Mailing-list emails DO NOT GET POSTED TO THE FORUM.
So basically the Forum is now out of date, we are looking into migrating the history.

For now you should send emails, people will see them, discuss@lists.openscad.org.

Draft of the look and feel of a simple pythonic API for CSG

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

Draft of the look and feel of a simple pythonic API for CSG

Bryan Bishop
Hey Thomas,

A while ago, you and Jelle were talking about creating an API for
pythonOCC that would simplify and hide the ugly guts of OCC. I haven't
seen too much on this front in a while, but a few days ago I was
talking with Christian Siefkes, Ben Lipkowitz, and a few others about
a potential look and feel for python that would hide away OCC, or even
BRLCAD or anything else that we opt to throw under the hood.

I was wondering if I could get some thoughts on how this feels:

http://designfiles.org/~bryan/csg.py

sphere = Sphere(position=(0, 0, 0), radius="5 mm")
base = Circle(diameter="20 mm", position=(0,0,0))
cylinder = base.extrude(length="10 mm", direction=Vector(0, 0, 1))
sphere.position = (0, 0, 10)
lamp_post = cylinder.fuse(sphere)

#if you're in an X11 opengl session thingy:
display.add(lamp_post)

#or if you want to export it:
iges_data = lamp_post.to_iges()
file_handler = open("lamp_post.iges", "w")
file_handler.write(iges_data)
file_handler.close()

And maybe some parametric PAF stuff?

base = Circle("base of base plate", diameter="20 mm")
base_plate = Extrusion(base, "10mm", Vector(0,0,1))
#OR: base_plate = base.extrude("10 mm", Vector(0, 0, 1))
#OR: base_plate = extrude(base, "10 mm", Vector(0, 0, 1))
base_plate.name = "cylinder 1"

assert base_plate == Cylinder("cylinder 1", diameter="20 mm",
height="10 mm"), "Cylinder and base plate should be exactly the same"

base_plate.diameter = "25 mm"
assert base.diameter == "25 mm", "base diameter should have been updated"

base.diameter = "32 mm"
assert base_plate.diameter == "32 mm", "base plate diameter should
have been updated"

I am not entirely sure how to do this sort of feature tree. Any hints
or advice from interested bystanders would be hawt. Also, I am sending
this over to OpenSCAD because they have a similar thing going on, with
their own parser, but nevertheless would probably be interested in
python hooks and somehow influencing how those hooks feel & work.

Thanks,

- Bryan
http://heybryan.org/
1 512 203 0507

Reply | Threaded
Open this post in threaded view
|

Re: [Pythonocc-users] Draft of the look and feel of a simple pythonic API for CSG

Bryan Bishop
On Sun, Feb 21, 2010 at 1:49 PM, Jelle Feringa wrote:

> On Feb 21, 2010, at 8:28 PM, Bryan Bishop wrote:
>> Hey Thomas,
>>
>> A while ago, you and Jelle were talking about creating an API for
>> pythonOCC that would simplify and hide the ugly guts of OCC. I haven't
>> seen too much on this front in a while, but a few days ago I was
>> talking with Christian Siefkes, Ben Lipkowitz, and a few others about
>> a potential look and feel for python that would hide away OCC, or even
>> BRLCAD or anything else that we opt to throw under the hood.
>
> Not good.
> Those libs are _massively_ different, so no way.

Have you checked out libged from BRLCAD? There's CSG support going on,
believe it or not.

> When discussing the higher level API ( yes please ;'), please do so in reference to the work-in-progress: /src/addons/KBE/Level2API.py

Granted. Here's a link, then, since I can't seem to find it elsewhere
on the internets:

http://designfiles.org/lab/opencascade/Level2API.py

- Bryan
http://heybryan.org/
1 512 203 0507

Reply | Threaded
Open this post in threaded view
|

Re: [Pythonocc-users] Draft of the look and feel of a simple pythonic API for CSG

Bryan Bishop
In reply to this post by Bryan Bishop
On Sun, Feb 21, 2010 at 1:59 PM, Thomas Paviot <[hidden email]> wrote:
> Hi Bryan,

Hey Thomas. Thanks for the quick reply.

> *Very* intersting thread, thank you for opening it.

had to be done

> The topic you're talking about is still an open issue in CAD and
> contributions from the open source community would certainly be a great
> thing. However, it's not only a technical problem (in terms of
> implementation), but rather a scientific one. As far as I know, a good
> starting point is the second edition of the AP203 STEP application protocol,
> especially the ISO10303-55 (‘Procedural and hybrid representation’). Being
> able to implement this part of the standard in a scripting langage would
> already be a huge step.

Yes, absolutely. I do not have access to the ISO documentation on
STEP. Maybe you can send a few files my way to help me out? There is
one other resource that I am aware of- namely, the STEP export API in
the OpenCASCADE source code. From this, it is possible to extract the
valid entities that can be found in a STEP file in the EXPRESS
language. But then you have the issue of adopting OCC's peculiar
standard or peculiar implementation of STEP. Here's a skeleton of STEP
features that I figured out by looking at the OCC source:

http://designfiles.org/~bryan/step_importer.py

> I think this approach would certainly be the easiest way to get started: the
> STEP data model has been widely discussed and validated.

Right now what we need most are the ISO 10303 documents. Otherwise I
suspect nothing will happen. Whether or not this could be used to make
an API is also another issue- I suspect so, but maybe we should forge
ahead even if we can't get the ISO docs?

- Bryan
http://heybryan.org/
1 512 203 0507

Reply | Threaded
Open this post in threaded view
|

Fwd: [Pythonocc-users] Draft of the look and feel of a simple pythonic API for CSG

Bryan Bishop
---------- Forwarded message ----------
From: Thomas Paviot <[hidden email]>
Date: Sun, Feb 21, 2010 at 2:24 PM
Subject: Re: [Pythonocc-users] Draft of the look and feel of a simple
pythonic API for CSG
To: Bryan Bishop <[hidden email]>


2010/2/21 Bryan Bishop <[hidden email]>

>
> On Sun, Feb 21, 2010 at 1:59 PM, Thomas Paviot <[hidden email]> wrote:
> > Hi Bryan,
>
> Hey Thomas. Thanks for the quick reply.
>
> > *Very* intersting thread, thank you for opening it.
>
> had to be done
>
> > The topic you're talking about is still an open issue in CAD and
> > contributions from the open source community would certainly be a great
> > thing. However, it's not only a technical problem (in terms of
> > implementation), but rather a scientific one. As far as I know, a good
> > starting point is the second edition of the AP203 STEP application protocol,
> > especially the ISO10303-55 (‘Procedural and hybrid representation’). Being
> > able to implement this part of the standard in a scripting langage would
> > already be a huge step.
>
> Yes, absolutely. I do not have access to the ISO documentation on
> STEP. Maybe you can send a few files my way to help me out? There is
> one other resource that I am aware of- namely, the STEP export API in
> the OpenCASCADE source code. From this, it is possible to extract the
> valid entities that can be found in a STEP file in the EXPRESS
> language. But then you have the issue of adopting OCC's peculiar
> standard or peculiar implementation of STEP. Here's a skeleton of STEP
> features that I figured out by looking at the OCC source:
>
> http://designfiles.org/~bryan/step_importer.py
>
> > I think this approach would certainly be the easiest way to get started: the
> > STEP data model has been widely discussed and validated.
>
> Right now what we need most are the ISO 10303 documents. Otherwise I
> suspect nothing will happen. Whether or not this could be used to make
> an API is also another issue- I suspect so, but maybe we should forge
> ahead even if we can't get the ISO docs?
>
> - Bryan

Bryan,
You'll have to buy the CD in order to have documentation. However,
there's a webpage dedicated to AP203ed2 here:
http://www.steptools.com/support/stdev_docs/express/ap203e2/index.html
The EXPRESS data model file can be browsed at:
http://www.steptools.com/support/stdev_docs/express/ap203e2/html/index.html
I learnt most of the STEP standard by reading the EXPRESS files.
Thomas

>
> http://heybryan.org/
> 1 512 203 0507




--
- Bryan
http://heybryan.org/
1 512 203 0507