dcowden / cadquery

CadQuery-- a parametric cad script framework
Other
432 stars 56 forks source link

Design Direct API #167

Closed dcowden closed 5 years ago

dcowden commented 7 years ago

CQ 2.0 should have a direct api in addition to a fluent api, for more programmatic use.

fragmuffin commented 7 years ago

To further the discussion on operations, with regard to #195

All thread operations would take parameters:

These inputs would be abstracted via named standards (eg: M6)

Useful thread operations would be:

Also, things to consider:

adam-urbanczyk commented 7 years ago

I would expect

s3.faces(op_id='hole')

to give all faces of the object that resulted from the cut operation

Perhaps more importantly,I would expect these two to return the same thing

s3.faces() ctx.find(op_id='hole').faces()

@dcowden Here is an deliberately more complex example, let's see if we all agree (NB: I am using cq1 syntax for building the model, the main focus is on what should the selectors do in such a situation):

from cadquery import *
box1 = Workplane('XY').box(1,1,1)

image

box1 = box.faces('>Z').circle(0.2).cutThruAll(id='cut1')

image

box2 = box1.faces('>Z').circle(0.4).cutThruAll(id='cut2')

image

So I'd expect box2.faces() to return all (7 faces) of box2, but ctx.find(op_id='cut1').faces() return 7 faces, out of which 1 is not returned by box2.faces().

For me it would also make sense to have ctx.find(op_id='cut1').created().faces() (or maybe ctx.find(op_id='cut1',created=True).faces() ) return the one cylindrical face, and ctx.find(op_id='cut1').modified().faces() return 2 (top and bottom) planar ones.

What do you think about this?

dcowden commented 7 years ago

Yep! I'm in agreement with both. I'm not sure which selector syntax I like better yet. I definitely like id being the only parameter to find, because then the api of the result matches other selectors returned by operations.

jmwright commented 7 years ago

@fragmuffin You had mentioned being able to build complex things like cars using the direct API. I don't want to pollute this issue too much, but I thought you might be interested in this simple car suspension with animations done in raw FreeCAD scripting. https://www.youtube.com/watch?v=LxvK6raH2Pg

fragmuffin commented 7 years ago

@jmwright very nice, thanks for the link :) that's similar to what I'll be setting up, but a bit more robotic.

jmwright commented 7 years ago

Adam Vermeer has done some simple assemblies using JSON in Jupyter Notebook. Have a look at the first message from June 20th here.

https://groups.google.com/d/msgid/cadquery/3090ee44-9e2b-40c7-befc-aed7c59a12aa%40googlegroups.com

He calls them "naive assemblies" since they don't use constraints between parts. It might still be interesting to you though.

zbynekwinkler commented 6 years ago

Any news on this "Direct API" front?

dcowden commented 6 years ago

@jmwright @zwn Sadly, no. Writing the direct API is a large task that I don't anticipate have the time to do all at once, and it doesn't lend itself to imcrental implementation.

The vision was initially for cw 2.0 to be OCC nased, with a direct API, and a stand alone GUI. This is simply too much for the resources available to us.

Since we have a nearly complete OCC branch, and it appears a gui might be quick to implement, I'm thinking it's best for 2.0 to release these alone.

After a lot of conversation yesterday, I want to validate that with all the core contributors, and then make a GitHub milestone and issues match that approach

dcowden commented 5 years ago

This has been closed in favor of the CQ 2.0 implemention at https://github.com/cadquery/cadquery