Class ObjectSnap
- Namespace
- OpenCAD2D
- Assembly
- OpenCAD2D.Core.dll
Object snaps, ortho, polar and grid snap, as AutoCAD's: given the cursor, the size of the aperture and the point a rubber band is drawn from, the point a click takes. Snaps are worked out from the display items under the aperture, through a space's PickIndex, so an INSERT's lines and arcs are snapped to where it places them.
public sealed class ObjectSnap
- Inheritance
-
ObjectSnap
- Inherited Members
Remarks
AutoCAD's order is kept: a snap to a point near the cursor (endpoint, midpoint, centre, node, quadrant, intersection, apparent intersection, insertion, geometric centre, the crossing of two tracking lines) wins, the nearest of them first; then a snap the object under the cursor gives wherever its point lies (perpendicular, tangent, the centre of a circle whose rim is under the cursor, the centroid of a closed polyline under it, the insertion point of a block or a text under it, the apparent intersection with an object clicked first); then a point on an extension, a parallel or a tracking line near the cursor; then the object offered as the first of an extended apparent intersection; then nearest. A POINT is a node, not an endpoint, as in AutoCAD. An XLINE and a RAY are snapped along their whole length, as lines without end: nearest, perpendicular and their crossings however far from their base points; the base point of a RAY is an endpoint and the root point of an XLINE a midpoint, as AutoCAD gives them. Where no object snap is found, the cursor is put on the grid, then held level or upright (ortho) or on a polar angle from the base point.
Extension, Parallel and object snap tracking work from points acquired by resting the cursor (Acquire(PickIndex, GeoPoint2, double, GeoPoint2?)): seven at most, the oldest let go first, each let go when the cursor rests on it again, and all of them by ClearAcquired(), which the window calls once a point is taken.
Constructors
- ObjectSnap(Tolerance)
Makes the snaps of AutoCAD's default: endpoint, midpoint, centre, quadrant and intersection, on.
Properties
- Acquired
Gets the points acquired, the oldest first; seven at most.
- AcquiresWithShift
Gets or sets whether a point is acquired for tracking only while Shift is held as the cursor rests on it, as AutoCAD's POLARMODE 8; off until set, when resting on it is enough. The window's canvas honours it.
- AdditionalPolarAngles
Gets or sets the additional polar angles, in radians from the X axis of the UCS, as AutoCAD's POLARADDANG while POLARMODE 4 is set: each held as it is beside the multiples of PolarAngle, but not its own multiples, and counted from the last segment too while PolarFromLastSegment is on; none until set. With a polar angle of 90 and 33 added, the cursor is held at 33 degrees from the base point, but not at 66.
- AngleOverride
Gets or sets the direction an angle override typed at the prompt holds the cursor to, in radians counter-clockwise from the world's X axis, as AngleOverride gives it; null, as until set, for none. The cursor is held on the line through the base point at that angle, either side of it, over the grid, ortho and polar, and an object snap still wins, as AutoCAD 2021's help has it. With 30 degrees from the origin, the cursor at (100, 0) is held at (75, 43.3).
- GridOrigin
Gets or sets the point the snap grid runs through, in the coordinates of Ucs, as AutoCAD's SNAPBASE; the origin until set.
- GridSnap
Gets or sets whether the cursor is put on the snap grid (SNAP, F9), or, while PolarSnap is on, on steps along the polar angles.
- GridX
Gets or sets the spacing of the snap grid along X; 10 until set.
- GridY
Gets or sets the spacing of the snap grid along Y; 10 until set.
- IsOn
Gets or sets whether object snaps are on (OSNAP, F3).
- Isoplane
Gets or sets the plane of an isometric snap, as AutoCAD's SNAPSTYL 1 with SNAPISOPAIR; null, as until set, for the rectangular snap of SNAPSTYL 0. The snap points then lie where the 30, 90 and 150 degree lines cross, twice GridY apart along each, as AutoCAD keeps half the vertical spacing in the drawing: SNAP Style Isometric 5 keeps a spacing of 8.6603 by 2.5, and the points lie 5 apart. Ortho holds the cursor on the two axes of the plane, whether the snap grid is on or not.
- LastSegment
Gets or sets the direction of the last segment drawn, the way a line or the end of an arc ran, which the polar angles are counted from while PolarFromLastSegment is on; null, as until set, for none.
- Magnet
Gets or sets whether the cursor is drawn locked on a snap's point, the rubber band running to it, as AutoCAD's AUTOSNAP 4 (the magnet); on until set. Off, the rubber band follows the cursor, and a click still takes the snap.
- Modes
Gets or sets the object snaps that may be taken.
- Ortho
Gets or sets whether the cursor is held level or upright from the base point (ORTHO, F8).
- Override
Gets or sets the object snaps of the next point alone, as AutoCAD's override typed at a point prompt (END, MID) or chosen from the Shift+right-click menu: taken in place of Modes, whether IsOn is on or off; None takes no object snap for that point (NONe). Null, as it is until set, for no override. The window clears it once the point is taken.
- Polar
Gets or sets whether the cursor is held on a polar angle from the base point when it comes near one (POLAR, F10).
- PolarAngle
Gets or sets the polar increment in radians; a quarter turn until set.
- PolarDistance
Gets or sets the step of PolarSnap, as AutoCAD's POLARDIST: nought, as until set, or below steps by GridX, the snap X spacing. It steps along the lines of object snap tracking from the points acquired too.
- PolarFromLastSegment
Gets or sets whether the polar angles are counted from the last segment drawn (LastSegment), as AutoCAD's POLARMODE 1 (Relative to last segment): off until set, when they are counted from the X axis of the UCS turned by SnapAngle, as they are where no segment has been drawn. With a polar angle of 90 and the last line drawn at 30 degrees, the cursor is held at 30, 120, 210 and 300 degrees from the base point.
- PolarSnap
Gets or sets whether SNAP steps along the polar angles in place of the grid, as AutoCAD's SNAPTYPE 1 (PolarSnap): off until set, as SNAPTYPE 0. With SNAP and POLAR on, the cursor held on a polar angle from the base point is put at a whole number of PolarDistance from it, so that with a distance of 25 a cursor 37 along the level line from (0, 0) is put at (25, 0); off a polar angle, or with POLAR off, the cursor goes free.
- ShowsMarker
Gets or sets whether the marker of a snap is drawn at its point, as AutoCAD's AUTOSNAP 1; on until set.
- ShowsSnapTip
Gets or sets whether the name of a snap is shown by the cursor, as AutoCAD's AUTOSNAP 2 (the AutoSnap tooltip); on until set.
- ShowsTrackingTip
Gets or sets whether the tip by the cursor, "Ortho" with the distance and the angle from the base point, is shown while the cursor is held by ortho, polar or a tracking line, as AutoCAD's AUTOSNAP 32 (the tooltips of polar tracking, object snap tracking and Ortho mode); on until set.
- SnapAngle
Gets or sets the angle the snap grid is turned by about GridOrigin, in radians from the X axis of Ucs, as AutoCAD's SNAPANG; nought until set. Ortho holds the cursor along the turned axes and the polar angles are counted from it, as AutoCAD's are. With a snap of 10 turned by 30 degrees, the cursor at (9, 4) is put on (8.6603, 5), the point 10 along the turned X axis.
- Tolerance
Gets the tolerance of the comparisons.
- Tracking
Gets or sets whether object snap tracking is on (OTRACK, F11): from each point acquired, lines run level and upright, or on every polar angle while Polar and TracksPolarAngles are on, and the cursor is held on one near it or where two cross.
- TracksPolarAngles
Gets or sets whether object snap tracking runs its lines from the points acquired on every polar angle while Polar is on, as AutoCAD's POLARMODE 2 (Track using all polar angle settings): off until set, when they run level and upright alone, as POLARMODE 0 (Track orthogonally only). With a polar angle of 45 and a point acquired at (100, 0), the cursor at (130, 30.4) is held on the line at 45 degrees only while it is on.
- Ucs
Gets or sets the user coordinate system the grid, ortho and polar tracking follow, as AutoCAD's do: the grid runs along its axes, ortho holds the cursor along them, and polar angles are measured from its X axis. Object snaps give world points whatever it is. The world until set; null sets the world.
Methods
- Acquire(PickIndex, GeoPoint2, double, GeoPoint2?)
The cursor has rested, as AutoCAD acquires a point when the cursor pauses on it: a point acquired before and within the aperture is let go; else, with object snap tracking on, the snap point under the cursor is acquired, and with Extension the end of a line or an arc there; else, with Parallel and a base point, the line under the cursor. A point acquired past the seventh lets the oldest go. A line 0,0 to 100,0 rested on at its end (99.6, 0.3) with Extension gives the end (100, 0) running on along +X.
- AcquireTrackPoint(GeoPoint2)
Acquires a point given rather than rested on, as AutoCAD's temporary track point (TT): while OTRACK is on, tracking lines run from it as from any point acquired, so that TT at (2 000, 0) holds the cursor near (2 000.3, 700) at (2 000, 700). It is drawn as a small cross and counts among the seven, the oldest let go first.
- ClearAcquired()
Lets every acquired point go, and the object clicked first for an apparent intersection: the window calls it once a point is taken or the prompt goes.
- Snap(PickIndex, GeoPoint2, double, GeoPoint2?, GeoPoint2?)
Gets the point a click at the cursor takes.
- TakeFirstObject(CadSnapResult)
Picks the object an ExtendedApparentIntersection offers as the first of two, as a click on it does in AutoCAD: the point is not taken, and the object under the cursor after gives where the two would cross, run on. Two lines 0,0 to 10,0 and 20,5 to 20,10, the first picked, give (20, 0) from anywhere on the second.