Jump to content

accessing entity in a codes windows selection set


maerfl

Recommended Posts

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)

Link to comment
Share on other sites

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)

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