Previous Posts
» Pummelo-ed
» 1/6 Scale
» E8 Tees!
» Breadboard Crumbs
» Hello from Fermilab!
» ! blondegeek store closed for summer !
» Microwave Popcorn Smoke Signals
» I promise I'm not ignoring you...
» Something punny...
» Russian Soaps and Non-Russian Soup.



Subscribe to this blog! or Add to your Google homepage!

Tuesday, January 18, 2011

First RhinoScript!!!

I'm currently in studio working on an exercise due tomorrow. In our prior assignment we created a drafting instruction set, that our studio mates executed.


Now we have to interpret the drawing and create 3D shapes. In the process of doing so, I discovered that it was vital that I learn RhinoScript. Turns out it has little to no syntax and you don't have to declare the type of your variables. Gotta admit, I still keep putting ";"s at the end of lines. C++ habits die hard.

Anyway, here's my little script that turns the lines on the page into boxes, conserving a constant perimeter from box to box. It needs some tweaking to become architecturally fluent, but hey a first script is a first script.

Option Explicit
'Script written by blondegeek
'Script version Tuesday, January 18, 2011 9:37:11 AM

Call Main()
Sub Main()
Dim arrObjLines, strObjLines
Dim dblPerimeter, dblOffset
Dim dblLength, dblHeight
Dim arrObjStart, arrObjEnd
Dim strObjRectangle
Dim arrObjNewStart, arrObjNewEnd
Dim arrPlanarPoints,arrParam
Dim PlanarFace
Dim normalvec, normalvecnorm
Dim modifier
Dim X,Y,Z
Dim PathLine

arrObjLines = Rhino.GetObjects("Select Lines to apply rule to.",4,True,True,True)
dblPerimeter = Rhino.GetReal("Set limit perimeter")
dblOffset = Rhino.GetReal("Enter Offset.")

For Each strObjLines In arrObjLines
dblLength = Rhino.CurveLength(strObjLines)
dblHeight = (dblPerimeter-2*dblLength)/2
arrObjStart = Rhino.CurveStartPoint(strObjLines)
arrObjEnd = Rhino.CurveEndPoint(strObjLines)

arrObjNewStart = arrObjStart
arrObjNewStart(2) = arrObjNewStart(2) + dblHeight
arrObjNewEnd = arrObjEnd
arrObjNewEnd(2) = arrObjNewEnd(2) + dblHeight

arrPlanarPoints = array(arrObjStart, arrObjEnd, arrObjNewEnd, arrObjNewStart)
PlanarFace = Rhino.AddSrfPt(arrPlanarPoints)

arrParam = Rhino.SurfaceClosestPoint(PlanarFace, arrObjStart)
normalvec = Rhino.SurfaceNormal(PlanarFace,arrParam)
X = normalvec(0)
Y = normalvec(1)
Z = normalvec(2)
modifier = dblOffset/(X^2+Y^2+Z^2)^(1/2)
normalvecnorm = normalvec
normalvecnorm(0) = normalvecnorm(0)*modifier+arrObjStart(0)
normalvecnorm(1) = normalvecnorm(1)*modifier+arrObjStart(1)
normalvecnorm(2) = normalvecnorm(2)*modifier+arrObjStart(2)

PathLine = Rhino.AddLine(arrObjStart,normalvecnorm)

Rhino.ExtrudeSurface PlanarFace, PathLine
Next
End Sub


Posted by Tess |


« Home | Pummelo-ed » //-->





Nice! Where's the result?

Posted by Blogger Dimitri timidimit #  

~Oo°~

Post a comment.



>> Neutrino Page
>> Design Page
>> projects 2006-2008
>> ye (olde)^2 stuff

*these will open up in different windows due to the likelyhood of ancient broken links.

Widget_logo