Jump to content

Recommended Posts

Posted

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?

Posted

(foreach pt (mapcar	'cdr 	(vl-remove-if-not
  '(lambda (j) (= (car j) 10)) lst))
.....
.....
)

 

 

Welcome to CAD Tutor Deko :)

Posted

(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]

Posted

Guess you posted good 'ol assoc/member route Lee.

 

Man you are fast :D

Posted

;;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   

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...