How to create a concrete reinforcement toolbox with Rhino?

Hi everyone,

This post is a bit long, so just to bring the essential first, I am a civil engineer working for a 1000 people engineering company ( We are designing bridges, towers, and power plants.

I am working for our scientific direction, where I am in charge of developping new tools between engineering softwares (finte elements) and 3D / BIM softwares. From my own experinece with Rhino, I think it is the perfect environment to develop “software bridges”. But as I said I am just a civil engineer, and I need good advice here. Lukilly you’re here ! :wink: Here above I briefly describe what I’ve been doing with scripts so far, what I need to do now, and what kind of help I really need.

What I have been doing so far
I have been using RhinoScript for a couple of years, and so far I’ve been quite happy with it. From drawing a parametric bridge (200 lines) to more recent applications (1000 lines), my scripts became a bit more complex, using .TXT files to store a database describing civil engineering structures for example.

What I need to do now
Now I have a more complex project. I need to develop a “toolbox” for an engineer to start from its calculation results (.TXT files) and create with rhino a parametric reinforcement model of a building, and then export it to TEKLA, for draftsmen to take over detailed drawings. See above for more details.

What kind of help do I need
I want to make sure I use an appropriate dev environment. In other words, can I just stay with separate scripts that I load one by one, or should I move to real dev environments, using Visual Studio for example.
I have never used Visual Studio but I looked at what other people did with it and it looks good :
However, I am bit afraid of loosing time on learning new langages (other than RS and Python) that would slow my dev, and I really need advice from experienced people Here. Is it worth it ?
I should also mention that the ideal for me and my company would be to contract a specific assistance with McNeel to have someone giving me advice on my coding environment and general code organization. I don’t know if this is feasable. But I would be happy to talk about it.

A hint of how I could start my project
I am not a professional dev, and here is how I think I could do it (and where I really need advice) :slightly_smiling_face:

  • write a script for each function of my toolbox
  • each script store and retrieve information in/from Rhino custom Object properties (in order to avoid maintaining a separate database using objects identidiers, which would add significant functionalities I think).

Here above are the first scripts, just to give you a hint :

This is just .TXT files containing a mesh and calculation results at mesh node points.

Visualise the mesh and the results in Rhino. This is fine with RS or Python.

This is creating series of bars. For example you create a polygon on your mesh in rhino, and then the script asks you a few parameters (bars spacing and diameter) and creates a layer with your serie of bars.

Script N : Many other functionalities, ending with reinforcement export to TEKLA

Well, if you got so far, thank you, and many thanks for your help.

Best regards,

Tanguy Prevost
Structural and Civil Engineer

1 Like

Since you are discussing building parametric geometry here, I’m just wondering if maybe you should start working in Grasshopper… There are also many extensions that can access external database kind of objects whether they be text files, excel spreadsheets or other…

Since you are already familiar with Rhinoscript you know the benefits of its easy, interactive capability to develop an idea for new functionality into working software. The resulting performance is more than adequate for automating a wide range of complex Rhino functionality so it’s a great way to work out what you’d like the function to look and work like. You working directly in Rhinoscript allows a lot of cut-and-try which is considerably less efficient and tedious when working with a third party. If performance under Rhinoscript proves inadequate the script provides a great starting point for an expert in a higher performance language.

If you would like to become personally proficient in a higher performance language environment, Visual Basic in the Visual Studio environment is an easy jump from Rhinoscript, which is just Microsoft’s VBScript adapted to Rhino. On the other hand, Python now seems to be the hot ticket for all the folks with a background like yours and is integrated into Rhino in much the same way as Rhinoscript, although neither integration is as capable and nice to use as Visual Studio.

I’m sure these remarks will bring forth a slew of better opinions from folks who have done a lot more of what you are trying to do much more recently than I.

Another thing to keep in mind is that because others have done similar things they may be able to offer you some code bits that get you started on your functions, or even functions that do what you need. Yet others may have put a lot of time into developing functions you could use directly and would make them available for a price. Certainly something to consider when contemplating the time you and your company will invest in developing your own.


I’m not sure is this what you ask for, but one question I was reading in your article deals about if its worth to invest time into becoming a more professional software developer or not.

Although you might not consider yourself of being a professional developer (but maybe you are more then you think), it will be always worth to move from a level of scripting into a level of true software development.

Let me explain why I do believe its worth the pain by pointing out just three arguments:

  1. A script basically is a good way to solve quick operations. It is great for a couple of repetive tasks, but in my oppinion any script containing more then 50 lines of code is actually a bad script.
    One argumentation is based on the so called SOLID principles, where the S stands for Single responsibility. Single responsibity basically means to encapsulate one functionality into one object/file, which again is beneficial because you can build in many of conditionals and variations and everybody still know what it does in the end, simply because it follows only one purpose.
    If you divide a software into single responsibities, it would mean you have to call dozens of scripts to get something done. What you see on a scripting level is is almost the opposite-> unreadable routines - very hard to manage on a greater scale. The rest of SOLID rather points to increase abstraction, interaction through clean interfaces, extensibity and inversion of control/dependency inversion. Something you don’t even care about when writing scripts but which are very useful concepts of structuring your code. Not to speak of using a true software architecture.

  2. I find it extremly hard to reuse script functionalities if they are not really linked to each other. So what you usually do is copy and pasting and therefore creating many unnecessary overhead, impossible to improve and extend. Basically by chosing to setup a software solution over using loose scripts is that you actually saving yourself from writing the same things over and over again by sorting things up in an overall structured manner.

  3. Scripts are hard to test and to debug, which makes them unreliable per se. A complex software needs much more effort on validation and reliability. A little script can be tested by some manual testing. However the moment your software increase in size you’ll need some sort of test automation otherwise you cannot guarantee anythink anymore. I cannot imagine nor I know a satisfying way in doing unit and integration testing on a scripting level. I also don’t know how to do good debugging if you are not using a advanced debugger, which lets you jump throughout your whole project.

… and many more

In the end you simplify your life greatly. So you should rather see it as an investment and not as an possibly-irrelevant knowledge

1 Like


@TomTom. Thank you very much for your contribution. It is actually fun to read your message, because I’ve actually lived what it looks like to try and maintain my “script”.

What my script looks like (SOLID?)
Actually I do structure my code into sub-functions that do not exceed 50 lines. So Indeed, my last projet is a 1000 lines “script” with a “main” script that call about 20 subfunctions. With a great deal of Loop in there to recognise each shape in the model and assemble shapes togetether to form real objects, and store this in a database. This took me about 2 months full time.

Where I find it hard to progress
So in the end I have a long .rvb file, with a main() that asks a few parameters, and then 20 functions, everything in the same file. I have never used VisualStudio but I suppose it lets me put every function into separate files, in order to debug everything one script by one, and also deal with different versions of these functions. But where I meet difficulty is here (I think it is very basic for real dev but it is unclear to me) :slight_smile: I have not found the proper documentation that tells me how in VisualStudio I can ask the Rhinoceros Application to execute my main script.

Actually, I think I just need a good tutorial to get me started with a real dev environment (VisualStudio?), and wether VS can tell Rhino to execute scripts in Python, VBScript… This is why I was happy at the beginning to just deal with Rhino and execute a .rvb file. But now that things are more complex, I do feel the need of a proper dev environment…

Am I correct that it’s ok for you to learn a new language for it? Just in addition to python and VB, c# could be another option. If so, Long’s tutorial is a good place to start (c# + VS).

Personally I also enjoy VS together with gh python’s code input. It’s like a live link between VS and gh.

Hello Tanguy,

I was in a similar position 3,5 years ago with a collection of several thousand lines of RhinoScript written by a colleague in half a dozen scripts. Over the course of 18 months I rewrote these in Python using the rhinoscriptsyntax module, which made it pretty easy to rewrite them. Having them in Python means I can now organise them in toolbox modules and import functions as needed for my scripts. Python supports OOP, multiple inheritance and introspection, meaning you are not limited in building professional tooling.

I recommend you think about version control as part of your planning.

Bon courage :wink:

Graham Knapp

This is indeed a problem regarding the Rhino environment. So first of all if you download Visual Studio 2017(!) you can download a so called "Rhino Wizard" from the marketplace which setups a Rhino Project for you. There is no template for VS 2019 yet. (At least from what I know). But in theory you can setup a project for yourself. This however requires some experience with Visual Studio.
There is currently one limitation using Visual Studio, which requires you to restart Rhino for any change to apply. However there are workarounds as well. Maybe you just start getting used to Visual Studio, creating a console app and a .dll at least once. There are plenty of tutorials on the internet. As I said it will be overwhelming in the beginner, but once you get a clue about how to use an ide like Visual Studio you won’t move back again.

This is not quite it. First of all 50 lines per function is not good. 50 line per file is.
Its good to write functions, but this doesn’t really fit into whats meant by single responsibility. The problem with writing everything into functions is that you basicially are limited within one function and that these functions are part of greater logical unit (the script or script object) . Better is to make it an object or module. I’ll give you an example. Saving and Loading a file is usually done inside a Serializer Object, which allows you to write and load in multiple ways, which does all the checking and which can be unit tested completly isolated. You can of course write a static save and load function instead, but it since it lives within a part of your script, it will make no sense calling this from within another script. Imagine using a BuildRoundBoxesScript and you like access The BoxSerialization function which you already implemented in the BuildJaggedBoxesScript. Calling BuildJaggedBoxesScript.Save(…) inside a BuildRoundBoxesScript is Spaghetti coding at its finiest. Instead calling the BoxSerializer.Write(…) makes more sense.

[Oddly, the open source project Code Aster / Salmome Mecha has finite element simulations for concrete cracking, and I think I saw something that can model rebar rusting. EDF has used it for their nuclear containment. Though…it’s in French, as in “mallage” means “mesh”]

Hi everyone,
I have carufully read your responses and I still have a few questions concerning the choice of my dev environment :slight_smile:

  1. @Dancergraham : what exactly do you mean by “toolbox module” ? Are we talking about a serie a python files, each file containing one or several functions ? Do you have to put all these file under the same folder ? Anyway, I would be very keen to have a look at how you organised your scripts, and how I can best take advatage of OOP, since I think our application fields ar very similar (finite elements post-processing). Also, do you use custom GH components ? And does the (python-files-refering-one-to-another) method still works the same with GH custom components ?

  2. @TomTom : For a start, could I use VS just to deal with a serie of python scripts, containing functions/methods and object types définitions, that all together form the parts I need for my project ?

  3. @TomTom : Let us say that I have all my python scripts that work all together, that I took best advantage of creating object types and methods, will it change that in the end the user loads a python “main” script ?

Thank you,

@tim.stark : Hi Tim, If possible, could you give me some more details about this method ? Are there any tutorial or general documentation that you would recommend to get me started with the VS / Python method ? And how does it work for the user ?

I don’t have much time to make a video or something like that, but I try to describe it as good as possible.

First of all you need to install python and the rhino api in visual studio.

Now you can code in VS and safe it. For example:

Go to GH and place the python component. Right click on the symbol and choose: “Show code input parameter”. Place a “file path component” and “read file” (total file) and connect it:

“Set one file path” to the previously in VS saved python file:

Now your python components reads everything you write in that file:

As soon as you safe the VS python file, the gh python component gets updated:

@Tim : Thanks a lot. This answers a great deal to my initial problem. I will look for how to install VS and the rhino API right away.

But you are now just back on scripting level. You basically just replaced the editor. You now also have Grasshopper in between which is in my oppinion a total wrong approach with an much lower level of access.

I would set it up the other way.You create a piece of core logic in a plugin/software project creating two interfacing libraries which are storing Grasshopper Components and Rhino Commands each.

1 Like

I don’t think you max out the potential of Visual Studio using IronPython. I can only warn you in using IronPython if you are not knowing C#, C++ or VB[.]Net well enough!

Sure Python works with modules and you can use them from anywhere.

You are right, he’s just changing the editor. But he could use it to easily debug and if he finished everything he could still create a plugin with the rh6 python editor.
Yes I would reccomend doing it in c# instead, but in my opinion python is easier to learn.

1 Like

Basically I’m just warning to use IronPython, because its a Python derivative written in C# to deal with a very unpythonic framework. The frustration level can quickly rise if you deal with some more advanced dotnet concepts, which actually questions the statement “easier to learn”. Not to speak of the defacto absence of documentation on IronPython. On CPython I would even agree on that statement, but since I’m arguing about moving a bit apart from the scripting context, I personally find IronPython not the best starting point. And being someone knowing both languages quite well, I would always advice to take a bit of extra pain when working within the Rhino Environment. Or simply learn both…

1 Like

@tim.stark and @TomTom
Thank you for the advice. Well, it sounds obvious now that maybe I didn’t give enough context, so I will give a few information that could maybe help you give me the good direction :slight_smile:

The arguments for C#

  1. It looks like it is the thing to learn if I want to progress with Rhino coding. But from what I’ve seen it would take me a few days and many questions to the forum to understand what is going on in this article here, that has tempted me a few times…
  2. I’ve learned Java during my studies, and when I look at C# or C++ coding syntax I am not afraid :sweat_smile:. I use VBA for about 8 years now quite often (which is why I started Rhino coding with VBScript), and I always use Option Explicit, declaring variable types, even declaring object types.
  3. So why not “jump” to coding in a real dev environment like VS and C# (what is the difference with C++ by the way).
  4. I feel like proper Rhino documentation only exists in RhinoCommon C++.

The arguments for Scripting (Python and VBScript)

  1. I wil get started easily, but I agree this is not a big argument
  2. I have a gifted colleague who could help me with it when in trouble, and indicate what good libraries I could use.
  3. Python documentation for Rhino is not really good I think, but I can Always relly on VBScript functions documentation that I find quite OK.

In order to give you an idea of how I code, here is an example. You can run the script and select the text file attached.
Txt_To_Rhino_2019.06.19.rvb (5.9 KB)
Essai 08 Juillet.txt (48.0 KB)

All you need to do is downloading Visual Studio and these templates (they are also runnning on vs2019 now):

They already include an example each

This is the Rhinocommon api sdk:

All you need to do is build and run