All maya attributes are dynamic however you just have no cause and effect for the attribute.
mean change it value and see changes immediately, and not executing the script again.
Ok in general maya assumes the dg IS static, that is no dg node is created and no node is destroyed during dg evaluation. Because that wold lead to a sort of chaos thats really hard to manage, and it throws out the door mayas speed optimisations. This is to say there are unforseen complications to the matter. Such as not going to work with mentalray batch rendering very easily in all instances. But mayas done quite well even tough it assumes something doesnt mean you cant do something against it: Its just that all bets are off, you just now said to maya I know better and will manage all problems i get myself thank you.
Theres 6 ways out of this (4.5 sidestep the issue one really works th way you outline but....):
is to use a snapshot node and a animated start node thet you just make intermediary. It can do what you ask, its simple and effective. Tough you will need prefeerebly to know how many nodes you need at maximum up front. Because it can not just go and change the topography of the dg willfully. Since no nodes are destroyed, just nulled it works with most other maya modules as is.
create dummy nodes and hide. Well yes ok use snapshot instead, much better. As for example mentalray has issues with animated hidings in form of a speed penalty in exportation
makeĀ exporession that kill extra nodes and create more when needed, you can do this. Its easy to do but its not very efficient and its horribly hard to manage on the long term. Because it brings in a number of issues for animation and referencing. Since nodes do really disapear over time you cant expect to build history on top either, since it doesnt resurect after death. WHich is why the methods above have nodes created a head of time sitting and waiting. THis is against mayas ideology use at own risk.*
you can make all of the cubes in one object, thisway the node topo graphy doesnt change. Offcourse you now can not move the individual cubes as easily. The trick is to extrude a line 2 times and use one delete. IN terms of speed this is best, its oalso easiest to build history on top. Having only one downside the fac that all cubes share one transform.
Particle instacing, this is fast and malleable, should you decide to later do a helix no problem. But even this method has down sides of method 4.
make a new node.
Depending on what you actually need id choose 1, 4 or 5. Thing is maya is missing a a node that would bridge the methods 1 to 4, 4 to 5, 5 to 4 and 5 to 1. They arent hard to make they just dont exist in the default maya shipment. Making theese nodes would bring maya MUCH closer to par with houdini*.
- Thats to say if you must ask yoru probably not up to it.
**houdini has a advantage it has a compound node that can eat a lot of geometric data into one node. Maya really would need that node. The bevel++ actually tries to do this but the compound shape is missing