Method Check
- Namespace
- OpenCAD2D
- Assembly
- OpenCAD2D.Core.dll
Check(Action<CadEditor>)
Checks an edit without making it: runs the call the delegate makes, with every check the call makes (its arguments,
its objects, the plan of the edit and the owner's gate) and none of its writing, and says what refused it. A Move of
a line on the locked layer Steel checks to The object 2F is on the locked layer Steel.; an Offset of a circle
of radius 10 inward by 15 to Cannot offset that object.; a Copy of a line to null, and no copy is made.
public string Check(Action<CadEditor> edit)
Parameters
Returns
- string
Null where the edit would be made; else why it would be refused, as the message of the exception the call throws for a number that is no edit (ArgumentException) or for what the drawing refuses (InvalidOperationException); an ArgumentException's message may carry a second line naming the parameter.
Remarks
editor.Check(e => e.Offset(curve, 5.0, side)) is checked as editor.Offset(curve, 5.0, side) is refused,
so that a script that has other changes to make first can find out whether the edit will be refused before it makes
them. Inside the delegate each edit of the editor (Move<T>(IEnumerable<T>, GeoVector2), Copy<T>(IEnumerable<T>, GeoVector2), Rotate<T>(IEnumerable<T>, GeoPoint2, double),
Scale<T>(IEnumerable<T>, GeoPoint2, double), Mirror<T>(IEnumerable<T>, GeoPoint2, GeoPoint2, bool), Offset(DxfCurve, double, GeoPoint2), Erase(IEnumerable<DxfEntity>)) checks and gives back what the
call would not (a Copy none, for it makes none); it opens no undo step and no group, writes nothing on the command
line and leaves the pickfirst selection alone. The first edit that is refused ends the check; the edits after it in the delegate are not looked at.
What the delegate does besides calling the edits (a zoom, a variable set) is done.
The check is of the drawing as it stands: an edit that follows others the script made first is not looked at as it will
be after them. One thing is left to the writing: an owner that takes an edit itself can still refuse it then (The
model owner did not take this edit.), and nothing is changed by that either.
A plugin that uses it states [assembly: CadPluginApi("1.5")].
Exceptions
- ArgumentNullException
Thrown when the delegate is null.