I can’t find answer anywhere. I looked for a long time so I am asking for your help. I have no coding background at all FYI. Basically, I want to learn how to write Grasshopper script with Python to create my own component. The component I want to create is a drafted extrusion from any planar closed curve. Drafted means it is tapered to a chosen angle. This is different from a regular extrusion.
x is the planar closed curve
y the length of extrusion
z is the draft angle
So I take the planar closed curve, move it, scale it down then loft the original curve to the scaled one.
At some point, I need to get the end point of a line(a Rhino Line SDL) but I get an error saying : ‘Line’ object is unsubscriptable.
That Rhino SDL line print as an array of 6 numbers which I assume are the starting point and end point coordinates.
I am stuck there and can’t finish my first script. Any help ?
My code is below.
import rhinoscriptsyntax as rs
from Rhino.Geometry import Vector3d
from Rhino.Geometry import Line
A = rs.CopyObject(x)
B = rs.AddPlanarSrf(x)
pt2 = rs.SurfaceAreaCentroid(B)
num = pt2
closestPt = rs.SurfaceClosestPoint(B,num)
normal = rs.SurfaceNormal(B,closestPt)
line = Line(num,normal,y) #I am looking to get the end point of this line but ‘Line’ object is unsubscriptable
pt3 = rs.AddPoint(rs.CurveEndPoint(line))
angle = math.radians(z)
C = 1-((y*(angle)/50))
D = math.tan(15)
translation = rs.VectorCreate(pt3, num)
b=rs.ScaleObject(x, num, (C,C,1),True)
arrObjects = [A,b]