"sheet" body Breps (i.e trimmed stuff == BrepFaces) divide them proportionally to the u/v domains using DeDom2Num: get Lists of U1/V1 values, say a uList and a vList. In order to do that:
3. Find the min of each List, say uMin, vMin.
4. Your U/V division integer values (per surface) are:
(int) (U * uList[i] / uMin)); (int) (V * vList[i] / vMin));
5. Using the pts and vectors trees from the divide surface component ... add to each div pt the corresponding normal vector multiplied by some min/max random value.
6. Create a Nurbs Surface using the newly created "distorted" pts (control points or trough points).
7. Trim the surfaces against the potential Inner/Outer loops (per brep). Trim requires solid cutters mind.
…
using some simple vector math and RhinoCommon (basically, to check if a point is above a plane: Calculate the dotproduct between the plane Z-Axis and a vector from the plane origin to the point. If this is negative you're below, else above the plane).2) The cost of inputting/outputting large lists of objects can be very expensive (see this thread for tips). Best way to get around this is to encapsulate the logic inside your GHPython components as much as needed and not input/output more than you have to. Alternatively you can wrap the data from one component to the next in something which won't expose the data to GH. A third option is to use the PointCloud class or even the Volvox pointcloud. Both should severely speed this up.3) Of course multithread it once it you find the best solution for you (if it's still too slow ;)Attached a file exemplifying some of this..Edit: Didn't see Daniel's answer, using Plane.ValueAt(pt) method will be even faster than calculating it yourself via Python.…
h a surface reference that doesn’t exist anymore. Could you give me any advice to get the same result with the actual version or a solution to download the component.
Of course with the new component there is a big distortion.
attached the pictures to help understanding
Many thanks in advance for your help.
Michèle
1 the tutorial reference
2 the component you use
3 the current component in PT for grasshopper
…
r spatial studies farther down the road, but I digress; on to my Grasshopper script:
I've built a Grasshopper script that will display a point field for a given topography map (curves extracted from contour lines). The idea here is to display higher levels of density where the highest slopes are within a given topo map.
The file works, but I'm wondering if there is a simpler way of going about this, since my file contains so much redundant info (open the cluster "Pt:50" to see what I mean). My Grasshopper Kung-Fu skills aren't anywhere near expert yet, so I defer to the experts out there for a simpler solution. Here's my breakdown:
1. Start at curve start point, and find closest point within the group of curves.
2. Get distance to that closest point, and find second point along said curve at that distance.
3. Repeat process along curve starting at each new point at each new process.
Thanks in advance for any suggestions/comments!
Cheers,
cb…
changes is the usage of Structures ("ValueTypes" as they are known in generic .NET parlance) over Classes. In the old SDK On3dPoint was a class. That means that if you declare an On3dPoint, it would be Nothing:
Dim pt As On3dPoint 'This results in a pt which doesn't exist, i.e. Nothing
Attempting to call any functions on this would result in a NullReferenceException. Point3d in RhinoCommon is a structure, very much like the integer and boolean types. It is impossible for a structure to not exist. Therefore, when you declare a Point3d, you actually get a valid point at {0,0,0}:
Dim pt As Point3d 'This results in a point at {0,0,0}
The difference between structures and classes ("value types" and "reference types" respectively) is very important and you'll need to understand it otherwise you'll keep running into weird bugs you can't explain. One of the biggest differences to keep in mind is that assigning a Value Type to another Value Type automatically creates a copy of it. Observe these two pieces of code:
Dim pt0 As New On3dPoint(1,4,0)
Dim pt1 As On3dPoint = pt0
pt1.Z = 10
vs.
Dim pt2 As New Point3d(1,4,0)
Dim pt3 As Point3d = pt2
pt3.Z = 10
The first example uses On3dPoint, which is a reference type. "Reference" means that the actual data stored inside the pt0 and pt1 variables is in fact a memory address. When you then try to access the Z component of the point, the computer will read that memory address stored inside the variable, go to that location in memory and extract the number at that location that represents the Z component of the point. So On3dPoints exist somewhere in memory (you don't know where and you shouldn't have to care) and you can have any number of On3dPoint references pointing to that address, i.e. all sharing the same point data.
Not so with value types. Value types don't store their data elsewhere and then remember where elsewhere is supposed to be, they store their data directly inside the variable. So when you assign pt0 to pt1, what's actually happening is that the reference to the On3dPoint instance is copied, and now pt0 and pt1 both point at the same location in memory. Therefore changing the Z of pt1 will also change the Z of pt0, since they're the same Z. However when you assign pt2 to pt3, it also assigns the data inside pt2 to pt3, but in this case the data is in fact the point coordinate itself. So changing the Z of pt3 does not affect the Z of pt2.
Because of this fundamental difference between the old and the new points* you cannot simply translate code, you need to really understand what the code is doing in order to rewrite it. My guess in this case is that you're trying to call a constructor that doesn't exist:
Dim pt As New Point3d(pts(n))
In the old SDK the best way to create a copy of a point was to use the copy-constructor. However this constructor is missing in RhinoCommon because simply assigning the old point has the same effect:
Dim pt As Point3d = pts(n)
* Vectors, Planes, Transform matrices, Circles, Arcs, Lines etc. are also all Value Types in RhinoCommon
--
David Rutten
david@mcneel.com
Poprad, Slovakia
…
Added by David Rutten at 2:19am on January 15, 2012
problem with C++ and C# and (probably) Python.
Here's the problem (scroll down for the solution):
You're creating a loop that runs from zero to one, with a specific step size. However, the step size is computed as the inverse of the number of rows/columns. Whenever you compute 1.0 / Rows, you don't get the exact answer. You get a floating point number that is very close to the real answer. Add this number to itself 19 times and you don't end up exactly at 1.0, but at 1.000000000001 (or something). Therefore the last iteration is skipped.
You could solve this by adjusting your loop to go from zero to one+half-the-stepsize:
For i As Double = 0.0 To (1.0 + 0.5*rowStep) Step rowStep
But I think the following is much neater:
Private Sub RunScript(ByVal Brp As OnBrep, ByVal Col As Integer, ByVal Row As Object, ByRef A As Object)
Dim srf As IOnSurface = Brp.Face(0)
Dim U As OnInterval = srf.Domain(0)
Dim V As OnInterval = srf.Domain(1)
Dim Rows As New List(Of On3dPoint)
For i As Int32 = 0 To Row
For j As Int32 = 0 To Col
Dim s As Double = U.ParameterAt(i / Row)
Dim t As Double = V.ParameterAt(j / Col)
Dim pt As On3dpoint = srf.PointAt(s, t)
Rows.Add(pt)
Next
Next
A = Rows
End Sub
I practically never use doubles in For...Next loops.
--
David Rutten
david@mcneel.com
Turku, Finland…
e of what should I do?
Thankyou!!!!
//Create empty rectanles, breps list List<Rectangle3d> rects = new List<Rectangle3d>(); List<Brep> collectBreps = new List<Brep>();
//Initialize a new instance of the Random class called random
Random random = new Random(); //Create a new unitZ vector Vector3d unitZ = new Vector3d(0, 0, 1); //Start a loop for(int i = start; i <= end; i = i + 2) { //Create random values int randint = random.Next(0, 100); int randint2 = random.Next(0, 10); int randint3 = random.Next(0, 5); //Create new Extrusions based on these random values Point3d pt = new Point3d(i, randint, randint2); Plane pln = new Plane(pt, unitZ); Rectangle3d rect = new Rectangle3d(pln, randint3, randint3); //Add all of these to the appropriate lists (Actually, since we are only using the rects you don't need the others FYI) rects.Add(rect); } A = rects;…
etter with each release
but if I had my way, here are a few things that I might add, I'm sure there has been conversations about this already in the past, please excuse the redundancies:
- being able to print the "stage" (by stage I mean the space where you layout the components and wires...)
- problem w/vb component pt 1 - sometimes when adding new inputs, items checked as lists go unchecked
- problem w/vb component pt 2 - sometimes I find that when I put a name in an input when I hit ok I still get the default x, y, ....
- it might be nice to be able to "fit to content" a notepad component, sort of indesign style where it sets its shape to the limits of its content
- when copying and pasting, it would be great if the new item were somehow already aligned, so that a simple shit+drag would avoid having to go that extra step and use the align buttons - which are great btw. and yes I'm that lazy
- sliders - I'm not sure why when you right click and have access to its values the length stays fixed so that if you adjust the min or max you automatically affect the other. I'm not sure I get why that is...
-sliders pt 2 - I think it would be great to be able to set the incremental value - so instead of just integers of floats it could be multiples of a number - I know you could do this with a function, but in my mind, the less parts the better
- a more major one - it might be really great if we could completely disable components like the preview option but going one step further and actually eliminating that component from the computation.meant mostly for the ends that might be taxing on a system, to be able to return to early parts and quickly adjust without waiting for update of later stages, but could also see a use if you wanted to send data through to a later stage having bypassed some middle components - these middle components would then become completely empty and neutral conduits until being reactivated again - think of the 3DStudio Max stack
these are mostly incredibly minor and would just kind of heighten the expereince even more…
.5 (50%) will make everything look half as big, a zoom factor of 3.0 (300%) will make everything look 3 times bigger.
The code I use in the Variable Parameter tip looks like this:
Dim box As RectangleF = Attributes.Bounds Dim pt As New PointF(box.X + 0.5F * box.Width, _
box.Top + 0.5F * box.Height) Dim view As New GH_NamedView("zui_zoom", pt, _
10.0F, GH_NamedViewType.center)
view.SetToViewport(canvas, 1200)
I use a fixed zoom factor of 10.0 but you'll need to compute a variable zoom level each time. Basically, the zoom level you want it the factor you need to multiply the Attributes.Bounds with in order to make them as big as the viewport.ScreenPort So if the ScreenPort is 950 pixels wide and 720 pixels high and the Bounds of the attributes are 55 pixels wide and 75 pixels high, the zoom factor to make the width and height fit exactly would be:
Dim zoomW As Single = Convert.ToSingle(950/55)
Dim zoomH As Single = Convert.ToSingle(720/75)
Dim zoom As Single = Math.Min(zoomW, zoomH)
Where zoom is the lowest of the two. I hope my math isn't wrong, I didn't test this and only just woke up... But that's the basic idea.
--
David Rutten
david@mcneel.com
Poprad, Slovakia…
Added by David Rutten at 2:18am on February 16, 2012
ts in the Rhino Window for obj in self.objs: rhObj = rhdoc.Objects.Find(obj) # finds the object in the Rhino data set using its GUID
if type(rhObj.Geometry) == rg.LineCurve and self.lineSeg[0] == True: line = [] pt = [] weight = None
# Extracts coordinates from underlying Rhino Object geometry line.append(self.Point3d_to_Pt3(rhObj.Geometry.PointAtStart)) line.append(self.Point3d_to_Pt3(rhObj.Geometry.PointAtEnd))
if self.lineSeg[1] == True: weight = rhObj.Attributes.PlotWeight # Extracts weight from Rhino Object
line.append(weight) self.lines.append(line) if type(rhObj.Geometry) == rg.Point and self.point == True: point = rs.PointCoordinates(rhObj.Geometry) self.pts.append(rs.PointCoordinates(rhObj.Geometry))
return [self.pts,self.lines]
…