+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Forum Newbie
    AutoCAD 2016
    Join Date
    Mar 2017

    Default accessing entity in a codes windows selection set

    Registered forum members do not see this ad.


    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:

    (setq sel1 (ssget "_w" '(-2 -2) '(115 10)))
    (setq e (car (entsel)))
    (setq topoint (vlax-curve-getStartPoint e))
    (command "_.COPY" sel1 "" "0,0" topoint)

  2. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Lee Mac's Discipline Details
    Custom Programming / Software Customisation
    AutoCAD 2018
    Join Date
    Aug 2008
    London, England


    There are several ways to access items in a selection set - this tutorial describes the advantages & disadvantages of a handful of methods.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  3. #3
    Quantum Mechanic BIGAL's Avatar
    Civil 3D 2016
    Join Date
    Dec 2005


    Registered forum members do not see this ad.

    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-ename->vla-object ent)
    (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"))))
    ; look at varaible co-ordsxy which is a list of vertices
    (princ co-ordsxy)
    A man who never made mistakes never made anything

Similar Threads

  1. Entity Selection
    By tgibbo in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 30th Apr 2015, 10:04 am
  2. entity selection
    By salman in forum AutoLISP, Visual LISP & DCL
    Replies: 11
    Last Post: 30th Jun 2010, 09:36 pm
  3. Entity and Associative Codes
    By alijahed in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 17th May 2010, 01:17 am
  4. Entity group codes question
    By George Duls in forum AutoLISP, Visual LISP & DCL
    Replies: 16
    Last Post: 9th Nov 2007, 12:30 pm
  5. delay in selection of objects/selection windows
    By RedRobMol in forum AutoCAD Drawing Management & Output
    Replies: 2
    Last Post: 31st May 2005, 01:34 pm

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts