4 Truss Geometry Inputs, Use Only One With Python?

Evening All, So I’m in the process of creating a rather long structure with a single truss type. Currently a design based on a warren truss. However I’d like the option to ‘flick a switch’ to switch to other types, like Pratt & Howe trusses. I’ve used several if nodes however things get rather messy! I’m thinking whether this is a case to use an IfElse in Python? However I have no knowledge of coding. An idea of the script input & output below:

If IN[0] = 1
Use IN[1] as OUT
If IN[0] = 2
Use IN[2] as OUT
If IN[0] = 3
Use IN[3] as OUT
If IN[0] = 4
Use IN[4] as OUT
<p style="margin: 0cm 0cm 8pt;"></p> <p style="margin: 0cm 0cm 8pt;">I've had an attempted but it keeps giving me null's!</p> <p style="margin: 0cm 0cm 8pt;">The IN[o} is purely a number 1 ->4</p> <p style="margin: 0cm 0cm 8pt;">The other IN's contain geometry data.</p> <p style="margin: 0cm 0cm 8pt;"></p> <p style="margin: 0cm 0cm 8pt;">IF anyone has a good link to a good python beginners guide then do let me know!</p> <p style="margin: 0cm 0cm 8pt;"></p> <p style="margin: 0cm 0cm 8pt;">Thanks,</p> <p style="margin: 0cm 0cm 8pt;">Dan</p> <p style="margin: 0cm 0cm 8pt;">![Truss - 3D|1704x880](upload://qv3SjXtOFlxpwquT9z8EdRj4ZvB.png)</p>

Hi Daniel,

That looks like a very impressive truss generator. You can definitely use python for this, but at the same time, you could also use the default “List.GetItemAtIndex” node to select the desired outcome:

2015-12-02_10-24-23

 

 

 

 

 

 

 

 

 

 

 

 

You could use the list index approach inside a python node as well:

2015-12-02_10-26-43

 

 

 

 

 

 

Tho keep in mind that this process will need to execute all options first and only then pass along the one you select and thus this will not help performance wise.

A nice way to learn the basics of python is to try one of the many online resources:

https://www.codecademy.com/learn/python

Thanks Dimitar! Worked perfectly!

 

That’s only half the file above! Currently purging & rebuilding the file, but I have noticed the performance issues on the full larger model, strangely 0.8.2 seems to run smoother than 0.9!

Dan