https://github.com/FreeCAD/FreeCAD/pull/1554
I think it could be merged, but as the PR says it could be possible to improve the python interfacing before doing so, as to avoid having to change anything build on it afterwards.
I am not posting videos, as the capabilities are substantially the ones shown above. I would like to comment on how it works, and particularly in how it can leveraged by Python users.
There are "simple" routines, that follow the following logic:
Detect - (Analyse) - [Get] - [Set] - Make
Parenthesis means not necessarily available for all the routines, brackets means they are available but need not be executed, depends on the application.
So basically you "Detect" a type of constraint or types of constraints and you "Make", i.e. you create the constraints detected. Different constraints or types of constraints may take different parameters for detection, and also have default values, but are first detected and then made.
The Get/Set enables the user to see the result of the detection and modify it before applying it. As said they are optional, as the make acts on the detect result directly if this is not needed. It gives you back a list of tuples, which is (First, FirstPos, Second, SecondPos), for cases where several different constraints are detected by a single detect-analyse processes, it has a fifth value which is the constraint Type.
The Analyse, which is not available for all the routines, operates in detected constraints of the same routine, to look for alternatives. For example, a general pointonpoint detection leads to a search for coincident constraints, which can be later run via Analyse if it is intended to convert endpoint coincidence to endpoint perpendicular and tangent constraints.
Neither the Detect, nor the Analyse, nor the Get steps modify the Sketch geometry. Make applies the constraints stored internally in the SketchAnalysis object.
The make takes one parameter, a boolean "onebyone", which enables the user to decide whether constraints should be added one by one, solving and checking for redundancies after each addition and removing redundancies if positive. EACH routing has its own DEFAULT value, so some routines default to true and others to false. The reason is that some routines are fine with "False" where others require a "True".
Currently you have these simple routines (the same parameters are used in Python):
Code: Select all
int detectMissingPointOnPointConstraints(double precision = Precision::Confusion() * 1000, bool includeconstruction = true);
void analyseMissingPointOnPointCoincident(double angleprecision = M_PI/8);
int detectMissingVerticalHorizontalConstraints(double angleprecision = M_PI/8);
int detectMissingEqualityConstraints(double precision);
Then there is currently one complex routine that combines different simpler routines, which is called autoconstraint, and is shown in the videos above. It basically calls the different detection methods, in a particular order and orderly adds the constraints to avoid problems.
Code: Select all
int autoConstraint(double precision = Precision::Confusion() * 1000, double angleprecision = M_PI/20, bool includeconstruction = true);
Code: Select all
void autoRemoveRedundants(bool updategeo);
int deleteAllConstraints();
Of course if you test it, I am curious of your feedback.
For the Python doc readers:
<Methode Name="autoconstraint">
<Documentation>
<UserDocu>
Automatic sketch constraining algorithm.
</UserDocu>
</Documentation>
</Methode>
<Methode Name="detectMissingPointOnPointConstraints">
<Documentation>
<UserDocu>
Detects Missing Point On Point Constraints. The Detect step just identifies possible missing constraints.
The result may be retrieved or applied using the corresponding Get / Make methods.
</UserDocu>
</Documentation>
</Methode>
<Methode Name="analyseMissingPointOnPointCoincident">
<Documentation>
<UserDocu>
Analyses the already detected Missing Point On Point Constraints to detect endpoint tagency/perpendicular.
The result may be retrieved or applied using the corresponding Get / Make methods.
</UserDocu>
</Documentation>
</Methode>
<Methode Name="detectMissingVerticalHorizontalConstraints">
<Documentation>
<UserDocu>
Detects Missing Horizontal/Vertical Constraints. The Detect step just identifies possible missing constraints.
The result may be retrieved or applied using the corresponding Get / Make methods.
</UserDocu>
</Documentation>
</Methode>
<Methode Name="detectMissingEqualityConstraints">
<Documentation>
<UserDocu>
Detects Missing Equality Constraints. The Detect step just identifies possible missing constraints.
The result may be retrieved or applied using the corresponding Get / Make methods.
</UserDocu>
</Documentation>
</Methode>
<Methode Name="makeMissingPointOnPointCoincident">
<Documentation>
<UserDocu>
Applies the detected / set Point On Point coincident constraints. If the argument is True, then solving and redundant removal is done after each individual addition.
</UserDocu>
</Documentation>
</Methode>
<Methode Name="makeMissingVerticalHorizontal">
<Documentation>
<UserDocu>
Applies the detected / set Vertical/Horizontal constraints. If the argument is True, then solving and redundant removal is done after each individual addition.
</UserDocu>
</Documentation>
</Methode>
<Methode Name="makeMissingEquality">
<Documentation>
<UserDocu>
Applies the detected / set Equality constraints. If the argument is True, then solving and redundant removal is done after each individual addition.
</UserDocu>
</Documentation>
</Methode>
<Methode Name="autoRemoveRedundants">
<Documentation>
<UserDocu>
Removes constraints currently detected as redundant by the solver. If the argument is True, then the geometry is updated after solving.
</UserDocu>
</Documentation>
</Methode>
<Attribute Name="MissingPointOnPointConstraints" ReadOnly="false">
<Documentation>
<UserDocu>
returns a list of (First FirstPos Second SecondPos Type) tuples with all the detected endpoint constraints.
</UserDocu>
</Documentation>
<Parameter Name="MissingPointOnPointConstraints" Type="List"/>
</Attribute>
<Attribute Name="MissingVerticalHorizontalConstraints" ReadOnly="false">
<Documentation>
<UserDocu>
returns a list of (First FirstPos Second SecondPos Type) tuples with all the detected vertical/horizontal constraints.
</UserDocu>
</Documentation>
<Parameter Name="MissingVerticalHorizontalConstraints" Type="List"/>
</Attribute>
<Attribute Name="MissingLineEqualityConstraints" ReadOnly="false">
<Documentation>
<UserDocu>
returns a list of (First FirstPos Second SecondPos) tuples with all the detected line segment equality constraints.
</UserDocu>
</Documentation>
<Parameter Name="MissingLineEqualityConstraints" Type="List"/>
</Attribute>
<Attribute Name="MissingRadiusConstraints" ReadOnly="false">
<Documentation>
<UserDocu>
returns a list of (First FirstPos Second SecondPos) tuples with all the detected radius constraints.
</UserDocu>
</Documentation>
<Parameter Name="MissingRadiusConstraints" Type="List"/>
</Attribute>