[resolved] tons of 'Links go out of the allowed scope' warnings

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
aapo
Posts: 615
Joined: Mon Oct 29, 2018 6:41 pm

Re: tons of 'Links go out of the allowed scope' warnings

Post by aapo »

I made pull request https://github.com/FreeCAD/FreeCAD/pull/5394 to add the extra information to the error message. Although it's a simple change, it's in the core, so I'm not too confident it'll be accepted straight away, but please test! :D

With this patch the error message is changed to a bit more informative form:

Code: Select all

Part::Extrusion: Link(s) to object(s) 'Sketch' go out of the allowed scope 'Extrude'. Instead, the linked object(s) reside within 'Body'.
It says 'link(s)' and 'object(s)' because the computation is based on the scope (Part-compatible shape object named 'Extrude' in the example), and it is possible that there are many out-of-scope objecs within 'Extrude', in which case they are all listed space-separated. The same goes for the list of the non-allowed scopes (in this case, 'Body').
chrisb
Veteran
Posts: 53930
Joined: Tue Mar 17, 2015 9:14 am

Re: tons of 'Links go out of the allowed scope' warnings

Post by chrisb »

Sounds good, thanks!
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: tons of 'Links go out of the allowed scope' warnings

Post by adrianinsaval »

aapo wrote: Tue Jan 18, 2022 6:37 pm It says 'link(s)' and 'object(s)' because the computation is based on the scope (Part-compatible shape object named 'Extrude' in the example), and it is possible that there are many out-of-scope objecs within 'Extrude', in which case they are all listed space-separated. The same goes for the list of the non-allowed scopes (in this case, 'Body').
did you consider the case were this list might become too long to be readable if displayed like this? IIRC there was a change for something of this sort not long ago.
aapo
Posts: 615
Joined: Mon Oct 29, 2018 6:41 pm

Re: tons of 'Links go out of the allowed scope' warnings

Post by aapo »

adrianinsaval wrote: Tue Jan 18, 2022 10:13 pm did you consider the case were this list might become too long to be readable if displayed like this? IIRC there was a change for something of this sort not long ago.
I did, but I'm not sure if my conclusions are correct. My (perhaps naive) assumption is that the number of objects is limited by the number of invalid 'features' linked to the scope-object, e.g. Sketches linked to a Body, and if I understood the code correctly, the invalid feature-objects should each be listed just once (even if they are used multiple times, as result.erase(std::unique(...)) is used in getScopedObjectsFromLinks()). It seems to me, that the only way to flood-fill the report view is to get the error triggered by an object having hundred of auto-generated invalid-linked child objects, but I couldn't think of such situations. And I dread to think of a person who manually adds hundreds of invalid features into a single container.

However, if there is a mechanism that autogenerates a lot of such features inside a Body, or a Part container, or a Part-workbench object, or whatever object; then it would be a problem for this error message (and possible the tree-view, if the features would show there, too). In that case, an obvious solution would be to truncate the printed list at some length and add an ellipsis. :D

EDIT: I added some code to limit the length of the listed strings in the error messages, and force-pushed a patch accordingly to the PR. I guess it doesn't hurt to be on the safe side, and I believe 99 % of the cases have at most three objects in the lists, anyway! :D
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: tons of 'Links go out of the allowed scope' warnings

Post by uwestoehr »

aapo wrote: Tue Jan 18, 2022 6:37 pm I made pull request https://github.com/FreeCAD/FreeCAD/pull/5394 to add the extra information to the error message. Although it's a simple change, it's in the core, so I'm not too confident it'll be accepted straight away, but please test!
Many thanks! As you said, it is a simple change. I find it very helpful.

Since a message is always also a matter of taste, i put it in now to see how it behaves in practice. Depending on the feedback, the message can be modified later.
chrisb
Veteran
Posts: 53930
Joined: Tue Mar 17, 2015 9:14 am

Re: tons of 'Links go out of the allowed scope' warnings

Post by chrisb »

uwestoehr wrote: Wed Jan 19, 2022 12:34 am Since a message is always also a matter of taste, i put it in now to see how it behaves in practice. Depending on the feedback, the message can be modified later.
I second this. It's not a dialog that gets too big or similar. So if many mistakes are made then many messages are shown. I wouldn't limit the length. Someone may want to process it automatically?
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
aapo
Posts: 615
Joined: Mon Oct 29, 2018 6:41 pm

Re: tons of 'Links go out of the allowed scope' warnings

Post by aapo »

chrisb wrote: Wed Jan 19, 2022 7:10 am I wouldn't limit the length. Someone may want to process it automatically?
I believe in practice there will be at most a few objects per error message, most likely just one, so the idea is to be on the safe side if there'll be something completely unexpected. The "tons of warnings" in the thread title refers to this warning being triggered for every affected container object (scope) displaying the warning after every recompute. So, if you'll have a lot of invalid objects, you'll get a lot of warnings - but this is unchanged, and exactly the same as the original implementation. Now you'll just get a little bit of helpful information per warning: What are the name(s) of the object(s) that are in the "wrong" places, and what are these "wrong places". But still tons of warnings! :lol:

The wrong place is completely subjective; if you have an object (Sketch) used inside two different objects (Body and Extrude), the sketch inside Body is "in the right place" for Body, but "in the wrong place" for Extrude; and if you swap the Sketch between objects, it's vice versa for the situation. This occurs unless the Body and Extrude would have the same GeoFeatureGroupExtension (the same, not only the same values), but then the Body and Extrude would be mutually interlocked in space. And, I don't think you'll be able to do that in practice, because I believe that at least in the current implementation GeoFeatureGroupExtension is never shared between different objects, but I'm not actually sure about that.
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: [resolved] tons of 'Links go out of the allowed scope' warnings

Post by carlopav »

That's a very helpful improvement. thx aapo!
aapo wrote: Wed Jan 19, 2022 9:49 am The wrong place is completely subjective; if you have an object (Sketch) used inside two different objects (Body and Extrude), the sketch inside Body is "in the right place" for Body, but "in the wrong place" for Extrude;
I think the right place it's always the place where the object (Sketch) is grouped into, so into the Body... because this means that it it's located in the parent object LCS... while Extrude does not provide a "place". The same would happen with 2 Body objects, the sketch could be located just in one of the two, and this is its right context.
Edit: In fact, if you move the Body, the Extrude should not update, because it does not detect a change in Sketch placement...
follow my experiments on BIM modelling for architecture design
aapo
Posts: 615
Joined: Mon Oct 29, 2018 6:41 pm

Re: [resolved] tons of 'Links go out of the allowed scope' warnings

Post by aapo »

carlopav wrote: Wed Jan 19, 2022 9:48 pm The same would happen with 2 Body objects, the sketch could be located just in one of the two, and this is its right context.
Indeed, and the idea of the enhanced error message is to offer the user more hints about what exactly went wrong, if the user tries to use the Sketch out of its right context, i.e. for an operation inside the wrong Body.

EDIT: What I meant by 'subjective' is the fact that whether or not a given object is in a right or wrong place depends on where the user is trying to execute the operation. For some contexts, a given object is in the wrong places, but for just one context (generally, its parent's context) it's in the right place. So, for a general error message it's impossible to state that an object is definitely in the wrong place, because it's in the wrong place for just the one particular operation (hence the warning).
Post Reply