Grasshopper

algorithmic modeling for Rhino

I'm trying to convert a RhinoScript into VB.Net so that I can plug it into Grasshopper for a graduate studio project. I've never used scripting before, and what I am trying to do may not be possible. Here it the RhinoScript that I am using:

 

'Option Explicit

'Rem Script written by Giulio

'Rem Script version lunes, 10 de noviembre de 2008 21:00:00

'Rem This script is licenced to you under the conditions shown at

'Rem http://www.giuliopiacentino.com/this/

 

Call Main()

 

Sub Main()'starts command

 

Dim arrLfStart(),arrRxStart(), arrLfEnd(), arrRxEnd(), arrLinks(), i 'sets intergers

Dim links: links = 36 'number of cylinders (links)

 

ReDim arrLfStart(links), arrRxStart(links), arrLfEnd(links), arrRxEnd(links), arrLinks(links) 'combines integer with number

 

Dim angleDist:angleDist = Rhino.PI / 10

 

For i=0 To links 'sets integer

 

'The following sets the path

arrLfStart(i) = Array(Cos(i-angleDist)*3 + Cos(i*12)*12,  Sin(i-angleDist)*3 + Sin(i*12)*12,            i*5)

arrRxStart(i) = Array(Cos(i+angleDist)*3 + Cos(i*12)*12,                Sin(i+angleDist)*3 + Sin(i*12)*12,           i*5)

arrLfEnd(i) = Array(-Cos(i-angleDist)*3 + Cos(i*12)*12,                  -Sin(i-angleDist)*3 + Sin(i*12)*12,            i*5)

arrRxEnd(i) = Array(-Cos(i+angleDist)*3 + Cos(i*12)*12,                                -Sin(i+angleDist)*3 + Sin(i*12)*12,           i*5)

 

'The following adds cylindars according to specified points

Call Rhino.AddCylinder(IntraPts(arrLfStart(i), arrRxStart(i), 0.5), IntraPts(arrLfEnd(i), arrRxEnd(i), 0.5), 0.5)

 

Next

 

'The following adds surfaces to the path

Call Rhino.AddLoftSrf(Array(Rhino.AddInterpCurve(arrLfStart), Rhino.AddInterpCurve(arrRxStart)))

Call Rhino.AddLoftSrf(Array(Rhino.AddInterpCurve(arrLfEnd), Rhino.AddInterpCurve(arrRxEnd)))

 

End Sub

 

Function IntraPts(byRef p1, byRef p2,byRef n)

'Rem This function gives the first point out if you use n=0,

'Rem with n=1 it gives the second point.

IntraPts = Array( p1(0)*(1.0-n)+p2(0)*n, p1(1)*(1.0-n)+p2(1)*n,  p1(2)*(1.0-n)+p2(2)*n  )

End Function

I know that the script works in RhinoScript. If anyone could help me out I would appreciate it.

Views: 574

Replies to This Discussion

Absolutely no attention paid to see if the logic could be written more succinctly. You'll need a recent version of Grasshopper to open the attached file.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Attachments:
Thank you David, I appreciate you taking the time to help me out.
can you explain how to transform rhinoscript into VB?
thanks in advance
Step 1. understand RhinoScript syntax
Step 2. understand VB.NET syntax
Step 3. know what specific functions do in RhScript
Step 4. know what parallel functions exist in the SDK

There is no quick and easy way. It basically means rewriting the code in a different language.

--
David Rutten
david@mcneel.com
Poprad, Slovakia

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service