Thursday, February 19, 2015

Python Rocks!!

Few months ago, I've created a membrane simulator using formulas and AC family as below.

It looks working pretty well.  Actually, The membrane can't maintain 100%  accurate length. I wanted to find a formula to make it, but failed. The one at the video can maintain just approx length. :(

After knowing Dynamo and Python, I challenged it again.

Rope Simulator

In Revit, there is no way to make a NurbsCurve to have assigned length. All you can do is just measuring length of curves which are already created. Of course there are some complex formulas about spline, such as below

p=p(u)= p(1- 3u+ 2u3 )+ p1(3u- 2u3 )+ p0(u- 2u+ u3 )+ p1' (- u+ u3 ) 

I could use it if I were a mathematician, but I'm not. :(

So, I wrote a Python code instead.

My first Python code
This simple Python code gave me a NurbsCurve from given two points and curve length as below.

This code can be a start point of certain computational design like an example below.

With Python, I'm sure you can go even further than someone without it.

You can use my code if you want.

Enjoy. :)

PS. Please don't judge my dumb code. It's my first one. At least it works. :)
       It will be appreciated if you suggest any better one.