deko Posted October 10, 2012 Posted October 10, 2012 hi, i am having some problems with lists. for example, i have a polyline list, and i want to take its 1st point, use it during a "while" routine... then thake the seccond point, use the routine again, and again with 3rd point, and etc..... so, here is a random poyline list: ( (-1 . ) (0 . "LWPOLYLINE") (330 . ) (5 . "1F2") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbPolyline") (90 . 6) (70 . 0) (43 . 0.0) (38 . 0.0) (39 . 0.0) (10 1232.28 1105.94) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 1823.53 1585.85) (40 . 0.0) (41 . 0.0) (42 . -0.741819) (91 . 0) (10 2257.98 1292.03) (40 . 0.0) (41 . 0.0) (42 . 2.5507) (91 . 0) (10 2914.56 1670.74) (40 . 0.0) (41 . 0.0) (42 . -0.859067) (91 . 0) (10 2950.49 2163.71) (40 . 0.0) (41 . 0.0) (42 . 2.38592) (91 . 0) (10 1871.63 3100.83) (40 . 0.0) (41 . 0.0) (42 . 0.203773) (91 . 0) (210 0.0 0.0 1.0) ) if it was a line or something like that, i could use "" (assoc 10 .... but i have 6 of them!, so, what do i do? Quote
pBe Posted October 10, 2012 Posted October 10, 2012 (foreach pt (mapcar 'cdr (vl-remove-if-not '(lambda (j) (= (car j) 10)) lst)) ..... ..... ) Welcome to CAD Tutor Deko Quote
Lee Mac Posted October 10, 2012 Posted October 10, 2012 (setq elist (entget [i][color=green]<lwpolyline ename>[/color][/i])) (while (setq item (assoc 10 elist)) (setq point (cdr item) elist (cdr (member item elist)) ) [i][color=green]... < do something > ...[/color][/i] ) (foreach item (entget [i][color=green]<lwpolyline ename>[/color][/i]) (if (= 10 (car item)) [i][color=green]... < do something > ...[/color][/i] ) ) PS: Please edit your post and enclose your code with code tags: [highlight][noparse] [/noparse][/highlight] Your code here [highlight][noparse] [/noparse][/highlight] Quote
pBe Posted October 10, 2012 Posted October 10, 2012 Guess you posted good 'ol assoc/member route Lee. Man you are fast Quote
gS7 Posted October 11, 2012 Posted October 11, 2012 ;;Function To Mark Each Node Points With Point IDs ;; Writtend By Ganesh .... (defun c:mnp(/ os lay str cntr l str strt ent vert pts) (setq os(getvar "osmode")) (setq lay(getvar "clayer")) (setvar "cmdecho" 0) (setvar "osmode" 0) (command "UNDO" "G") (prompt "\nSelet Valid Polylines.") (if(setq ss(ssget '(( 0 . "LWPOLYLINE")))) (progn (setq str(getstring T "\nEnter Prefix ::")) (command "LAYER" "M" "Id_Points" "c" "62" "" "") (setq l(sslength ss)) (setq cntr 0) (repeat l (setq ssn(ssname ss cntr)) (setq strt 1) (setq ent(entget ssn)) (foreach VERT Ent (if(= (car VERT) 10) (progn (setq PTS(cdr VERT)) (command "TEXT" "J" "MC" PTS (*(getvar "DIMSCALE") 1) "0" (strcat(strcase str) "-"(itoa strt))) (setq strt(1+ strt)) );progn );if );foreach (setq cntr(1+ cntr)) );;reapet );;progn (princ "\nError...No Valid Object Selected") );if (setvar "osmode" os) (setvar "clayer" lay) (command "UNDO" "E") (setvar "cmdecho"1) (princ) );;defun 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.