Tuesday, January 20, 2015

Dynamo: Text Padding Nodes

I made an engrossing discovery the other day, meet as I was closing up my article on zero-padding for an integer-to-string conversion. And while I do not regret the try I put into nonindustrial the bespoken nodes to achieve that result, as I am still very much in acquisition mode, and that gave me a duty in which I had whatever interest, I would be remiss if I did not pass along this "discovery".

In the Dynamo out-of-the-box Library, there are two nodes that, kindred to my bespoken node, will "pad" a progress to a given length, using the case (or characters) of your choice. These crapper be found low Core > String > Actions, and are called PadLeft and PadRight.

In the image above, the aforementioned signaling is provided to each of these nodes, and the newWidth signaling is provided with a itemize of values, resulting in a itemize of results, so you crapper wager the effects. The str signaling is "ABC" and a multi-character string, "wxyz" is utilised for the padChars input. As you crapper see, the PadLeft convexity adds artefact characters to the mitt lateral of the string; the PadRight convexity adds artefact characters to the correct lateral of the string. Just aforementioned my bespoken node, if the size of the initial progress is the aforementioned or greater than the newWidth value, the original progress is passed through unmodified.

Unlike my bespoken node, you crapper specify whatever progress to be utilised for padding. If the artefact progress has more than one character, then Dynamo uses the prototypal case of the progress when one case is required for padding, the prototypal two characters when two characters are required, and so on. If the required number of characters for artefact exceeds the size of the padChars string, as many instances of the flooded progress nonnegative a coloured progress with as many characters starting with the prototypal as necessary to alter the final progress to the given size will be used.

The Screencast beneath shows how the PadLeft convexity crapper be utilised to do the aforementioned abstract as my bespoken node.

The warning to be learned here is, preceding to embarking on a planning duty in Dynamo, take a careful countenance at what is provided out-of-the-box (as substantially as in "packages" of bespoken nodes that crapper be downloaded) to wager if whatever or every of what you requirement to do is already available.

People who read this post also read :

No comments :

Post a Comment