Next (Logging) Previous (Scene Graph)


Basically, ctx executes your commands one by one, if an error occurs, ctx will stop, but the previous commands were already executed and saved in the database, although the operations are reversible, but you need to execute rollback using command like ctx().undo(). So if you want ctx execute your commands as a whole, you’d better employ ctx transaction.

A transaction is a unit of work that you want to treat as “a whole”. It has to either happen in full, or not at all.

A classical example is translating an object after renaming it. To do that you have to rename the object, and then translate it, however, you probably forget to change the name of the object in the second command, so ctx can’t execute the translation operation, but the rename operation had been done.

So if you want these two commands work as a whole, you can use transaction. Transaction is there to ensure, that no matter what happens, the data you work with will be in a sensible state. It guarantees that if one of the command failed, the other commands won’t modified the original data.

To start a transaction, use ctx().start(), and to end the transaction use ctx().end(). The commands in between start() and end() will be executed together by ctx.

For Example: Change the name of all polymesh objects to “YourObject

ctx('%PolyMesh').start().each(function(node) {



Next (Logging) Previous (Scene Graph)