geometry is over constrainted symmetry bug

geometry is over constrainted symmetry bug

casey.rogers
Alumni Alumni
883 Views
4 Replies
Message 1 of 5

geometry is over constrainted symmetry bug

casey.rogers
Alumni
Alumni

I have an addin where one component of it takes two projected edges that for a 90 degree corner, creates a third sketchline that is directly between those two edges using a symmetry constraint. 99% of the time this works just fine. However, under conditions that seem arbitrary, I get a "Failed : 5 : Sketch Gemoetry is over constrained" error when I try to apply the symmetry constraint.

Here is the section of code casuing problems:

 

Here are some screenshots of an example design where it sometimes fails:

fail.JPG

fail2.JPG

The second image shows the created projected lines and the created line that is supposed to be symmetrical. However, the symmetry constraint fails and is not applied in the second image (the line is in the exact middle because my add-in constructs it that way, but it is unconstrained).

Several changes will cause the add-in and the symmetry constraint not to fail:

1) using the modify tool to change the geometry being projected in any way that changes the projected lines

2) increasing the dimensions of the gap to 21.5 or larger

Manually creating the symmetry constraint after the add-in fails succeeds and behaves as expected.

Below is the segment of code in question, a link to the github repo with the add-in and attached is the design I'm using to debug the problem. Does anyone have any idea what's happening here?

https://github.com/caseycrogers/Dogbone

 

        tempPoint = adsk.core.Point3D.create((pointTuple[1].geometry.x + pointTuple[2].geometry.x)/2,
                                              (pointTuple[1].geometry.y + pointTuple[2].geometry.y)/2, 0)
        line0 = lines.addByTwoPoints(pointTuple[0], tempPoint)
        line0.isConstruction = True
        line1.isConstruction = True
        line2.isConstruction = True
        ui.messageBox("got here")
        constraints.addSymmetry(line1, line2, line0)
        ui.messageBox("this doesn't display because it crashes") 
0 Likes
Accepted solutions (1)
884 Views
4 Replies
Replies (4)
Message 2 of 5

zhijie.li
Alumni
Alumni

"Sketch Gemoetry is over constrained" means there are existing contrains on the sketch entities which cause the entities cannot be changed any more or add new constrain. You can try to remove the existing constraints and try it again.

 

take sketch line for example:

# delete constraints on line1
    constraints = line1.geometricConstraints
    for constraint in constraints:
        constraint.deleteMe()

# delete constraints on line2
    # TODO

# create symmetric constraint again.
    # TODO

 

0 Likes
Message 3 of 5

casey.rogers
Alumni
Alumni

I don't think this is the case however as I can manually create (via the GUI) the exact same symmetry constraint under the exact same conditions and I do not get a geometry is over constrained issue.  Additionally, the conditions that cause the failures versus the conditions that do not are all the same with respect to constraints: two projected lines forming a corner and one line with a coincident constraint to the corner of the projected lines.

 

I feel like the symmetry constraint method is falsely reporting that the geometry is overconstrained or I'm passing the inputs into the method improperly.

0 Likes
Message 4 of 5

zhijie.li
Alumni
Alumni

Hi casey,

 

I rechecked your sample, and found that the sketch line 1 and 2 are not allowed to be changed (include add constraint) because they have reference to the edges (used to project). Set “isReference” property to false can solve the problem. Please add codes as following and try again:

        #create a sketch and project the dogbone's corner onto the sketch

        sketch = sketches.add(plane)

        line1 = sketch.project(edge0)

        line2 = sketch.project(edge1)

        line1 = line1.item(0)

        line2 = line2.item(0)

        line1.isReference = False

        line2.isReference = False

 

Regards,

Zhijie

0 Likes
Message 5 of 5

casey.rogers
Alumni
Alumni
Accepted solution

Making the edges non-reference did not work. However, as I had the add-in originally, the symmetry line is exactly inbetween the two refelected lines. I just offset it slightly and now the add-in works. It appears to be a bug in the API where the symmetry constraint sometimes fails when the lines are already perfectly symmetrical, but not currently constrained.

0 Likes