Sketch.offset constraints are lost when geometry changes

Sketch.offset constraints are lost when geometry changes

Anonymous
Not applicable
1,747 Views
4 Replies
Message 1 of 5

Sketch.offset constraints are lost when geometry changes

Anonymous
Not applicable

Hi everyone,

I'm making an addin for making friction-fit "lids" to go on boxes. The user selects the open face of the box, and my addin:

 

  1.  projects the face into a new sketch
  2.  creates some curves with sketch.offset
  3. extrudes the new profiles into a new component

When I run my addin I can confirm that the sketch contains the projected curves and offset curves as expected. However if the box is edited earlier in the timeline (eg to add a fillet), the projected curve is update, but the offset curves do not update, and lose their offset constraint.

 

My code uses sketch.project() on the original geometry and then sketch.offset() on the projected lines. I don't understand why the offset constraint is lost when the timeline is recalculated. My only guess is because my addin doesn't have an executeHandler, it only has an executePreviewHandler (with isValidResult=True). But it feels to me that my addin shouldn't need to run at all once it's done its job. The offset constrain should be sufficient. What am I missing?

Below are screenshots showing how a fillet causes the offset constraint to be lost.

 

Before unsuppressing the filletBefore unsuppressing the filletAfter unsupressing the fillet. Offset constraint is lost.After unsupressing the fillet. Offset constraint is lost.

0 Likes
Accepted solutions (1)
1,748 Views
4 Replies
Replies (4)
Message 2 of 5

BrianEkins
Mentor
Mentor

You're correct that your add-in shouldn't need to be present once it's created the geometry.  The result of using your add-in should be exactly the same as going through the process manually.  If you go through the exact same process interactively, do the model update correctly?  Can you post an example to demonstrate the problem?

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 3 of 5

Anonymous
Not applicable

Hi Brian, thanks for your quick reply. I've just tested doing the steps manually and indeed the result is exactly the same as with my addin. So this isn't an API problem, as such.

 

The problem stems from the fillet. If I simply change the wall thickness of my box, the sketch works as expected (the offset constraint is retained). But a fillet introduces new curves, which aren't projected since they weren't present when my code was run.

 

My code is easily able to find the curves if they're present. So my new question is how do I get my code to run again and recreate the sketch?

 

0 Likes
Message 4 of 5

BrianEkins
Mentor
Mentor
Accepted solution

Unfortunately, there currently isn't a way to automatically execute your add-in's command and have it recreate whatever steps it did originally.  Sometimes a workaround is to have a semi-automatic process where the user needs to run a command to force this "recompute".  That's what I do with my "Nifty Dogbone" add-in.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 5 of 5

Anonymous
Not applicable

Yes I see, your addin has an extra toolbar item to force a recompute. It really feels like the API should have a RecomputeEventHandler.

 

Thanks for your help!

0 Likes