HELP ON MAKING A SPLINE OUT OF A POINT LIST

I am trying to make a program that will automatically draw gears based on basic parameters fed to it and I've come across a problem. Now that I
have a point list, how can I make a spline out of it. What I'm doing now is very convoluted, I am setting up a selection set and a loop that will draw a segment of the line for each loop and add it to that selection set After that I use the pedit command to join the line segments and convert them into a spline.
Also has anybody had problems with trying to use trim through Autolisp, sometimes the trim works and sometimes it doesn't (check that out for yourself) Even though the point I feed it resides on a line that I want to trim nothing happens.
Thank You
This is a bit of code from the lisp file
                    ;=======================================DRAWING THE CURVE
(setq curv (ssadd))            ; CREATE A CURVE HOLDING SELECTION SET (setq index 0) (repeat    (length endpoints)        ; WILL MAKE A WHOLE BUNCH OF LINE SEGMENTS, AND ADD EACH OF THEM TO THE CURV SELECTION SET (command ".line"      (nth index endpoints)    ; GET THE CURRENT ENDPOINT AS THE START OF THE LINE      (nth (1+ index) endpoints); GET THE NEXT ENDPOINT AS THE EP OF THE LINE      ""      ) (ssadd (entlast) curv)        ; ADD THE LAST CREATED LINE TO THE SELECTION SET (setq index (1+ index)) )
(cond ( (> bc rd)                ; IF THE BASE CIRCLE IS LESS THAN THE ROOT DIAMETER (command ".line"      (last endpoints)        ; START FROM THE END OF THE INVOLUTE      (polar center (: 0) (/ rd 2.0))                     ; AND TO THE ROOT DIAMETER      ""      ) (ssadd (entlast) curv)        ; ADD THE LAST ENTITY CREATED TO THE CURV SS ) ) (command ".pedit" "m" curv "" "y" "j" "" "s" "")                     ; CONVERT THE LINES GRABBED IN THE SELECTION SET INTO A SPLINE USING THE POLYLINE EDIT COMMAND                      (COMMAND ".CIRCLE" center "d" rd)    ; CREATE THE ROOT DIAMETER TO TRIM THE CURVE TO
(command ".trim"            ; TRIM THE INVOLUTE CURVE UP THE ROOT DIAMETER      (polar center (: 13.45) (/ rd 2.0))      ""      (last endpoints)      ""      )                
--
--------------------------------------------------
Overview of Newsgroups and Binaries....
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
by the way sorry for the caps heading didn't notice it until now.
--
--------------------------------------------------
Overview of Newsgroups and Binaries....
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
do a google search for autogear.lsp & save your time for better things

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.