Grasshopper

algorithmic modeling for Rhino

Vb script should I use an array or List of List is fine.

B

VB question help more than welcome.

First question which is the difference between

Dim Pt as New OnPoint3d or Dim Pt as New Point3d

Second question, I have a list of curve and a list of point, I am searching for each curve which of those point are contain inside of the curve. The script doesn't throw an error but i can not get the point for each curve..from it... help more than welcome..thanks!

RunScript(ByVal listpt As List(Of Point3d), ByVal crv As List(Of Curve), ByRef A As Object

Dim ptarr As New List(Of List(Of Point3d))

For j As int32 = 0 To crv.count - 1

Dim ptlist As New List(Of Point3d)

For i As int32 = 0 To listpt.count - 1

Dim crvtemp As Curve = crv.item(j)

Dim pt As New Point3d pt = listpt.item(i)

If crvtemp.Contains(pt) = PointContainment.Inside Then ptlist.add(pt)

End If

Next

ptarr.Add(ptlist)

Next

A = ptarr

thankssssssssss

Views: 1292

Replies to This Discussion

1) The prefix "On" hints at the type being part of the OpenNURBS namespace. Point3d is part of RhinoCommon namespace. As GH is built upon RhinoCommon you should always use Point3d

2) I'm more of a C# guy and my last VB project is way back but as far as i can see, the output of the VB component only likes Lists. List of List isn't translated into a tree. Have a look in the VB section. Surely there is a proper way to construct trees (Lists of List) in VB scripts.

Instead of Lists of List use the DataTree type.

Other than that you scrips seems to work.

One more question though. Any reason for not going this way:

Dear Hannes, Actually I didn't went that way because I am not that good a list and culls at gh. How I could extract the info to list of list of point from the cull component...If you have time could you explain me a little more your way...I tried but it doesn't work...thanks!

Best to get a little more comfortable with lists and datatrees as that is what Grasshopper is all about.

What above def. does is create trimmed surfaces from the curves. Then it tests each point for trim inclusion on the surfaces. The output will be a list of boolean values that indicates whether a point is inside the curve or not.

CullPattern removes items from a list according to a pattern of boolean values. If the value indicates true, the item is removed. So as you want to keep all points inside the curves, the Trim inclusion values need to be inversed. This is what the NotGate does. Each true becomes false and the other way around.

Now for the hard part. You actually want to do this with a number of curves where i used only on. You are familliar with lists of list so you should be able to understand the concept of datatrees. A list of list is basically a tree with one branching level. Each sublist is called a branch.

GH matches input lists at the same branching level. Normally the trim component gets two lists. one of curves and one of points. It will match up items and according to list logic will test point1 on curve1, point2 on curve2 and so on. if one list is shorter, the last item will be repeated until both lists are done.

You want to test all points on each curve. Here is where Grafting comes into play. A graft transforms a list to a tree, where each list item becomes a branch. You need to graft the curves. This will give you a tree with a branch for each curve. Each branch is alist containing only one item.

Now Grasshopper has multiple lists to evaluate (one for each branch) it will call the TrimInclusion for each curve (list) and try to match up a list of points. The points still are a single list and so GH will use this list for each of the curves tree branches. (the single curve in each branch is repeated for test for every point as shown above).

The output will match the operational complexity. As GH calls the component for a tree, the output will be a tree. In your case, this is a list (for each curve tree branch) of a list (for each point) of boolean values.

Cull works in a similar way. Now natching the complexity of the boolean pattern. you will end up with a tree where each branch contains the included points for each respective curve.

One thing I realized while I wrote all of the above is that TrimInclusion needs UV coordinates on the suface to test and not 3d points. So you have to make sure the input are valid UV for the surface. This will make the def considerably more complex.

That said, a script is the more elegant way as you don't even need to create the surfaces but can work on the curves right away.

this defThis def here makes use of the SurfaceCloserPoint component. It projects the points onto the surface and returns the UV coordinates and the distance of the original point to the surface. It's safe to assume that points withing the trim curve are on the surface (within document tolerance). Testing the distances against tolerance will again return a boolean pattern to use as culling guide.

Thanks very very much..for your time and help

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service