CADability dotNET

CADability is used as a CNC programming tool or interface in various contexts. CADability does not produce output in a Numerical control programming language. It provides the geometrical tools to produce such output. Some question in this context are answered here.

What is a Path?

There are two path objects: Path2D and Path.

Path is a geometric entity (implementing IGeoObject) which is displayed when contained in a visible Model. It is a ordered collection of 3D curves where each curve is connected with the next curve, i.e. the endpoint of curvei has the same coordinates as the startpoint of curvei+1. The last curve may be connected to the first curve. You can find out by calling IsClosed.

Path2D is a 2D dimensional curve. 2D curves serve as boundaries of Faces or Hatch objects. They are only visible if combined with a Plane (as in the Hatch object) or with a ISurface (as in the Face object).

There is a similar class to Path2D: The Border which is a 2D path which is always closed (see next question).

Border, SimpleShape, CompoundShape, how to deal with these objects?

Border, SimpleShape and CompoundShape are the objects of a 2D topology.

  • Border is a ordered collection of 2D curves which are connected to each other. It describes a "simply connected" piece of a planar surface.
  • SimpleShape is composed of a Border describing the outline and any number (including 0) of Borders describing holes. The holes are completely inside the outline and do not overlap each other (disjunct). Of course there may be no holes also. It is like a slice of cheese (with holes).
  • CompoundShape is a set of SimpleShapes which don't overlap.

There is a set of boolean operations on these objects. ...

There is an easy way to create a CompoundShape from an unordered list of curves (which is often the result when you import a dxf/dwg file): CreateFromList. This is an easy way to scan existing drawing for closed shapes. It will automatically find holes and multiple outlines.

If you need more control then you could use the action with which Hatch objects are generated: A single mouseclick inside a closed border finds that specific contour and optionally excludes holes.

Aequidistant or parallel curves

It is always an important issue to find aequidistant or equally spaced curves parallel to a given curve for the path of a tool. E.g. a cutting tool must move with a certain distance to a contour. Or the milling head must keep a certain distance to the outline.

Border.GetParallel returns one or more borders which are parallel or equally spaced to the original border. Positive distances produce borders to the outside, negative distances go inside. How could there be multiple borders as a result? Imagine the outside contour of the digit "8" (or any non convex outline). The aequidistant border to the inside may eventually fall apart into two parts.

SimpleShape.Shrink and SimpleShape.Expand do the same job for the SimpleShape respecting the holes (if there are any). Keep in mind that the result is always a CompoundShape.

CompoundShape.Shrink and CompoundShape.Expand are analoguos to the corresponding SimpleShape methods.

The result of this operations consist of lines and arcs, splines are approximated.

More complex tool pathes

More complex tool pathes are generated with the HatchStyles of Hatch objects. Hatch objects basically are defined by a CompoundShape and a HatchStyle. (Besides a Plane for the position in 3D space). You use a Hatch object to fill the interior of a CompoundShape with some curves defined by the hatch style.

HatchStyleLines yields a set of parallel lines according to the properties LineAngle, LineDistance, MarginOffset and some more. It also produces multiple set of parallel lines with different angles (e.g. used by laser marking systems).

HatchStyleContour yields a set of parallel conturs that fill the shape very effectively. It has many properties to define the way to deal with holes in the contour, the connection of the contour (e.g. spiral to produce few continuous paths) the direction, distance, orientation of the curves.

So simply define a Hatch object, set the shape and style and get the curves.

Automatically find holes to drill (Feature recognition of Solids)

If you have a Solid and you need to know where to drill holes, you need to take the following steps: Get the Shell of the solid. Iterate all the Faces of the Shell. Regard the Surface of the Face. If it is a CylindricalSurface use the properties Location and Axis to find out about the position of the hole. The bounds of the Area of the Face gives you the deepth you have to drill.

Finding the holes is just an example of 3D feature recognition. Solid.GetPlaneIntersection also provides a powerful tool for finding out about certain features of a solid.

I want to add tooling data to a Path

For most CNC programs you need to add more information to the geometry of the curves, like which tool is used, which speed, rpm, power etc. With little effort you can provide a user interface to add such data to a path or subcurves of a path.

The key to that functionality is UserData. You may connect any kind of data to geometric entities (and also to some other objects). When an object is selected you can see its data in the control center. Add some userdata in the form string->value to the object, and this data will also be displayed. So you can specify speed as a double value or tool selection as a MultipleChoiceProperty. These additional data objects are serialized (preserved when saved in a file). You can also add visual feedback to the display of the curve, e.g. changing color to represent tool selection or line pattern to show the speed.