algorithmic modeling for Rhino
Hello,
I'm trying to write the script, that would arrange a surface/brep in order to not overlap itself (so that the middle of the surface doesnt go over the edge of the surface).
If you imagine that I'm dealing only with surfaces, that are built as an edge-srf and every edge has 3 controlpoints (2 corners and middle), that leaves you just one control point for the middle part of the surface. My desire is to reach this point and move it so, that it's inside of the edges, so the surface can't overlap.
My question is - can I call the control points?
Tags:
not sure if you have already tried this but I would try to do it by attatching a slider to the center control point and using it to control its movement or maybe create a boundry curve and offet it to just inside the edge curves and link that to the center points.
I wanna do it by using VB script component... so I'm looking for the right command..
Alright, I've gotten something together that solves the problem but I don't like the way that I made sure it was still "in" the surface. Hopefully this will get you on your way.
'Turn your input surface into a nurbs surface
Dim s As NurbsSurface = x.Duplicate
'Get the middle control point, assign its location to a point3d for transforming purposes
Dim cpList As rhino.Geometry.Collections.NurbsSurfacePointList = s.points
Dim cp As controlpoint = cpList.GetControlPoint(1, 1)
Dim pt As point3d = cp.Location
'Turn the surface into a brep (to get the edges)
Dim be As rhino.Geometry.Collections.BrepEdgeList = s.ToBrep.edges
Dim el As New List(Of Curve)
For i As int32 = 0 To be.count - 1
el.add(be(i).ToNurbsCurve)
Next
Dim bnd() As curve = curve.JoinCurves(el)
'move the point according to the sliders
pt.Transform(transform.Translation(New vector3d (sliderX, SliderY, SliderZ)))
'check if the moved point is in the boundary (projected to the XY plane in this case)
If bnd(0).Contains(pt, plane.WorldXY) = PointContainment.Inside Then
'if yes then make the controlpoint = the point3d
cp = pt
cpList.SetControlPoint(1, 1, cp)
Else
'if not then do nothing to the point but let the user know
print("the control point is outside the boundary of the surface")
End If
'output your modified surface
output = s
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