By Adam Nagy
Issue: I have two commands inserting a block inside a transaction: the first inserts the block directly, the second does it through jigging. When run from a third command that combines the two then the first block does not appear until the second one's jig is finished when inside AutoCAD Mechanical. Inside plain AutoCAD it shows up fine.
I figured out that AutoCAD Mechanical wraps my command in a transaction. If I commit that then the first block appears fine, but it might cause other issues, so I'd rather avoid doing that.
Solution: You can force a transaction to flush graphics to the UI: http://adndevblog.typepad.com/autocad/2013/01/force-autocad-to-update-the-graphics-display-area.html
In our case adding a TransactionManager.QueueForGraphicsFlush() seems to be enough:
using (var transaction = document.TransactionManager.StartTransaction()) { // Code of first command adding the block
// Flush the graphics of the block to the UI transaction.TransactionManager.QueueForGraphicsFlush(); transaction.Commit(); }
You can also find information about this topic in "Autodesk ObjectARX for AutoCAD 2015: Developer Guide > Advanced Topics > Advanced Topics > Transaction Management"