'Line' object is unsubscriptable (SDL line for drafted extrusion script)

Hi there,

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
import math

A = rs.CopyObject(x)
B = rs.AddPlanarSrf(x)
pt2 = rs.SurfaceAreaCentroid(B)
num = pt2[0]
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)
rs.MoveObject(x, translation)
b=rs.ScaleObject(x, num, (C,C,1),True)
arrObjects = [A,b]
a=rs.AddLoftSrf(arrObjects)

This is not how a draft extrusion is made though, unless your base shape looks the same offsetted as it does scaled (it works for circles and squares and other regular polygons, not much else).

There is a method which performs this exact operation, perhaps you should be using it?

Thanks for your fast answer.

I wasn’t aware of this method. I had a look and ran into the same problem : defining the vector3D.

That’s why in my script I wanted to use the line SDL to get the normal of the planar surface and use it as the direction.

Is there a way to convert a line as a vector ?