Grasshopper

algorithmic modeling for Rhino

# Parametric Translation

Hi everyone,

Private Sub RunScript(ByVal brep As Brep, ByVal vector As List(Of Vector3d), ByRef A As Object)
Dim breps As New List(Of Brep)
Call translate(breps, brep, vector)
A = breps

End Sub

Sub translate(ByRef breps As List(Of Brep), ByVal brep As Brep, ByVal vector As List(Of Vector3d))
If breps.Count() > vector.Count() Then Exit Sub
Dim v0 As New Vector3d
Dim count As Integer
count = vector.Count()
For i As Integer = 0 To count - 1
v0 = vector(i)
brep.translate(v0)
i = i + 1
Next
Call translate(breps, brep, vector)
End Sub

Views: 575

Replies are closed for this discussion.

### Replies to This Discussion

you've created a recursive function with no way out! The subroutine "Translate" calls the subroutine "Translate" which calls the subroutine "Translate" which calls the subroutine "Translate" which calls the subroutine "Translate" which calls the subroutine "Translate" which calls the subroutine "Translate" which calls the subroutine "Translate" which calls the subroutine "Translate" which calls the subroutine "Translate" which calls the subroutine "Translate".... you get the picture.

It would be helpful to give an explanation of what you're trying to do so we can make suggestions about how to accomplish it.

Here's the idea,

First we got one box(green box) and a list of tangent vectors. The idea is moving this box by its own tangent vector on the curve.(white box) and this "new" box generates the next one by its own tangent vector on the curve... and this happens to the last item. Here's the algorithm:

B0 ----> B1

B1 ----> B2

B2 ----> B3

B3 ----> B4

...

So where does the curve come in? Your code does not mention any curves, only a list of vectors, which are inputted and therefore known ahead of time.

I also don't see the need to both iterate and recurse. Surely if you have a list of vectors all you need is iteration?

`Private Sub RunScript(ByVal G As GeometryBase, ByVal v As List(Of Vector3d), ByRef A As Object)   Dim geometry As New List(Of GeometryBase)  For i As Integer = 0 To v.Count - 1    'Duplicate the geometry because you kept    'transforming the same one over and over.    G = G.Duplicate()    G.Translate(v(i))    geometry.Add(G)  Next A = geometryEnd Sub`

--

David Rutten

david@mcneel.com

Dear David,
This is the whole idea:

Yes, I think I need Iteration. Thank you so much. ;)

You could achieve the same using Mass Addition btw. and hooking up a Move component to the Pr output.

--

David Rutten

david@mcneel.com

Thank you! :) I appreciate your help.

Dear David,

This is my last try. This definition supposed to be working. I dont' know what to do. please help! :( thx

Attachments:

by jodyc111

• View All