Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

How do I "Undo" or delete a failed API operation ? (aka: Can the API remove/undo/delete the most recent feature from the timeline somehow?)

OceanHydroAU
Collaborator

How do I "Undo" or delete a failed API operation ? (aka: Can the API remove/undo/delete the most recent feature from the timeline somehow?)

OceanHydroAU
Collaborator
Collaborator

*UPDATE* I solved this before posting, but thought I would post anyhow so google-search can help anyone else wondering this stuff.

 

I've done something this:

 

try:
    section[ps]['foil']['patch']=patches.add(section[ps]['foil']['patchInput'])
except:
    ps=ps+1 # try again, with the next one along

 

because there are occasions where the section I'm patching is too "twisted" to be patchable - which I can't find any easy way to determine in advance.

 

That works OK, except I end up with an unwanted item on the timeline:-

 

Screen Shot 2021-02-01 at 10.23.35 pm.png

Can anyone think of a way to get rid of the thing that failed (preferably inside my exception handler)?  It's throwing the exception, so I don't have a reference to try to delete of course...

 

Alternatively - is there a way to "snapshot and revert" or some other setting to prevent it half-creating that broken feature?

0 Likes
Reply
Accepted solutions (1)
464 Views
2 Replies
Replies (2)

OceanHydroAU
Collaborator
Collaborator
Accepted solution

The solution that worked for me was to count how many features exist before trying the operation, then after it fails, if there's now more in there, delete the last one.

 

pcount=patchFeats.count # see how many features currently exist
try:
    section[ps]['foil']['patch']=patchFeats.add(section[ps]['foil']['patchInput']) # this might throw an exception
except:
    if pcount < patchFeats.count: # something broken got created
        dudpatch=patchFeats.item(patchFeats.count-1)
        dudpatch.deleteMe()

 

If you want to be certain that the thing you're about to delete really is bad, you can check

should check:

dudpatch.healthState != 0

-or-

dudpatch.errorOrWarningMessage isn't empty

1 Like

GRSnyder
Collaborator
Collaborator

I'm having the same problem with creating a SplitFaceFeature. Sometimes it doesn't work because the split tool doesn't quite extend all the way to the edge of the face. Totally my issue, but I'd like to just extend the cut line and try again. Unfortunately, SplitFaceFeatures.add does add the feature successfully, but something else within the bowels of the implementation raises a RuntimeError exception, preventing me from ever getting a reference to the unhealthy feature itself.

 

As far as I've been able to determine, there is no way to fix this except by poking around in the Timeline as described above. I suppose if you are not in "capture design history" mode, you can just ignore the exception.

0 Likes