Grasshopper

algorithmic modeling for Rhino

Ok guys a bit crap issue here. I am used to vb script and not VB.net so I dont have much background in it.

I have this bit of code I can't understand. In particular I don't understand the Append function and the points array that follow. I was used to the Rhino.EvaluateSurface(Strobj, ArrParam) to pick pints on a surface.

Then I understand that points are identified with var pt and added with function pt_list.Add(pt) . But can't understand the whole syntax. This code is supposed to create hexagons!
Dim lines As New List(Of OnPolyline)()
'Point Culling

Dim ptArr As New On3dPointArray()


Dim pt_list As New List(Of On3dPoint)

For i As Int32 = 0 To u - 2 Step 2

For j As Int32 = 0 To v - 3 Step 4


ptArr.Append(arrPt(i + 1, j).x, arrPt(i + 1, j).y, arrPt(i + 1, j).z)
ptArr.Append(arrPt(i + 2, j + 1).x, arrPt(i + 2, j + 1).y, arrPt(i + 2, j + 1).z)
ptArr.Append(arrPt(i + 2, j + 2).x, arrPt(i + 2, j + 2).y, arrPt(i + 2, j + 2).z)
ptArr.Append(arrPt(i + 1, j + 3).x, arrPt(i + 1, j + 3).y, arrPt(i + 1, j + 3).z)
ptArr.Append(arrPt(i, j + 2).x, arrPt(i, j + 2).y, arrPt(i, j + 2).z)
ptArr.Append(arrPt(i, j + 1).x, arrPt(i, j + 1).y, arrPt(i, j + 1).z)
ptArr.Append(arrPt(i + 1, j).x, arrPt(i + 1, j).y, arrPt(i + 1, j).z)

Dim pline As New OnPolyline(ptArr)


lines.Add(pline)

Dim pt As New On3dPoint((arrPt(i + 1, j).x + arrPt(i + 1, j + 3).x) / 2, (arrPt(i + 1, j).y + arrPt(i + 1, j + 3).y) / 2, (arrPt(i + 1, j).z + arrPt(i + 1, j + 3).z) / 2)
pt_list.Add(pt)

ptArr.destroy

Next

Next

Views: 1431

Replies to This Discussion

Nice code :P

The points are already on the surface...its just a matter of organizing them.

Append...appends points to a point array...needed for the OnPolyline

pt_list.add(pt) ... used to return the cell points...the component gives you the points and the polylines of each cell...

This code could probably be cleaned up some ;)
HI Luis!

yes it's true the vb script take as input uv durface division! crap I should stop scripting at night :-)

What I don't understand is actually what Append does. Do you know if this is explained clearly somewhere?
1)Why do I need to append the UV points to other points array?
2) I don't actually understand how this point are organized. I can't see the logic! Can you enlight me? :-)
At least from what I'm looking at here, your issue is with how you're appending, which fundamentally extends from not knowing about the classes within the SDK. The class On3dPointArray performs a certain role, which is be a list/array that holds only On3dPoints. This means that there's a little less error checking that needs to go on, since only an On3dPoint can be in an On3dPointArray. What you're trying to do (and I'm not sure why) is to add/append the xyz coordinates into the array which will not work. Although those xyz coordinates will make a valid on3dpoint, by themselves they are NOT an on3dPoint, and therefore won't be able to be added into an On3dPointArray. Assuming that arrPt is filled with On3dPoints, then you shouldn't have a problem just passing that directly into the On3dPointArray with the Append function.

With the SDK, sometimes you will be forced to create these alternative structures and put stuff in them so that you can do what you want. Although this seams unnecessary, its really an access issue. RS is fairly no holds barred in terms of what you can supply to what. The SDK on the other hand needs you to make these constructs so that it knows that you're giving it the right information.

And as Luis said, clean up the code. Its doesn't just make it easier for people to help you, but it also makes it easier for you when you go back and look at this in 6 months.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service