algorithmic modeling for Rhino
Hi All,
I am a beginner With VB,
I trying to do a vb script component which will:
'add planes on a series of points
'intersect those planes with a Brep and create closed curves
'calculate the area of these curves.
for a better understanding please look at the image attached.
So far the scrip I have created it's only creating the point:
Private Sub RunScript(ByVal f1 As Integer, ByVal DELTAh1 As Double, ByVal Lobby1h As Double, ByRef A As Object)
Dim p As New List(Of Point3d)
Dim i As Integer
For i = Lobby1h To f1 + Lobby1h
p.Add(New Point3d(0, 0, i * DELTAh1))
Next
A = P
End Sub
Any Suggestions?
Tags:
Thanks Raul,
I appreciate your help,
What I am looking for, is actually a VB script to attach planes to point.
To make the planes you can do like this:
private void RunScript(int Start, double Delta, double End, Brep B, ref object Points, ref object Planes, ref object Areas)
{
List<Point3d> pnts = new List<Point3d>();
for (int i = Start; i < End; i++)
{
Point3d p = new Point3d(0, 0, i + Delta);
pnts.Add(p);
}
List<Plane> planes = new List<Plane>();
Vector3d v = new Vector3d(0, 0, 1);
foreach (Point3d my_pnt in pnts)
{
Plane pl = new Plane(my_pnt, v);
planes.Add(pl);
}
Points = pnts;
Planes = planes;
}
Sorry, its C# but its almost the same...
Edit : To make the planes with brep
Private Sub RunScript(ByVal B As Brep, ByVal N As Integer, ByRef A As Object)
Dim F0 As Surface = B.Faces(0)
Dim F1 As surface = B.Faces(1)
Dim P1 As Point3d = F0.PointAt(0, 0)
Dim P2 As Point3d = F1.PointAt(0, 0)
Dim Dist As Double = P1.DistanceTo(P2) / N
Dim Pl As New List(Of Plane)
For i As Integer = 0 To N Step 1
Dim Pt As New Point3d(P2.X, P2.Y, P2.Z + i * dist)
Dim V As New Vector3d(0, 0, 1)
Dim Plane As New Plane(Pt, V)
Pl.Add(Plane)
Next
A = Pl
End Sub
Thanks a lot Yasser,
just a question.
Can you tell me why you are Declare plane 2 times
1. Dim Pl As New List(Of Plane)
2. Dim Plane As New Plane(Pt, V)
One it won't be enough?
Thanks
M
Technically yes, instead of:
Dim Plane As New Plane(Pt, V)
Pl.Add(Plane)
you could write:
Pl.Add(New Plane(Pt, V))
There are however good reasons for not putting too much on a single line of code. Readability being the most important one. It's also easier to debug code that doesn't do too much all in one go.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
David, I have one question,
I can't figured it out, how to manage 1-dimensional array?
i.e. same as Mauro question above (Brep.CreateContourCurves Method)
Dim Crv As New List (Of Curve())
Dim Cls As Curve()
Cls = Rhino.Geometry.Brep.CreateContourCurves(B, Plane)
Crv.Add(Cls)
The output result none : "Rhino.Geometry.Curve[]"
Thanks
Since you're adding an array, you need to call AddRange() instead of Add().
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Aha, it works! Thanks a lot David
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by