Bug in trim on executePreview transaction
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.