Sheep Posted July 15, 2020 Posted July 15, 2020 (edited) Hi all. I'm new to AutoLISP and need some help. If i do a LIST on pline, i can see the X,Y and Z at every point. How do i extract the coordinates so i can make a new pline next to it (in any angle)? Found this snipets but it just show the (princ). No, i'm not exporting it to a text file. Please give me example not in VLisp. (defun c:vv () (setq elst (entget (car (entsel "\nSelect Polyline: ")))) (setq vnum 0) (if (= (cdr (assoc 0 elst)) "LWPOLYLINE") (while (setq elst (member (assoc 10 elst) elst)) (setq vnum (+ vnum 1)) (setq vxcd (cadr (car elst))) (setq vycd (caddr (car elst))) (princ (strcat "\nPolyline Vertex #" (itoa vnum) " X,Y Coordinates: " (rtos vxcd) ", " (rtos vycd))) (setq elst (cdr elst)) ) (princ "\nObject is not a 2D LWPolyline") ) (princ) ) Thank you for your time. Edited July 15, 2020 by Sheep Quote
Sheep Posted July 15, 2020 Author Posted July 15, 2020 Basically, i'm trying to answer my own question partially. Can i use: (mapcar 'rtos (append (cdr (assoc 10 (entget ent))) (cdr (assoc 11 (entget ent))) to get all the X,Y and Z or it's just for one coordinate? Quote
Trudy Posted July 15, 2020 Posted July 15, 2020 Hello, try this if you want (setq sset (ssget '((0 . "LWPOLYLINE")))) ;;;;;;;;;;;;;;;; ;repeat for n selected plines (repeat (setq i (sslength sset)) (setq nam (ssname sset (setq i (1- i)))) (setq ent (entget nam)) (setq entD ent) (setq tt (assoc 10 entD)) ;;;;; ;Create list from X Y (while (/= nil tt) (setq all (cons tt all)) (setq entD (vl-remove tt entD)) (setq tt (assoc 10 entD)) ); end while ) (setq all (reverse all)) Hope to help you if dont work i will modify it. 1 Quote
Jonathan Handojo Posted July 15, 2020 Posted July 15, 2020 Just copy it using vla-Copy and then move it using vla-Move (although this uses VLisp) ;; ent - entity object ;; pt1 - base point ;; pt2 - move point (defun pl (ent pt1 pt2) (vla-Move (vla-Copy (vlax-ename->vla-object ent)) (vlax-3d-point pt1) (vlax-3d-point pt2)) ) If you want just the coordinates: (mapcar 'cdr (vl-remove-if-not '(lambda (x) (vl-position (car x) '(10 11))) (entget pl))) 1 Quote
Sheep Posted July 15, 2020 Author Posted July 15, 2020 3 minutes ago, Jonathan Handojo said: If you want just the coordinates: (mapcar 'cdr (vl-remove-if-not '(lambda (x) (vl-position (car x) '(10 11))) (entget pl))) What is the substitute of vl-remove-if-not and vl-position in Autolisp? Quote
Jonathan Handojo Posted July 15, 2020 Posted July 15, 2020 You can use "member" in place of vl-position. It's just that "vl-position" is just slightly faster than "member". It accepts exactly the same arguments as "vl-position". As for vl-remove-if-not, I don't think there's another. You just have to make one: (defun vl-remove-if-not2 (fnc lst / rtn) (foreach x lst (if ((eval fnc) x) (setq rtn (cons x rtn)) ) ) (reverse rtn) ) 1 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.