Re: Pointers on writing an OpenSCAD extension

26 lượt xem
Chuyển tới thư đầu tiên chưa đọc

Bryan Bishop

chưa đọc,
20:06:17 10 thg 2, 201010/2/10
đến Vitaly Mankevich, Open Manufacturing, open...@rocklinux.org, kan...@gmail.com
On Wed, Feb 10, 2010 at 7:03 PM, Vitaly Mankevich <alban...@gmail.com> wrote:
> I've downloaded and played with OpenSCAD examples and I liked the
> simplicity and elegance of coding in geometry. I haven't seen the
> source so I don't know where to look for integrating this with
> pythonOCC.

Okay, thanks. I'll dig around a little bit, ask around.

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

Bryan Bishop

chưa đọc,
20:50:40 10 thg 2, 201010/2/10
đến Marius Kintel, kan...@gmail.com, open...@rocklinux.org, Vitaly Mankevich, Open Manufacturing
On Wed, Feb 10, 2010 at 7:48 PM, Marius Kintel wrote:
> On Feb 11, 2010, at 02:06 , Bryan Bishop wrote:

>> On Wed, Feb 10, 2010 at 7:03 PM, Vitaly Mankevich wrote:
>>> I've downloaded and played with OpenSCAD examples and I liked the
>>> simplicity and elegance of coding in geometry. I haven't seen the
>>> source so I don't know where to look for integrating this with
>>> pythonOCC.
>>
>> Okay, thanks. I'll dig around a little bit, ask around.
>
> From earlier mailing list discussions, I get the impression that pythonOCC
> is a superset of OpenSCAD, where OpenSCAD is lighter on the programming
> skills than pythonOCC.
> If this is not the case, I'd be very interested in an evaluation of what the
> differences between OpenSCAD and pythonOCC really are. Since OCC is a
> full-fledged CAD kernel, I guess that boils down to an evaluation of where
> using OpenSCAD could be an advantage.

Not quite what's going on here. Think of it more as pythonOCC as
bindings for python to OpenCASCADE (the kernel). Then, I'm considering
integrating OpenSCAD with pythonOCC so that it can spit out
information from the SCAD format to the internal OCC format so that it
can eventually be exported to STEP, IGES, brep, etc.

Bryan Bishop

chưa đọc,
21:15:05 10 thg 2, 201010/2/10
đến Marius Kintel, kan...@gmail.com, open...@rocklinux.org, Vitaly Mankevich, Open Manufacturing
On Wed, Feb 10, 2010 at 8:09 PM, Marius Kintel wrote:

> On Feb 11, 2010, at 02:50 , Bryan Bishop wrote:
>> Not quite what's going on here. Think of it more as pythonOCC as
>> bindings for python to OpenCASCADE (the kernel). Then, I'm considering
>> integrating OpenSCAD with pythonOCC so that it can spit out
>> information from the SCAD format to the internal OCC format so that it
>> can eventually be exported to STEP, IGES, brep, etc.
>>
>
> I see. In that case, and since OpenCascade is a C++ library, I would guess
> it's easier to hook up an OpenCascade exporter into OpenSCAD using the
> normal C++ API.

The documentation is absolutely terrible, that's why I was figuring a
prototype in python would be easier. But either way.

> As long as OpenCascade allows for building CSG trees out of polygonal
> manifold meshes, the worst case would be hooking up to the mesh class
> (PolySet) in OpenSCAD and use these as leaf nodes in the CSG tree. It's

I don't think we should use the meshes. Let's instead just look at the
actual objects (circles, spheres, etc.) and conver those to the same
objects used in OCC (i.e.,
OCC.BRepBuilderAPI.BRepBuilderAPI_MakeSphere).

> always possible to dig deeper and get access to true primitives, given that
> operations like extrusions are allowed on such (2D) primitives in
> OpenCascade.
>
> Until the inner workings of OpenSCAD is a bit cleaner, this would involve
> some hacking, but I'd be happy to support such an endaevor at the OpenSCAD
> end of things.
>
> As I mentioned earlier, I don't know anything about OpenCascade, so I would
> be more comfortable about this if someone did a proof-of-concept by
> remodeling some representative OpenSCAD examples using OpenCascade data
> structures.

Just point me where in the SCAD source code.

Leo Dearden

chưa đọc,
13:52:32 11 thg 2, 201011/2/10
đến open...@rocklinux.org, Bryan Bishop, Open Manufacturing


On 11 February 2010 12:04, Marius Kintel <mar...@kintel.net> wrote:
On Feb 11, 2010, at 03:15 , Bryan Bishop wrote:

> I don't think we should use the meshes. Let's instead just look at the
> actual objects (circles, spheres, etc.) and conver those to the same
> objects used in OCC (i.e.,
> OCC.BRepBuilderAPI.BRepBuilderAPI_MakeSphere).
>
I agree - I just don't know the capabilities of OpenCascade in this
respect.


> Just point me where in the SCAD source code.
>

What I would look at first is to write code for converting from
OpenSCAD Node tree to the equivalent/mappable concept in OpenCascade.
 
...this is the
evaluated node tree, meaning that all variables and control constructs
are already resolved, while the primitives are not converted to
meshes...
 
Alternatively, you could dig one step deeper and hook up to after the
parser (parse() global function). This will set
MainWindow::root_module, which is the root node of the (unevaluated)
module tree (includes module definitions and module instantiations).
This is more work as you need to rewrite the resolving logic (look at
the context handling).

Whichever level you work at, doing this with FreeCAD instead of OpenCASCADE is probably a good idea. FreeCAD is built on OpenCASCADE and it provides a much more complete design environment. You could interface at the C++ level, but the original suggestions of Python might be better. There is already a clean pythonOCC based interface for building geometry, and using it would make OpenSCAD plug in as another workbench, in parallel with conventional part design, or 2D drafting, or whatever. This would open up workflows that use geometry code for some parts of the the design and conventional CAD for others. 

I'm going to do some work on FreeCAD over the next couple of months and I'd be happy to share what I learn if you're interested.

Cheers,

Leo
Trả lời tất cả
Trả lời tác giả
Chuyển tiếp
0 tin nhắn mới