Jump to content

Extracting PLINE coordinate.


Sheep

Recommended Posts

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.

 

 

0.PNG

Edited by Sheep
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

  • Thanks 1
Link to comment
Share on other sites

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

 

  • Thanks 1
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

 

  • Thanks 1
Link to comment
Share on other sites

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