maerfl Posted March 24, 2017 Posted March 24, 2017 Hello I'm not able to figure out how to easily access the first entity of a slection set created with coded windows selection. I want to read out coodinates of the first point of 2 different objects which are "grabed" in a coded windows selection set. One polyline, one line. Then I want to copy the line from it's first point as basepoint to the first point of the polyline. Advanced I would like to copy it to all the other points of the polyline too. So it would be further more interesting to know how to access (read out the coordinates of) the second, the third and so on point of an object...using visual lisp. The following code is using first a pick up of the object where the line should be copied to and a static coordinate for the basepoint of the line instead of a read out coodinate: (vl-load-com) (setq sel1 (ssget "_w" '(-2 -2) '(115 10))) (setq e (car (entsel))) (setq topoint (vlax-curve-getStartPoint e)) (command "_.COPY" sel1 "" "0,0" topoint) Quote
Lee Mac Posted March 24, 2017 Posted March 24, 2017 There are several ways to access items in a selection set - this tutorial describes the advantages & disadvantages of a handful of methods. Quote
BIGAL Posted March 25, 2017 Posted March 25, 2017 Here is a pline co-ords it makes a list of the vertices. You just need a entsel and check if its a pline or a line etc. I posted something recently that did most of what you want. Will try to find. ; pline co-ords example ; By Alan H (defun getcoords (ent) (vlax-safearray->list (vlax-variant-value (vlax-get-property (vlax-ename->vla-object ent) "Coordinates" ) ) ) ) (defun co-ords2xy () ; convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z (setq numb (/ (length co-ords) 2)) (setq I 0) (repeat numb (setq xy (list (nth i co-ords)(nth (+ I 1) co-ords) )) (setq co-ordsxy (cons xy co-ordsxy)) (setq I (+ I 2)) ) ) ; program starts here (setq co-ords (getcoords (car (entsel "\nplease pick pline")))) (co-ords2xy) ; look at varaible co-ordsxy which is a list of vertices (princ co-ordsxy) 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.