sketcher : invalid constraint cannot be selected or deleted

About the development of the Part Design module/workbench. PLEASE DO NOT POST HELP REQUESTS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
freman
Veteran
Posts: 2214
Joined: Tue Nov 27, 2018 10:30 pm

sketcher : invalid constraint cannot be selected or deleted

Post by freman »

Hi,

deleting a constraint which is referenced in another constraint leads to an arbitrary reassignment.

This can often assign a zero value to a length based constraint. It seems that it is them impossible to select the broken constraint in the 3D since it no longer responds to mouse events such and hover and click.

When a constraint is deleted, all constraints above it in the list get renumber down. So any other constrain referring to it via expression evaluation Constraints[xx] now arbitrarily refers to some other variable. If the deleted object was a length and the new object pointed to is non dimenstional ( such as a horizontal , perpendicular or parallel constraint ) the expression now evaluates to zero. This will likely have destructive effects on the sketch.

Worse it seems that such a zero valued dimension cannot be selected, to change or delete it.

Clearly the abitrary reassignment is a serious bug and should not be happening.

A more acceptable outcome would be to keep the previous numerical value, and "clear" the expression entry, probably with a warning

Alternatively, all derivative constraints should be removed entirely, leaving the user to add a new constraint.

I see this in recent master build. I have been making more use of Constraints[xx] references recently , so probably this is nothing new, just I never hit the problem before.
Attachments
zero-dim.png
zero-dim.png (2.46 KiB) Viewed 1271 times
User avatar
adrianinsaval
Veteran
Posts: 5553
Joined: Thu Apr 05, 2018 5:15 pm

Re: sketcher : invalid constraint cannot be selected or deleted

Post by adrianinsaval »

see issue #7668 and the related forum discussion, this is known and we have discussed a potential solution, however it hasn't been coded yet.
chrisb
Veteran
Posts: 54293
Joined: Tue Mar 17, 2015 9:14 am

Re: sketcher : invalid constraint cannot be selected or deleted

Post by chrisb »

freman wrote: Sun Apr 23, 2023 9:08 pm Worse it seems that such a zero valued dimension cannot be selected, to change or delete it.
This is a separate issue, which may be fixed in the most recent 0.21. Workaround: increase the font size.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
freman
Veteran
Posts: 2214
Joined: Tue Nov 27, 2018 10:30 pm

Re: sketcher : invalid constraint cannot be selected or deleted

Post by freman »

thanks Adrian, this looks like a vipers nest ( or rather a python's nest ) of problems . Shame it has stalled for a while. It seems a lot of this should have been coded with linked lists, not linear arrays.

Chris thanks for the tip. I'll try that if I can still find this offending constraint. I think I just backed out the change which created it.

I tried zooming in so that nothing else was present, as seen in the screenshot, and it was still impossible to select it. These is no part of the screen which responds to the mouse. How is this a result of font size when I have no issues on other constraints, just the zero dimensioned one. It seems data related.
Last edited by freman on Thu Apr 27, 2023 5:35 am, edited 1 time in total.
chrisb
Veteran
Posts: 54293
Joined: Tue Mar 17, 2015 9:14 am

Re: sketcher : invalid constraint cannot be selected or deleted

Post by chrisb »

freman wrote: Wed Apr 26, 2023 7:17 am I tried zooming in
Zooming doesn't help. I discussed this recently with Abdullah and he made a change.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
freman
Veteran
Posts: 2214
Joined: Tue Nov 27, 2018 10:30 pm

Re: sketcher : invalid constraint cannot be selected or deleted

Post by freman »

OK, if it's already known and fixed that's great. That was my aim in reporting it.

I don't know where Abdullah hangs out but hopefully he can look at the possibility of using linked lists instead of pythons lists which are just dynamnic arrays. The horrible topo instability problem seems to have a similar cause.
chrisb
Veteran
Posts: 54293
Joined: Tue Mar 17, 2015 9:14 am

Re: sketcher : invalid constraint cannot be selected or deleted

Post by chrisb »

freman wrote: Thu Apr 27, 2023 5:46 am... using linked lists instead of pythons lists which are just dynamnic arrays. The horrible topo instability problem seems to have a similar cause.
I think it's ok to go off topic, because OP is solved. Can you elaborate your thought? I can neither imagine that the TNP is caused by using a certain implementation of lists, nor that some selectability is causing TNP issues.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
adrianinsaval
Veteran
Posts: 5553
Joined: Thu Apr 05, 2018 5:15 pm

Re: sketcher : invalid constraint cannot be selected or deleted

Post by adrianinsaval »

"Just use linked lists" is not a solution to TNP, people often come here and read some short description of some programming concept and think "well looks like I found a solution to TNP! Why is it that all these programmers with years of experience working on FreeCAD haven't thought of this before?"

But obviously solving TNP problem is much more nuanced than that... There's people working on it already, it's been going on for years now with a lot of thought and research into it, leave it to the experts unless you actually know what you are talking about and can code.

Likewise the constraint renumbering problem is also more nuanced and I have my doubts that linked list are of any use here, after all when using expressions we are not sequentially accessing members of the list so the pointer to the next member is useless, we want to access one specific object via an identifier, linked lists don't magically solve the identifier problem nor are they necessary to solve them. I could of course be wrong since I'm also an amateur programmer
chrisb
Veteran
Posts: 54293
Joined: Tue Mar 17, 2015 9:14 am

Re: sketcher : invalid constraint cannot be selected or deleted

Post by chrisb »

adrianinsaval wrote: Thu Apr 27, 2023 1:02 pm "Just use linked lists" is not a solution to TNP, people often come here and read some short description of some programming concept and think "well looks like I found a solution to TNP! Why is it that all these programmers with years of experience working on FreeCAD haven't thought of this before?"
You are very right with your conclusion, but the argument is very weak. Great inventions would be impossible, because there were always great inventors before, who would have invented it before.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
adrianinsaval
Veteran
Posts: 5553
Joined: Thu Apr 05, 2018 5:15 pm

Re: sketcher : invalid constraint cannot be selected or deleted

Post by adrianinsaval »

You are right and realthunder himself was not an expert either when he started this journey, what I don't like is the oversimplification of both the problem and the solution, treating an inherently complex problem as if it was just due to an oversight.
Post Reply