Johntosh Posted November 22, 2008 Posted November 22, 2008 Is there a better way of giving the coordinates to a command than what I've been using? (setq pnt-list (assoc 10 ent)) (setq pnt-x (rtos (nth 0 pnt-list))) (setq pnt-y (rtos (nth 1 pnt-list))) (setq pnt-z (rtos (nth 2 pnt-list))) (command "_.CIRCLE" (strcat pnt-x "," pnt-y "," pnt-z) radius ) Quote
devitg Posted November 22, 2008 Posted November 22, 2008 Is there a better way of giving the coordinates to a command than what I've been using? (setq pnt-list (assoc 10 ent)) (setq pnt-x (rtos (nth 0 pnt-list))) (setq pnt-y (rtos (nth 1 pnt-list))) (setq pnt-z (rtos (nth 2 pnt-list))) (command "_.CIRCLE" (strcat pnt-x "," pnt-y "," pnt-z) radius ) (setq pnt-list (cdr (assoc 10 ent))) The ASSOC return a list , whose first element is the code itself [10] and the following are the 3 point´s coordinates , in this case From this site http://ronleigh.info/autolisp/acatalog.htm assoc ..... Searches an association list for a key element and returns the sublist starting including the key element. After (setq carlist (list (list "year" "1940") (list "make" "buick") (list "model" "sedan"))) (assoc "make" carlist) returns ("make" "buick") Cdr , strip the first element of a list cdr ..... Returns a list containing all elements but the first. See note below. (cdr (list 2 4 6 ) returns (4 6 (cdr (list (list 1 2) (list 3 4) (list 5 6) (list 7 )) returns ((3 4) (5 6) (7 ) (cdr (list 9)) returns nil Quote
Johntosh Posted November 22, 2008 Author Posted November 22, 2008 thanks devitg I can see that my nth's should have started at 1 to miss the first list member (which I have been doing - typo) but I am happier that I can use cdr. Quote
CarlB Posted November 23, 2008 Posted November 23, 2008 You can send a list to the command, you don't have to put in text format. So the following shorter code should work: (setq pnt-list (assoc 10 ent)) (setq pnt-xyz (cdr pnt-list)) (command "_.CIRCLE" pnt-xyz radius) Quote
ASMI Posted November 23, 2008 Posted November 23, 2008 I think extra variables no need: (command "_.CIRCLE" (cdr(assoc 10 ent))radius) If you need variable in other place of your program: (command "_.CIRCLE" (setq pnt-xyz(cdr(assoc 10 ent)))radius) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.