I’ve been working on a rebar export script for a long time. My script is working fine as long as I select 1 beam. The goal is to have an export file for all beams in the project. For that I need to feed my script the beam elements one by one, so not as a list. My complex script can’t handle that.
Is there anyway to do this in Dynamo? For example send element 1, script creates an export file, when finished writing the export file a signal is send to feed element 2.
It’s like a “for…next loop”
Processing a list would be the intended way. Adjusting list levels and lacing can be complex but it resolves things in the easiest way.
As an alternate, you could try to create a custom node from the graph; that would reduce memory consumption if built correctly, but the same amount of calculations will be required by the cpu.
I know a list is the intended way but my script is very complex and works well for one selected element.
I’m trying to get it to work with a list but it’s hard and it might never work.
Do you have a small example of how to feed a custum node element by element?
At the start of your script put a number slider to cycle through one by one, then at the end set up a mouse clicker to queue up a mouse click on the slider uptick, and the manual run button.
Python has some tools to click the screen at XY coordinates. Ive used some custom implementations if this before in Grasshopper to register vectors into the view at clicked points, but havent tried in dynamo or making the click itself using python.
Could also implement a counter, which would likely be simpler than automating a mouse click (there are a LOT of issues with that around resolution and such).
Check if there is a .txt file with the same name as the active graph in the same path as the dynamo node; if so, open it, read the value, pass that out, and write back one more than the value. If not, make a new file and pass out a 0. The value passed from the Python node can then be used as a ‘get item at index’ node to pull out one item from the total selection. Run by player, and delete the text file when you’re done.
I spent a bit looking this over, but because of the constant shift from Python to Nodes it’d be a big lift. Shifting the Python code sets into a custom node would go a long way here as you’d be able to just manage the collection of rebar via list levels, and would help with long term maintenance of the code base as well.
The other option would be to go pure python - from the initial collection begin to loop over the dataset and do all of the work there, and then pack that in a custom node or leave it loose.
As the graph currently stands it’s too big a lift for me to easily help due to the other stuff I have on my plate (moving, the day job, and the like).