Bug in trim on executePreview transaction

vonbinderhosen
Explorer

Bug in trim on executePreview transaction

vonbinderhosen
Explorer
Explorer

I've written a python script that has an CommandEventHandler which runs on executePreview. This handler calls methods which essentially take a curve, add intersecting curves, then trim and remote a portion of the original curve. That all works fine. However, depending on the type of trim action (there's branching logic), the original curve may be deleted during the work. That all works correctly.

 

The issue is that per the documentation, executePreview should be wrapped in a single transaction so that it is idempotent. However, what happens is that if executePreview runs again (after the originally selected curve was deleted by a previous executePreview), it throws an exception: RuntimeError: 4 : An API Object refers to a deleted Object

 

I wrote a super simple test of this and attached it. To test this script, start a new design and sketch a line. Select the line, run the script and you'll get a pop command with one button 'preview'. If you click that button, it will fire the executePreview command. If you click the preview a few times you'll get the error.

 

To prove it's the trim, you can comment out line 39 (I commented on it) and you'll see it's otherwise idempotent.

0 Likes
Reply
92 Views
2 Replies
Replies (2)

vonbinderhosen
Explorer
Explorer

As a follow-up, I tried using guidance on this page, doing a timeline marker and rollTo. It moves the marker, but still hits the same deleted error.

0 Likes

vonbinderhosen
Explorer
Explorer

Ok, I have a guess as to what's happening. My script acts on a sketch (when in edit sketch mode). I think the transactions aren't used in an edit sketch, because I also see the timeline doesn't move inside edit sketch.

0 Likes