PartDesign Next - discussion on Attacher

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

PartDesign Next - discussion on Attacher

Post by DeepSOIC »

Attacher is the code behind datum plane, line and point attachment, as well as positioning of PartDesign primitives, and attachment of sketches.

List of attachment modes available:

Code: Select all

const char* AttachEngine::eMapModeStrings[]= {
    "Deactivated",
    "Translate",
    "ObjectXY",
    "ObjectXZ",
    "ObjectYZ",
    "FlatFace",
    "TangentPlane",
    "NormalToEdge",
    "FrenetNB",
    "FrenetTN",
    "FrenetTB",
    "Concentric",
    "SectionOfRevolution",
    "ThreePointsPlane",
    "ThreePointsNormal",
    "Folding",

    "ObjectX",
    "ObjectY",
    "ObjectZ",
    "AxisOfCurvature",
    "Directrix1",
    "Directrix2",
    "Asymptote1",
    "Asymptote2",
    "Tangent",
    "Normal",
    "Binormal",
    "TangentU",
    "TangentV",
    "TwoPointLine",
    "IntersectionLine",
    "ProximityLine",

    "ObjectOrigin",
    "Focus1",
    "Focus2",
    "OnEdge",
    "CenterOfCurvature",
    "CenterOfMass",
    "IntersectionPoint",
    "Vertex",
    "ProximityPoint1",
    "ProximityPoint2",
    NULL};
This is list of attachment mode names as they appear in Property Editor. Same names are used in task dialog, but there a renaming-translating map should be introduced at some point.

List of inputs as per attachment mode:
Plane and coordinate system modes:

Code: Select all

    mmTranslate: rtVertex
    
    mmObjectXY, mmObjectXZ, mmObjectYZ: any object with placement OR conic (i.e. ellipse/parabola/hyperbola)

    mmFlatFace: Planar face

    mmTangentPlane: Face + Vertex    OR   rtVertex + Face

    mmNormalToPath:  Edge OR Edge + Vertex   OR   Vertex + Edge

    mmFrenetNB, mmFrenetTN, mmFrenetTB, mmRevolutionSection, mmConcentric: Edge(curved)   OR   Edge + Vertex   OR   Vertex + Edge

    s = cat(rtVertex, rtVertex, rtVertex);
    mmThreePointsPlane, mmThreePointsNormal: Vertex + Vertex + Vertex    OR   Line + Vertex    OR    Vertex + Line    OR    Line + Line

    mmFolding: Line + Line + Line + Line
Line modes:

Code: Select all

    modeRefTypes[mm1AxisX] = attacher3D.modeRefTypes[mmObjectYZ];
    modeRefTypes[mm1AxisY] = attacher3D.modeRefTypes[mmObjectXZ];
    modeRefTypes[mm1AxisZ] = attacher3D.modeRefTypes[mmObjectXY];
    modeRefTypes[mm1AxisCurv] = attacher3D.modeRefTypes[mmRevolutionSection];
    modeRefTypes[mm1Binormal] = attacher3D.modeRefTypes[mmFrenetTN];
    modeRefTypes[mm1Normal] = attacher3D.modeRefTypes[mmFrenetTB];
    modeRefTypes[mm1Tangent] = attacher3D.modeRefTypes[mmNormalToPath];

    modeRefTypes[mm1TwoPoints].push_back(cat(rtVertex,rtVertex));
    modeRefTypes[mm1TwoPoints].push_back(cat(rtLine));

    modeRefTypes[mm1Asymptote1].push_back(cat(rtHyperbola));
    modeRefTypes[mm1Asymptote2].push_back(cat(rtHyperbola));

    modeRefTypes[mm1Directrix1].push_back(cat(rtConic));

    modeRefTypes[mm1Directrix2].push_back(cat(rtEllipse));
    modeRefTypes[mm1Directrix2].push_back(cat(rtHyperbola));

    modeRefTypes[mm1Proximity].push_back(cat(rtAnything, rtAnything));
Point modes:

Code: Select all

    modeRefTypes[mm0Origin] = attacher3D.modeRefTypes[mmObjectXY];
    modeRefTypes[mm0CenterOfCurvature] = attacher3D.modeRefTypes[mmRevolutionSection];
    modeRefTypes[mm0OnEdge] = attacher3D.modeRefTypes[mmNormalToPath];

    modeRefTypes[mm0Vertex].push_back(cat(rtVertex));
    modeRefTypes[mm0Vertex].push_back(cat(rtLine));

    modeRefTypes[mm0Focus1].push_back(cat(rtConic));

    modeRefTypes[mm0Focus2].push_back(cat(rtEllipse));
    modeRefTypes[mm0Focus2].push_back(cat(rtHyperbola));

    s = cat(rtAnything, rtAnything);
    modeRefTypes[mm0ProximityPoint1].push_back(s);
    modeRefTypes[mm0ProximityPoint2].push_back(s);
Hopefully I will transform all this mess into something nicer soon ;)
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: PartDesign Next - discussion on Attacher

Post by triplus »

cox
Posts: 971
Joined: Wed Nov 26, 2014 11:37 pm

Re: PartDesign Next - discussion on Attacher

Post by cox »

DeepSOIC wrote:
"TangentPlane",
"NormalToEdge",
"FrenetNB",
"FrenetTN",
"FrenetTB",
If the offsets in the bottom of the Attach form was expanded to have complete plasment(I guess super) dialog plus definable point on discretized surface, could not the above modes be condensed to one mode "Tangent" with the possibility to further define the special case with the placement dialog etc.

"TangentPlane" - Tangent on plane at discretized point on surface.
"NormalToEdge" - Tangent to edge rotated 90 deg around local x axis.
"FrenetNB" - Tangent to edge rotated 90 deg around local x axis. (Is this not the same as spesial "NormalToEdge" for strait edge?)
"FrenetTN" - Tangent to edge rotated 90 deg around local y axis.
"FrenetTB" - Tangent to edge.

I am aware that I am setting myself up for some 1D, 2D confusion and relying that the frenet magnitudes are not considered.
Need help? Feel free to ask, but please read the guidelines first
cox
Posts: 971
Joined: Wed Nov 26, 2014 11:37 pm

Re: PartDesign Next - discussion on Attacher

Post by cox »

Could center of gravity/mass be a candidate for the attacher, seams to me that most objects has this parameter.
Some cool relations between odd shaped objects might be doable. eg. consentric compatible with pentagon/square centre of mass attach, without relying on external references in sketches.
Need help? Feel free to ask, but please read the guidelines first
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: PartDesign Next - discussion on Attacher

Post by DeepSOIC »

cox wrote:could not the above modes be condensed to one mode "Tangent" with the possibility to further define the special case with the placement dialog etc.

"TangentPlane" - Tangent on plane at discretized point on surface.
"NormalToEdge" - Tangent to edge rotated 90 deg around local x axis.
"FrenetNB" - Tangent to edge rotated 90 deg around local x axis. (Is this not the same as spesial "NormalToEdge" for strait edge?)
"FrenetTN" - Tangent to edge rotated 90 deg around local y axis.
"FrenetTB" - Tangent to edge.
Well, I'd like to keep TangentPlane a separate mode simply because it is completely different code-wise.
NormalToEdge and FrenetNB are slightly different. In NormalToEdge, vertical sketch axis should tend to align with global Z axis, while in FrenetNB, it will align to binormal. As a consequence, NormalToEdge works on both straight and curved edges, while Frenet* modes require curvature.

Frenet* modes can indeed be joined, as one can be achieved from the other by superPlacement. However, I find this handy to have these modes separated, just like selecting sketch orientation as XY/XZ/YZ on creation is handy (it is extremely un-handy to manually set placement to achieve XZ plane sketch).
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: PartDesign Next - discussion on Attacher

Post by DeepSOIC »

cox wrote:Could center of gravity/mass be a candidate for the attacher, seams to me that most objects has this parameter.
That was planned, thanks for reminding!
cox wrote:Some cool relations between odd shaped objects might be doable. eg. consentric compatible with pentagon/square centre of mass attach, without relying on external references in sketches.
Not straightforward, but may be. I'll think about it.
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: PartDesign Next - discussion on Attacher

Post by DeepSOIC »

Found a bug. On datum lines and points, superPlacement is applied twice. Will fix.
Funny is that I found the bug while reading the code.
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: PartDesign Next - discussion on Attacher

Post by DeepSOIC »

One more important thing I want to say about Attacher. All Part2DObject geometry features are attachable (Sketcher Reorient Sketch command can be used as a crude temporary attachment UI). That applies to:
* Sketches (of course :P )
* PartDesign InvoluteGear
* Most of Draft Primitives
However, in Draft workbench, Attacher is partially defunct, because Python implementation needs to call object.positionBySupport() from within execute().

I plan expanding Attacher to provide Py interface, and introducing a standard attachment editing UI available from maybe everywhere. I'm not sure how soon will I get there, and will I ever...

Next, I plan using Attacher for Lattice placements.... :mrgreen: long long way to go.

EDIT: maybe Part primitives should be made attachable, too.
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: PartDesign Next - discussion on Attacher

Post by DeepSOIC »

Work in progress...
attaher-ui-workinprogress.png
attaher-ui-workinprogress.png (60.02 KiB) Viewed 2574 times
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: PartDesign Next - discussion on Attacher

Post by triplus »

I can't judge on how appropriate the names are or if they can be further improved. Due to the fact ATM i can't test the attacher modes in-depth (lack of free time). But as for looking at the picture and comparing it with what we had before i would say this is an improvement indeed. A bit of explanation on why i believe that. If we take for example:

TangentPlane

This is a term suitable for property name. But as for descriptive terminology user is confronted with in UX it is less suitable. Simply as the user isn't computer and usually uses different terminology to communicate. ;)
Optional vertex link defines where.
How about:

Point can be used as additional reference.

That is do we need to get technical with end users and use the term vertex? But as said definitely the step in the right direction!
Post Reply