×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

AutoLISP: Retrieving atoms from lists
2

AutoLISP: Retrieving atoms from lists

AutoLISP: Retrieving atoms from lists

(OP)
I have written an autolisp program where i generate a list of points that i would like to connect with the SPLINE command. The problem I am having is that I have been only able to get the spline command to recognize the first element of the list automatically. Following is the basic code:

code:

--------------------------------------------------------------------------------

(repeat 5   
(setq pt2 (getpoint ("\n enter point")))
(setq l1 (append l1 (list pt2)))
(command "spline" (car l1)
)

--------------------------------------------------------------------------------


As you can see above, this routine will get me the first point in the list l1, however, if I try to loop to get futher points in the list, I am not able to get further in. Does anyone know how to go about this process? Thanks!
Tom

RE: AutoLISP: Retrieving atoms from lists

(command "spline" (car pnts))
 (setq no 0)
 (repeat (length pnts)
   (setq no (1+ no))
   (command (nth no pnts))
 )

As you can see, you only call the spline command once, then successively use (command point) until you are at the end of the spline. One note however, the third to the last point must be an empty carriage return for example:

(setq pnts (list
 '(1072.25 844.75 0.0) ;start point
 '(901.875 872.25 0.0) ;next point
 '(984.313 1152.19 0.0);next point
 '(1182.13 1327.81 0.0);next point
 '(1610.75 1437.63 0.0);etc
 '(2281.13 1509.0 0.0) ;etc
 '(2676.75 1338.81 0.0);etc
 '(3000.94 1157.69 0.0);etc
 '(3105.31 1503.5 0.0) ;etc
 '""                   ;close point selection
 '(3814.19 1607.81 0.0);start tangent
 '(4072.44 949.063 0.0);end tangent
))

Hope this helps....

RE: AutoLISP: Retrieving atoms from lists

You are building a list and running "spline" at the same time.  You could do what you want without building a list like this:

;;-------------------------------------
(command "spline")
(while (setq pt (getpoint Enter point: "))
        (command pt)
)
(command "" "") ;this is to exit out of spline command
;;-----------------------------

Another way is to build a pointlist:
;;----------------------------------
(setq ptlist nil)
(while (setq pt (getpoint Enter point: "))
        (setq ptlist (cons  pt ptlist))
)
(setq ptlist (reverse ptlist))
(command "spline")
(foreach x ptlist (command x))
(command "" "")
;;---------------------------------

Hope this helps,
Carl

RE: AutoLISP: Retrieving atoms from lists

looks like a good case to try
mapcar lambda
but I could never make good use of these. Maybe someone will post here.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources