Option to Run Part A or Part B of a Script

Hi All,

I have a script which is numbering elements in order, using a spline to select the numbering order (see image: Element Renumbering Script).

I will run this script through Dynamo Player.

My issue is that sometimes I want to number elements without providing padding, for example: (1,2,3,4,5,6,7,8,9,10…)
and sometimes I want to number elements with padding, for example: (01,02,03,04,05,06,07,08,09,10…)

Is there a way I can choose to utilise the output from the green group when the boolean Padding Required is True and the output from the orange group
when the boolean is False? (see image: Zoom)

If anybody could point me in the direction of a similar post or provide any advice it would be greatly appreciated.

Thanks in advance for your help!


1 Like

Just change the place of your IF node. You don’t need an IF block for each one of the operations. In fact, remove them and connect your inputs directly.

Place the IF node right before your code block with the “a + b”, taking as inputs the outputs of the 2 operations.

Made a quick diagram to show you what I mean.

4 Likes

Hi @sed07,

I’ve clearly been staring at the screen for too long. How silly of me! Thanks for pointing this out…I think that’s enough dynamo for today.

Haha, yeah, happens to the best of us. Sometimes a small break is all you need :slight_smile:

1 Like

Was just about to propose the same hehe :sweat_smile:

1 Like

Thanks @Danos.

On a further point, is there a way to remove or grey out the inputs for the ’new width with padding’ and ‘pad with’ in the dynamo player, IF ‘padding required’ is switched to ‘false’?

I don’t have Dynamo open if front of me at the moment but looking at the screen caps another node I’ve used to capture similar functionality in my scripts that I don’t see mentioned yet is the Tool.RunMe node. I forget which package it’s from without Dynamo being open but basically I use it in conjunction with an if node for error checking or triggering complex branches of the script. I’ll feed an if-node a whole bunch of go/no go logic and then if it returns true trigger the required code. I like it because it keeps the error checking and functionality logic separate, each of which can be quite complex in their own right. Plus, sometimes I find it quite cumbersome to trigger certain behaviour directly from an if-node.

1 Like

Not directly in Dynamo Player,
But if someone fills in the ‘pad with’ input and the bool is set to false, nothing would happen anyways.

If you create the boolean node before you create the ‘padding with’ input, the boolean node will be on top in the dynamo player interface.

Also: You can create a string node, with a little explanation and select ‘is input’ so that user can read what they have to do with the script.

1 Like

You can maybe look into the Data-Shapes package if you want to do more with UI.

2 Likes

Hey @PerfectArchCo,

Thanks for your comment, I’ve heard of the Tool.RunMe node, I think it’s from the SteamNodes package iirc. I’ve shut down my pc for the night but I’ll have a play with this in the morning.

Thanks!

I’ve just started playing around with this- I’ll see if there’s anything in there to help me out - it’s a great package! Thanks.

Very helpful to know - thanks @Danos! I’ll have a play first thing in the morning!

@PerfectArchCo

Hi I had a look at the Tool.RunMe node from the SteamNodes package and from what I can tell, this seems to function exactly like @john_pierson’s Helpers.Toggle node in the Rhythm package. I’ve been using the rhythm node extensively in my scripts as a means of controlling which parts of my script to run - it’s incredibly helpful. Does anybody know if there is a discernible difference between the two or do they basically achieve the same result?

I believe the steam idea implementation is pretty much the same. :slight_smile:

Mine is essentially an if statement that returns the object or not based on the inputs.

1 Like

@john_pierson

Super handy node! Thanks!

Spooky @john_pierson piped up here because I’m pretty sure its from him I learned about the RunMe node last year. It sounds like the Rhythm package was updated without me noticing. I just checked and I do indeed already have that Rhythm node. Probably have had it for a while?

edit: without*

:ghost:

LOL, I added it back about a year ago. I had a user from Revit Forum ask for it after I removed the older DYF version. Along with it, I had added a few other nice helpers too.
image

3 Likes