Replies: 1 comment
-
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Exploring a Direct api for CQ
Definitions
Goals
These are the qualities we are trying to achieve with the new direct api
Design Rules
Here are some design rules I think will help achieve our goals
11 use regular lists and sets. This allows pythonic code to find items as needed
Design Challenges
Here are some challenges that presented themselves during design. Some of these influenced the design considerably
Face/Edge Confusion Users are familiar with geometric shapes like Rectangle and Circle, so they are commonly used to describe these shapes.
Unfortunately, in OCP/OCC, a Rectangle can refer to a face ( IE, it is closed), a Wire( a linked set of edges), or a list of edges.
Sometimes, its not clear which a user intends, and dis-ambiguating them is tricky.
The shape api does it by defining two methods: Face.makeCircle() creates a circular FACE, while Edge.makeCircle() creates an edge
A 2D workplane is state It is fairly intuititve for a user to imagine the objects being created as operating on a selected 2D plane.
In that case, the user supplies 2D coordinates, so that the shapes are created in the selected plane.
Since the user will do several operations on the same plane, it is syntactically nicer to allow the user to supply the plane a single
time, vs in every call. Unfortunately, this requires saving state, that increases the conceptual complexity
Patterning Users should be able to replicate an operatoin based on a variety of patterns, such as a rectangular grid.
It should be possible to pattern an Operation, but also an arbitrary user-provided set of code ( an anonymous, inline operation, if you will).
Chaining Constructors Constructors are a good way to require inputs-- only one line of user code is needed, and we can avoid
states where we don't have valid arguments. We can use superclasses to provide inherited functionality, but there's a problem: once we
have a lot of superclasses, we start running into a lot of boilerplate superclass calls. It is nice to minimize this if we can
It's hard to imagine constraints without state Constraint based modelling ( assemblies or sketches) implies storing a list of constraints and then solving them at the end-- which makes it feel a little weird to model as a stateless operation
When should the work be done? When should the operation actually do its work? The most obvious choice is in the constructor, because then the user can't begin calling interrogation methods without the operation having been completed. That prevents passing an operation from one to another, though, which could be a useful way to support deferred execution. A build() method makes it very clear when the work is done, and would support deferred execution, but then the user has to call the extra method
Proposed Operation Api
Concepts
Things I'm unhappy with
Examples
Example of creating an edge between two points
Beta Was this translation helpful? Give feedback.
All reactions