A playground for University of Bologna Students and a 6-days seminar about digital tools.

Digital generative tools are a very important part of architectural education. Andrew Kudless during his conference at SimAE was telling about chinese traditional woodcraftsmen: they spend their first two years of apprentice in making their own tools. Today, we have a large pool of digital ready made tools, built to respond to more or less specific problems or tasks, while keeping a level of flexibility and personalization. The majority of these tools have hidden capabilities, which can only be accessed bypassing the conventional interface and getting close to the machine logic of programming or building parametric components which generate shapes. Thus, seriality, differentiation, complexity can be implemented in architectural projects through code, in order to exploit the power of algorithmic based complex systems which are the basis of biological systems.


But, before going through such complexity, we must start with simple tasks and simple rules. Before playing seriously we need practice. This is the playground where a bunch of students will start to practice, a pool where they will share their results and questions. Maybe the stuff here that will be posted will seem obvious or naive to the navigated code-monkey, but, as I mentioned before, we all start from the basics and this is intended as a place to start. However, any comment and contribution is appreciated.

Playground is open, let's play! _ Alessio
Showing posts with label RhinoScript. Show all posts
Showing posts with label RhinoScript. Show all posts

25.5.09

honeycumb

Hi guys! Before studying Vink's exeples about texturing I tryed to create an honeycumb surface. It is only a simple test and probably I didn't follow the better way for create an Hexagon grid. In future I'll optimize this, may be using rules like attractors or surface curvature...

(sorry for comments, but is only a draft, and coding is simple to understand)


[EDIT]

well, I modified the code revising some errors (like problems with closed surfaces, not completly solved). I also insert comments. I hope it's clear now... ;-)


[/EDIT]

[EDIT]

I also added a diagram for better explain meaning of formulas with sin() and cos() ;-)


[/EDIT]


Option Explicit
' Script written by Alessandro Zomparelli
' alessandro.zomparelli@gmail.com
' http://alessandrozompa.altervista.org/
' Script version sabato 9 maggio 2009 17.11.41

Call Main()
Sub Main()
Call Rhino.EnableRedraw(False)

Dim strSrf, u, v, arrParC, arrUdom, arrVdom, s, u1, v1
ReDim arrParC(1)
strSrf = Rhino.GetObject("pick target surface")
u1 = Rhino.GetInteger("number of U subdivision", 10, 2)
v1 = Rhino.GetInteger("number of V subdivision", 10, 2)

'we are trying to define a grid for drawing hexagons,
'For Do this we need to define the unit parameter to whom refer coordinates:
'For example I choose the radius of circle in whom hexagon is inscribed
'Now we evaluate the number of radius needed for drawing the choosen number of hexagons
v = v1*2*sin(ToRadians(60))
u = u1*(1+cos(ToRadians(60)))

'Here we ask to user the scale of holes
s = Rhino.GetReal("scale value for holes", 0.5, 0.1, 1)

arrUdom = Rhino.SurfaceDomain(strSrf, 0)
arrVdom = Rhino.SurfaceDomain(strSrf, 1)

Dim arrPts, i, j, arrPtsE, arrPtM
ReDim arrPts(3), arrPtsE(6), arrPtM(2)


'now I define the parameter to use for conversion from xy units to uv
Dim parU, parV
parU=(arrUdom(1)-arrUdom(0))/u
parV=(arrVdom(1)-arrVdom(0))/v

For i=0 To u1/2-1
For j=0 To v1-1

'center of hexagon A
arrParC(0) = 2*i*parU*(1+cos(ToRadians(60)))
arrParC(1) = j*parV*2*sin(ToRadians(60))

'drawing hexagon
Call Hexagon(strSrf, parU, parV, arrParC, arrPtsE)
'creating panels
Call Panel (strSrf, arrParC, arrPtsE, s)

'center of hexagon B
arrParC(0) = 2*(i+0.5)*parU*(1+cos(ToRadians(60)))
arrParC(1) = (j+0.5)*parV*2*sin(ToRadians(60))
'drawing hexagon
Call Hexagon(strSrf, parU, parV, arrParC, arrPtsE)
'creating panels
Call Panel (strSrf, arrParC, arrPtsE, s)
Next
Next
Call Rhino.DeleteObject(strSrf)
Call Rhino.EnableRedraw(True)

End Sub

Sub Hexagon (strSrf, parU, parV, arrParC, arrPtsE)
Dim i, strExa
ReDim arrPtsE(6)
For i=0 To 6
'coordinates of vertex related to local center
arrPtsE(i)=Rhino.EvaluateSurface(strSrf, array(arrParC(0)+cos(i*ToRadians(60))*parU,arrParC(1)+sin(i*ToRadians(60))*parV))
Next
End Sub

Sub Panel (strSrf, arrParC, arrPtsE, s)
Dim strExa, strIn, arrPtM, arrPlane
strExa=Rhino.AddPolyline(arrPtsE)
strIn=Rhino.AddPolyline(arrPtsE)
arrPlane=Rhino.SurfaceNormal(strSrf,arrParC)
If isnull (arrPlane) Then Exit Sub
arrPtM=Rhino.EvaluateSurface(strSrf,arrParC)
Call Rhino.ScaleObject(strIn, arrPtM, (array(s,s,s)))
Call Rhino.MoveObject(strIn,arrPlane)
Call Rhino.AddLoftSrf(array(strExa,strIn))
Call Rhino.DeleteObjects(array(strExa,strIn))
End Sub

2.5.09

Interpolation function

In a discussion on the Grasshopper Google Group, David Rutten (btw... whenever you read, hear or pronounce this name please join hands as in prayer and say "Thank you, Zen master!"), as I said, David Rutten (repeat) has posted a useful and easy to implement function for interpolation. Here's the text extracted from the discussion:

there's a good function that always works when interpolating linearly between two tensors (be they numbers, vectors, points... any kind of data that can be blended).

If you have 2 values (A & B) and you want to interpolate between them at f (a blending factor), the function is always:

R = A + f * (B-A)

For example, let's fill in a few numbers and see what happens... Let's assume we want to find the value one quarter along the way between 15 and 19:

R = 15 + 0.25 * (19-15)
R = 16

Or, let's go twice beyond two points {10, 10, 0} and {12, 15, 4}

R = {10, 10, 0} + 2.0 * ({12, 15, 4} - {10, 10, 0})
R = {10, 10, 0} + 2.0 * ({2, 5, 4}) <---- if you subtract two points you get the vector going from A to B R = {10, 10, 0} + {4, 10, 8} R = {14, 20, 8}

This function is handy because it works without division (no division by zero errors), it works well when A is larger than B and it works for every value of f (i.e. you can also use it to extrapolate).

Well, nothing really new to those of you guys who followed the seminar, we talked and applied a lot of interpolations as a basic task of implementing gradients at different levels of discretization, but I think Rutten explains it very straightforward so it might be useful to have it as a reminder. Now go and apply it to any attractor/repellor/blend case you might undergo from now on.

13.4.09

Easter Egg



This is just for laughs, nothing serious, ok? Had some fun doing this small Easter Script.

1. Create a sphere in Rhino and stretch its control points to turn it into an egg

2. run the script below

3. Happy Easter!

Here's the script:

Option Explicit

'
'
'
' . Easter Stripe Egg
' . script written by Alessio Erioli
' .
' . v. 12 April 2009 + 22:05:27
' . © Alessio Erioli
' . monkey Rulez, so play by the rulez.
'____________________________________________________________________________________

Call Easteregg()

Sub Easteregg()

' input surface and division intervals

Dim strSurf: strSurf=Rhino.GetObject("select a surface",8)

' vertical subdivision intervals (<=200, otherwise sweep fails)

Dim intVInt: intVInt=Rhino.GetInteger("n. of V intervals?",200,10)

'lights off!

Rhino.EnableRedraw False

' get surface domain (u and v)

Dim arrUdom,arrVdom, zminPt, zmaxPt

arrUdom = Rhino.SurfaceDomain(strSurf,0)

arrVdom = Rhino.SurfaceDomain(strSurf,1)

' get zmin and zmax points

zminPt=Rhino.EvaluateSurface(strSurf,array(arrUdom(0),arrVdom(0)))

zmaxPt=Rhino.EvaluateSurface(strSurf,array(arrUdom(0),arrVdom(1)))

Dim i, inc, angInc, ang, arrPt, arrPt2, vect, strCrv

Dim arrPts: ReDim arrPts(intVint)

' hetght and angle increments

inc = (zmaxPt(2)-zminPt(2))/intVint

angInc = 180/5

ang = 0

For i = 0 To IntVint

' point along vertical

arrPt= array (zminPt(0),zminPt(1),zminPt(2)+(i*inc))

' second point for vector construction

arrPt2 = array (zminPt(0)+1,zminPt(1),zminPt(2)+(i*inc))

' vector construction and rotation

vect= Rhino.VectorCreate(arrPt, arrPt2)

vect=Rhino.VectorRotate(vect,ang+i*angInc,array(0,0,1))

' projects point to surface

arrPts(i)=Rhino.ProjectPointToSurface(arrPt,strSurf, vect)(0)

If Isnull(arrPts(i)) Then

arrPts(i)=arrPt

End If

Next

' create base curve

strCrv = Rhino.AddInterpCurve(arrPts,3)

Dim arrPlane,arrCircles, dblrad

ReDim arrCircles(intVint)

' create circular sections along curve

For i=0 To intVint

arrPlane=Rhino.CurvePerpFrame(strCrv,Rhino.CurveClosestPoint(strCrv,arrPts(i)))

dblrad=sin(i*pi/intVint)+0.001

arrCircles(i)=Rhino.AddCircle(arrPlane,dblrad)

Next

' add a sweep 1 rail surface

Call Rhino.Addsweep1(strCrv, arrCircles)

' hide unnecessary elements

Rhino.HideObject strCrv

Rhino.HideObject strSurf

Rhino.HideObjects arrCircles

' lights on!

Rhino.EnableRedraw True

End Sub

2.4.09

Rhinoscript new release

A new version of Rhinoscript is available for download, in order to accomplish the changes and fixes of Rhino 4.0 SR 5.

Download it from RhinoLabs page:

http://en.wiki.mcneel.com/default.aspx/McNeel/RhinoScriptLabs.html

7.2.09

RhinoScript SR5

Rhinoscript plug-in has updated to compliant version SR5.0. You can download it here.

From RhinoScript Labs:

New Methods

  • AddPlanarMesh - Creates a planar mesh from a closed, planar curve.
  • BoxMorphObject - Bounding box morphs an object.
  • CurrentDetail - Returns or changes the current detail view in a page layout view.
  • DetailNames - Returns the detail views of a page layout view.
  • DivideCurveEquidistant - Divides a curve such that the linear distance between the points is equal.
  • ExtrudeCurveTapered - Extrudes a curve to a taper.
  • IsDetail - Verifies that a detail view is on a page layout view.
  • IsLayout - Verifies that a view is a page layout view.
  • IsLayoutObject - Verifies that an object resides in either layout or model space.
  • Layer State Methods - Several new layer state methods were added.
  • ObjectLayout - Returns or changes the layout or model space of an object.
  • ProjectCurveToMesh - Projects one or more curves onto one or more meshes.
  • ProjectPointToMesh - Projects one or more points onto one or more meshes.
  • RemoveCurveKnot - Deletes a knot from a curve.
  • RemoveSurfaceKnot - Deletes a knot-line from a surface.

Changed Methods

  • AddSweep1 - Fixed closed rail curve bug.
  • AddSweep2 - Fixed closed rail curves bug.
  • MeshVertexColors - Additional, optional, argument added.
  • RenameView - Fixed a crash bug.