Forgot password?

Create an account!

Forum

« back

RhinoScript – Help with Merger Sponge

Messages

Please log in to write a message.

  • 3. mauro (Sep 30, 2012 19.12):

    This is Great!!
    Thanks

  • 2. Johannes (Sep 28, 2012 11.24):

    Hi, a nice script!

    I wrote the Sierpinski dance new... now it works in all dimensions.

            Call MakeSierpinski(Array(arrCenter(0)+dblWidth/3, arrCenter(1)+dblWidth/3 ,arrCenter(2)+dblWidth/3),dblThirdWidth,intGen-1)
                    Call MakeSierpinski(Array(arrCenter(0), arrCenter(1)+dblWidth/3 ,arrCenter(2)+dblWidth/3),dblThirdWidth,intGen-1)
                    Call MakeSierpinski(Array(arrCenter(0)-dblWidth/3, arrCenter(1)+dblWidth/3 ,arrCenter(2)+dblWidth/3),dblThirdWidth,intGen-1)
                    Call MakeSierpinski(Array(arrCenter(0)+dblWidth/3, arrCenter(1),arrCenter(2)+dblWidth/3),dblThirdWidth,intGen-1)
                    Call MakeSierpinski(Array(arrCenter(0)-dblWidth/3, arrCenter(1),arrCenter(2)+dblWidth/3),dblThirdWidth,intGen-1)
                    Call MakeSierpinski(Array(arrCenter(0)+dblWidth/3, arrCenter(1)-dblWidth/3 ,arrCenter(2)+dblWidth/3),dblThirdWidth,intGen-1)
                    Call MakeSierpinski(Array(arrCenter(0), arrCenter(1)-dblWidth/3 ,arrCenter(2)+dblWidth/3),dblThirdWidth,intGen-1)
                    Call MakeSierpinski(Array(arrCenter(0)-dblWidth/3, arrCenter(1)-dblWidth/3 ,arrCenter(2)+dblWidth/3),dblThirdWidth,intGen-1)
                    Call MakeSierpinski(Array(arrCenter(0)+dblWidth/3, arrCenter(1)+dblWidth/3 ,arrCenter(2)),dblThirdWidth,intGen-1)
                    Call MakeSierpinski(Array(arrCenter(0)-dblWidth/3, arrCenter(1)+dblWidth/3 ,arrCenter(2)),dblThirdWidth,intGen-1)
                    Call MakeSierpinski(Array(arrCenter(0)+dblWidth/3, arrCenter(1)-dblWidth/3 ,arrCenter(2)),dblThirdWidth,intGen-1)
                    Call MakeSierpinski(Array(arrCenter(0)-dblWidth/3, arrCenter(1)-dblWidth/3 ,arrCenter(2)),dblThirdWidth,intGen-1)
                    Call MakeSierpinski(Array(arrCenter(0)+dblWidth/3, arrCenter(1)+dblWidth/3 ,arrCenter(2)-dblWidth/3),dblThirdWidth,intGen-1)
                    Call MakeSierpinski(Array(arrCenter(0), arrCenter(1)+dblWidth/3 ,arrCenter(2)-dblWidth/3),dblThirdWidth,intGen-1)
                    Call MakeSierpinski(Array(arrCenter(0)-dblWidth/3, arrCenter(1)+dblWidth/3 ,arrCenter(2)-dblWidth/3),dblThirdWidth,intGen-1)
                    Call MakeSierpinski(Array(arrCenter(0)+dblWidth/3, arrCenter(1) ,arrCenter(2)-dblWidth/3),dblThirdWidth,intGen-1)
                    Call MakeSierpinski(Array(arrCenter(0)-dblWidth/3, arrCenter(1) ,arrCenter(2)-dblWidth/3),dblThirdWidth,intGen-1)
                    Call MakeSierpinski(Array(arrCenter(0)+dblWidth/3, arrCenter(1)-dblWidth/3 ,arrCenter(2)-dblWidth/3),dblThirdWidth,intGen-1)
                    Call MakeSierpinski(Array(arrCenter(0), arrCenter(1)-dblWidth/3 ,arrCenter(2)-dblWidth/3),dblThirdWidth,intGen-1)
                    Call MakeSierpinski(Array(arrCenter(0)-dblWidth/3, arrCenter(1)-dblWidth/3 ,arrCenter(2)-dblWidth/3),dblThirdWidth,intGen-1)

    Would be nice to see that script in our script library!!!
    Think about using block definitions instead of 8.000 polysurfaces. They all look the same.

    regrads
    johannes

  • 1. mauro (Sep 28, 2012 07.03):

    Can Somebody please help figuring out what I do wrong?
    The Script works only on face of the Cube.

    Thank you


    Call Main()
    Sub Main()
    ' start recursion
    Dim arrCenter
    arrCenter = Array(0,0,0)

    Dim dblWidth
    dblWidth = 10
    Dim intGen
    intGen = 3


    Rhino.EnableRedraw(False)

    Call MakeSierpinski (arrCenter,dblWidth,intGen)


    Rhino.EnableRedraw(True)
    End Sub

    Sub MakeSierpinski (arrCenter,dblWidth,intGen)

    If (intGen<1) Then
    'draw a rectangle

    Call AddCube(arrCenter,dblWidth)

    Else
    ' Recurse
    Dim dblThirdWidth
    dblThirdWidth = dblWidth/3


    'Upper layer
    Call MakeSierpinski(Array(arrCenter(0)-dblWidth/3, arrCenter(1)+dblWidth/3 ,arrCenter(2)+dblWidth/3),dblThirdWidth,intGen-1)
    Call MakeSierpinski(Array(arrCenter(0), arrCenter(1)+dblWidth/3, arrCenter(2)+dblWidth/3),dblThirdWidth,intGen-1)
    Call MakeSierpinski(Array(arrCenter(0)+dblWidth/3, arrCenter(1)+dblWidth/3, arrCenter(2)+dblWidth/3),dblThirdWidth,intGen-1)
    Call MakeSierpinski(Array(arrCenter(0)-dblWidth/3, arrCenter(1), arrCenter(2)+dblWidth/3),dblThirdWidth,intGen-1)
    'Call MakeSierpinski(Array(arrCenter(0),arrCenter(1), arrCenter(2)+dblWidth/3),dblThirdWidth,intGen-1)
    Call MakeSierpinski(Array(arrCenter(0)+dblWidth/3 ,arrCenter(1), arrCenter(2)+dblWidth/3),dblThirdWidth,intGen-1)
    Call MakeSierpinski(Array(arrCenter(0)-dblWidth/3, arrCenter(1)-dblWidth/3, arrCenter(2)+dblWidth/3),dblThirdWidth,intGen-1)
    Call MakeSierpinski(Array(arrCenter(0), arrCenter(1)-dblWidth/3 ,arrCenter(2)+dblWidth/3),dblThirdWidth,intGen-1)
    Call MakeSierpinski(Array(arrCenter(0)+dblWidth/3, arrCenter(1)-dblWidth/3, arrCenter(2)+dblWidth/3),dblThirdWidth,intGen-1)
    'Middle Layer
    Call MakeSierpinski(Array(arrCenter(0)-dblWidth/3, arrCenter(1)+dblWidth/3, arrCenter(2)),dblThirdWidth,intGen-1)
    Call MakeSierpinski(Array(arrCenter(0), arrCenter(1)+dblWidth/3, arrCenter(2)),dblThirdWidth,intGen-1)
    Call MakeSierpinski(Array(arrCenter(0)+dblWidth/3, arrCenter(1)+dblWidth/3, arrCenter(2)),dblThirdWidth,intGen-1)
    Call MakeSierpinski(Array(arrCenter(0)-dblWidth/3, arrCenter(1), arrCenter(2)),dblThirdWidth,intGen-1)
    'Call MakeSierpinski(Array(arrCenter(0), arrCenter(1), arrCenter(2)),dblThirdWidth,intGen-1)
    Call MakeSierpinski(Array(arrCenter(0)+dblWidth/3, arrCenter(1), arrCenter(2)),dblThirdWidth,intGen-1)
    Call MakeSierpinski(Array(arrCenter(0)-dblWidth/3, arrCenter(1)-dblWidth/3, arrCenter(2)),dblThirdWidth,intGen-1)
    Call MakeSierpinski(Array(arrCenter(0), arrCenter(1)-dblWidth/3, arrCenter(2)),dblThirdWidth,intGen-1)
    Call MakeSierpinski(Array(arrCenter(0)+dblWidth/3, arrCenter(1)-dblWidth/3, arrCenter(2)),dblThirdWidth,intGen-1)

    Call MakeSierpinski(Array(arrCenter(0)-dblWidth/3, arrCenter(1)+dblWidth/3, arrCenter(2)-dblWidth/3),dblThirdWidth,intGen-1)
    Call MakeSierpinski(Array(arrCenter(0), arrCenter(1)+dblWidth/3, arrCenter(2)-dblWidth/3),dblThirdWidth,intGen-1)
    Call MakeSierpinski(Array(arrCenter(0)+dblWidth/3, arrCenter(1)+dblWidth/3, arrCenter(2)-dblWidth/3),dblThirdWidth,intGen-1)
    Call MakeSierpinski(Array(arrCenter(0)-dblWidth/3, arrCenter(1), arrCenter(2)-dblWidth/3),dblThirdWidth,intGen-1)
    'Call MakeSierpinski(Array(arrCenter(0), arrCenter(1), arrCenter(2)-dblWidth/3),dblThirdWidth,intGen-1)
    Call MakeSierpinski(Array(arrCenter(0)+dblWidth/3, arrCenter(1), arrCenter(2)-dblWidth/3),dblThirdWidth,intGen-1)
    Call MakeSierpinski(Array(arrCenter(0)-dblWidth/3 ,arrCenter(1)-dblWidth/3, arrCenter(2)-dblWidth/3),dblThirdWidth,intGen-1)
    Call MakeSierpinski(Array(arrCenter(0), arrCenter(1)-dblWidth/3, arrCenter(2)-dblWidth/3),dblThirdWidth,intGen-1)
    Call MakeSierpinski(Array(arrCenter(0)+dblWidth/3, arrCenter(1)-dblWidth/3 ,arrCenter(2)-dblWidth/3),dblThirdWidth,intGen-1)

    End If

    End Sub


    Function AddCube(arrCenter, dblWidth)

    Dim strCube
    Dim dblHalfWidth
    dblHalfWidth = dblWidth/2

    strCube = Rhino.AddBox(Array(_
    Array(arrCenter(0)-dblHalfWidth,arrCenter(1)-dblHalfWidth,arrCenter(2)-dblHalfWidth),_
    Array(arrCenter(0)+dblHalfWidth,arrCenter(1)-dblHalfWidth,arrCenter(2)-dblHalfWidth),_
    Array(arrCenter(0)+dblHalfWidth,arrCenter(1)+dblHalfWidth,arrCenter(2)-dblHalfWidth),_
    Array(arrCenter(0)-dblHalfWidth,arrCenter(1)+dblHalfWidth,arrCenter(2)-dblHalfWidth),_
    Array(arrCenter(0)-dblHalfWidth,arrCenter(1)-dblHalfWidth,arrCenter(2)+dblHalfWidth),_
    Array(arrCenter(0)+dblHalfWidth,arrCenter(1)-dblHalfWidth,arrCenter(2)+dblHalfWidth),_
    Array(arrCenter(0)+dblHalfWidth,arrCenter(1)+dblHalfWidth,arrCenter(2)+dblHalfWidth),_
    Array(arrCenter(0)-dblHalfWidth,arrCenter(1)+dblHalfWidth,arrCenter(2)+dblHalfWidth)_
    ))

    AddCube = strCube

    End Function

Recommend

Why are these buttons gray?