BlackAlnet Posted May 28, 2009 Posted May 28, 2009 (Defun C:DSS () (setq bnum (getint "\nEntre com um numero: ")) (setq inum (itoa bnum)) (Setq PT1 (GetPoint "\nPonto de Desapropriação: " )) (Command "-INSERT""PONTO" PT1 "1""1""0" inum inum "") (while (/= nil PT1) (setq bnum (+ bnum 1)) (setq inum (itoa bnum)) (setq PT1 (getpoint "\nEscolha proximo ponto: ")) (Command "-INSERT""PONTO" PT1 "1""1""0" inum inum "") ) (setq ptlist (append ptlist (list PT1))) (setq file (open (getfiled "Output file" "" "" 5) "w")) (write-line (strcat (rtos (cadr PTLIST)) "," (rtos (caddr PTLIST))) file) (close file) (Princ) ) That's a lisp who i want to take every "insert point coordinates", and put it on a ".csv file, who i will open in excel and generate a table of coordinates... But is not working... I need some tips, i do not want the solution.I want to make it from my own. If someone could help me, i will be very grateful. PS: Excuse me for bad my English Quote
Lee Mac Posted May 28, 2009 Posted May 28, 2009 Did you not want to expand on the LISP I posted previously in your other thread to help you with the one above: (defun c:DSS (/ oldatt bnum pt1) (setq oldatt (getvar "ATTREQ")) (setvar "ATTREQ" 1) (if (and (setq bnum (getint "\nEntr com um numero: ")) (or (tblsearch "BLOCK" "PONTO") (findfile "PONTO.dwg"))) (while (setq pt1 (getpoint "\nPonto de Desapropriação: ")) (command "-insert" "ponto" pt1 "1" "1" "0" (itoa bnum) (itoa bnum) "") (setq bnum (1+ bnum)))) (setvar "ATTREQ" oldatt) (princ)) Quote
Lee Mac Posted May 28, 2009 Posted May 28, 2009 Perhaps something like this to write to file? (defun c:DSS (/ oldatt file bnum pt1 ptlst) (setq oldatt (getvar "ATTREQ")) (setvar "ATTREQ" 1) (if (and (setq bnum (getint "\nEntr com um numero: ")) (or (tblsearch "BLOCK" "PONTO") (findfile "PONTO.dwg")) (setq file (getfiled "Output File" "" "csv" 9))) (progn (while (setq pt1 (getpoint "\nPonto de Desapropriação: ")) (command "-insert" "ponto" pt1 "1" "1" "0" (itoa bnum) (itoa bnum) "") (setq bnum (1+ bnum) ptlst (cons pt1 ptlst))) ; Add the point to the list (setq file (open file "w")) ; Open the file for writing (mapcar (function (lambda (x) (write-line (strcat (rtos (car x)) "," (rtos (cadr x))) file))) ptlst) ; Write each pt in the list to the file (close file))) ; Close the file (setvar "ATTREQ" oldatt) (princ)) Quote
BlackAlnet Posted May 28, 2009 Author Posted May 28, 2009 It's advanced for me, ahaha, but i can understand your lines...I already have 1 lsp with your increment, and work very well!!! So, i want to increment more, and get a *.csv file with the coordinates. Can i take it using "append"? what's wrong with my code? "EDIT"= You are so fast,disregard the above text Quote
BlackAlnet Posted May 28, 2009 Author Posted May 28, 2009 this is definitely what I was thinking! Thank you very much. I do not even know this function lambda ... Quote
Lee Mac Posted May 28, 2009 Posted May 28, 2009 this is definitely what I was thinking! Thank you very much. I do not even know this function lambda ... Thanks As for "lambda" it is what is known as an "anonymous function", when you want to perform a set of operations on each member in a list, you can combine a "mapcar" with a "lambda" function that is a generic example of the operation you want to perform... if that makes any sense... i.e. (mapcar '(lambda (x) (+ x 2)) '(1 2 3)) or (mapcar (function (lambda (x) (+ x 2))) (list 1 2 3)) will return: (3 4 5) And so you can see that the generic function "lambda" has been applied to each member in the list, and the result is a list of the returns. 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.