I have many levels in a project to deal with terraced townhouses. Each of these levels ends with a suffix of the unit number in parentheses, such as “(21)”. I am copying the demising walls over and want to change each of their Base and Top Constraints up to the same level name with the next unit number. For example, I want a couple walls to move their Base Constraint from the level “2F T.O. SHT’G (20)” to “2F T.O. SHT’G (21)”, and the walls above them to move from the level “3F T.O. SHT’G (20)” to “3F T.O. SHT’G (21),” and so on. I am hoping that, since I have used numbers in the names, I can make use of this to make quick work of this task. So far I have the graph below, dealing with only the Base Constraint for now, I’ll deal with the Top Constraint after finishing this graph. I isolated the numbers in the names of the levels and increased their values by one, but am stymied by how to re-insert these new numbers back into the names of each corresponding level. Once I have re-created the levels’ names, I should be able to use a SetParameter node. That’s what I’m thinking. Any advice how to finish the graph?
Use String.Join or String.Concat to put your level name back together.
Then feed the new strings into the Element.SetParameterByName.
Where do I place one of those nodes? I don’t know how to transform my nested lists into single lines of strings. Do I need to specify levels on the Join or Concat node?
Here is where I am stuck:
That looks close to it. Does that work with the SetParameterByName node? I’m wondering if the lack of a parenthesis between “Level” and “Name” in your String.Concat node will cause the SetParameterByName node to not recognize the new values.
Make sure you have the string exactly right. Readd the : if you need to.
You can easily add the parenthesis back in - that was just showing how to set the concat/join nodes in a case like this.
Several ways to do it, but I’d probably grab the items at the indexes you want to add the parenthesis to, do a “(” + num + “)” codeblock, then replace item at index. There’s probably some super efficient one line DesignScript or custom node out there, but that’s a pretty easy OOTB solution.
You’d also have to check if that parameter even accepts a string as input. You may have to use your finished string to ‘search’ for the correct level element and use that to drive your parameter.
You are correct, the Base and Top Constraints do not accept strings as inputs. Do you have an idea which node or collection of nodes I could use to do such a search to find the level objects?
I got it! For the search I used the Clockwork node “Elements.FilterByName” with the list of the project’s levels. See below for the nodes I used for searching. The graph, all said and done, is the biggest beast of a graph I have yet made, and does not allow for “Unconnected” Top Constraint values, but this will work for me.
Nodes for searching and obtaining the levels of the Top and Base Constraints of the selected Walls:
How can you modify the top and base offset constraints on Dynamo?
this can be resolved more simply without packages, you just need get Element name node for Levels and use it for filtering the level elements.
@johnedgar10 you can use the ‘Top Offset’ and ‘Base Offset’ parameters and set them using a number node via input or slider like below:
You can also set the levels of these constraints like below also:
@Redrunner262 given I can see you’re still around on the thread (spotted the like, cheers!), here’s a helpful expanded version of ‘don’t use clockwork’. By the way, perfectly fine to use it; it’s well supported, developed and has exposed Python if anyone ever wants to open it up.
Hope this helps in case the last year didn’t lead you to an alternative approach:
Fantastic, thank you very much Gavin! Indeed the past year has not borne much fruit in my Dynamo-learning journey, so I greatly appreciate your help