Sketch::checkGeoID fails

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
Post Reply
chrisf
Posts: 212
Joined: Fri Jan 03, 2014 10:20 am

Sketch::checkGeoID fails

Post by chrisf »

I'm working on a part with 30 feature sketches with lots of external geometry that's falling over repeatedly in Sketch::checkGeoID.

I've commented out the assertion here in Sketch.cpp and it now seems stable:

Code: Select all

int Sketch::checkGeoId(int geoId)
{
    if (geoId < 0)
        geoId += Geoms.size();
//    assert(geoId >= 0 && geoId < int(Geoms.size()));
    return geoId;
}
I'm a bit pushed for time to look into this right now but suspect that this test is failing due to the use of negative indicies for external geometry?

Chris
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Sketch::checkGeoID fails

Post by wmayer »

Can you describe a way to get this assert failing? Actually the assert checks that the given geoId is in the the range [0, Geom.size()[. Which values do geoId and geom.size() have?
chrisf
Posts: 212
Joined: Fri Jan 03, 2014 10:20 am

Re: Sketch::checkGeoID fails

Post by chrisf »

I was working with a broken model that's now fixed. Guess I should have kept it really but I'm in a big hurry to get some parts out for prototyping.

As you say, the check tests for 0 < geoId < Geoms.size() but before that it tests for geoId < 0 and if so, adds on Geoms.size().

IIRC to numerate constraint geometries, the sketcher uses 0 -> Geoms.size() for edges in the sketch, -1 & -2 for the x and y axes and -3 -> -n for external geometry elements.

If this is right then, if a sketch has more external gemoetry items than edges in the sketch, then this test could fail.
chrisf
Posts: 212
Joined: Fri Jan 03, 2014 10:20 am

Re: Sketch::checkGeoID fails

Post by chrisf »

So, having browsed the code a bit more, it looks like, whilst the external geometries are referenced with a negative integer, theyr'e held at the end of the Geoms list so the test is valid.

As I said, the model was broken so I guess that was the cause of the assert failure.

If it happens again, I'll take a closer look at the cause because this can leave you with an unrecoverable model.
User avatar
Suraj Dadral
Posts: 307
Joined: Fri Sep 07, 2018 5:32 pm
Contact:

Re: Sketch::checkGeoID fails

Post by Suraj Dadral »

Similar error is happening in case of wall also as in this thread: https://forum.freecadweb.org/viewtopic.php?f=23&t=36127
And I am also getting following error when I try to edit sketch programmatically.
Error:

<Exception> Sketch::checkGeoId. GeoId index out range.
Traceback (most recent call last):
File "/home/blank/.FreeCAD/Mod/Reinforcement/BeamReinforcement/MainBeamReinforcement.py", line 1429, in clicked
self.accept(button)
File "/home/blank/.FreeCAD/Mod/Reinforcement/BeamReinforcement/MainBeamReinforcement.py", line 1532, in accept
self.FaceName,
File "/home/blank/.FreeCAD/Mod/Reinforcement/BeamReinforcement/TwoLeggedBeam.py", line 1670, in editReinforcement
structure,
File "/home/blank/.FreeCAD/Mod/Reinforcement/BeamReinforcement/TwoLeggedBeam.py", line 1962, in editTopReinforcement
facename_for_t_rebars,
File "/home/blank/.FreeCAD/Mod/Reinforcement/LShapeRebar.py", line 255, in editLShapeRebar
sketch.movePoint(0, 1, points[0], 0)
IndexError: {'sclassname': 'N4Base10IndexErrorE', 'sErrMsg': 'Sketch::checkGeoId. GeoId index out range.', 'sfile': '', 'iline': 0, 'sfunction': '', 'swhat': 'Sketch::checkGeoId. GeoId index out range.', 'btranslatable': False, 'breported': True}

Is this issue has been resolved?

Thanks,
Post Reply