See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Exact point using ENTSEL

  1. #1
    I could stop if I wanted to
    Join Date
    2001-01
    Posts
    257
    Login to Give a bone
    0

    Default Exact point using ENTSEL

    HI All
    I am working on a routine where I need to select a MULTILEADER with ENTSEL but I need to obtain the exact location (point) where I selected the object. Everything I have tried thus far returns a point at either end of the MULTILEADER. Any help is greatly appreciated.
    Manuel

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,100
    Login to Give a bone
    0

    Default Re: Exact point using ENTSEL

    Are you using running OSNAPS? You may need to disable them during that operation.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  3. #3
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Exact point using ENTSEL

    Try:
    Code:
        (setq e (nentselp pt)
              ent (entget(ssname (ssget pt nea) 0))
              etype (cdr(assoc 0 ent))
              elayer (cdr(assoc 8 ent))
              ent (cdar ent)
        )
        (if (= etype "MULTILEADER")
          (progn
            (setq e (nentselp pt)
                  ent (entget(ssname (ssget pt nea) 0))
                  etype (cdr(assoc 0 ent))
                  ent (cdar ent)
            )
          )
        )

  4. #4
    I could stop if I wanted to
    Join Date
    2006-04
    Posts
    466
    Login to Give a bone
    0

    Default Re: Exact point using ENTSEL

    might have to trash some CAR and CDR for this. i'm lost, (ENTGET (CAR ENTSEL)) ?
    or (CDR ENTSEL))?

    entity and point, yup CDR of entsel
    Last edited by aaronic_abacus; 2023-03-28 at 03:39 AM.

  5. #5
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    1

    Default Re: Exact point using ENTSEL

    Quote Originally Posted by aaronic_abacus View Post
    might have to trash some CAR and CDR for this. i'm lost, (ENTGET (CAR ENTSEL)) ?
    or (CDR ENTSEL))?

    entity and point, yup CDR of entsel
    The point returned by entsel is the location of the cursor and ignores osnap settings.
    From Help: The pick point returned by entsel does not represent a point that lies on the selected object. The point returned is the location of the crosshairs at the time of selection. The relationship between the pick point and the object will vary depending on the size of the pickbox and the current zoom scale.

    Only way I've ever gotten around it was to try snapping to a point on the selected object.
    Works best if you're zoomed to the selected object, not a perfect solution.
    Code I attached was a snippet from an old lisp of mine with a different entity type hoping it might help.

  6. #6
    I could stop if I wanted to
    Join Date
    2002-08
    Posts
    231
    Login to Give a bone
    2

    Default Re: Exact point using ENTSEL

    Hi,
    Even with a standard command, it is impossible to latch onto a point close to a multileader.
    I only see this not very elegant method to get the exact value of the near point.

    Code:
    ((lambda ( / loop sel pt ent pt_near)
      (setq loop T)
      (while loop
        (setq sel (entsel "\nSelect an MLeader: "))
        (cond
          ((and sel (eq (cdr (assoc 0 (entget (car sel)))) "MULTILEADER"))
            (setq
              loop nil
              pt (cadr sel)
            )
            (command "_.undo" "_mark")
            (command "_.explode" (car sel))
            (setq
              ent (nentselp pt)
              pt_near (vlax-curve-getClosestPointTo (car ent) pt)
            )
            (command "_.undo" "_back")
          )
          (T (princ "\nIs not an MLeader or the selection is empty!"))
        )
      )
      (if pt_near (command "_.line" "_none" pt_near))
      (prin1)
    ))

  7. #7
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    2

    Default Re: Exact point using ENTSEL

    OK using active x



    Code:
    ;___________________________________________________________________________________________________________|
    ;
    ; Written By: Peter Jamtgaard copyright 2023 All Rights Reserved
    ;___________________________________________________________________________________________________________|
    
    ;___________________________________________________________________________________________________________|
    ;
    ; Command Line Function Header List
    ;___________________________________________________________________________________________________________|
    
    ;* C:MLN
    ;* Command Line Function to get the nearest point to a multileader
    
    ;* C:MultiLeaderNearest
    ;* Command Line Function to get the nearest point to a multileader
    
    ;___________________________________________________________________________________________________________|
    ;
    ; General Function Header List
    ;___________________________________________________________________________________________________________|
    
    ;  Function List Argument1 Argument2 Arguement3
    
    ;* (ListofSublistsSortbyItem lstOfSublists intItem)
    ;* Function to sort a list of sublists by item in sublists
    
    ;* (MultiLeaderList objOwner objMultileader lstPoint)
    ;* Function to read get the list of ratio of distance and point sublists from each leader and sort them
    
    ;* (MultileaderSelect)
    ;* Function to select a multileader
    
    ;$ End Header
    
    ;___________________________________________________________________________________________________________
    ; 
    ; Command Line Function to get the nearest point to a multileader
    ;___________________________________________________________________________________________________________
    
    (defun C:MLN ()(C:MultiLeaderNearest))
    
    (defun C:MultiLeaderNearest (/ intOwnerID
                                   lstObjectAndPoint
                                   lstOfSublists 
                                   lstPoint
                                   lstSelection 
                                   objDocument
                                   objMultileader
                                   objOwner
                                )
     (if (and (setq lstObjectAndPoint (MultileaderSelect))
              (setq objMultileader    (car lstObjectAndPoint))
              (setq lstPoint          (cadr lstObjectAndPoint))
              (setq intOwnerID        (vla-get-OwnerID objMultileader)) 
              (setq objDocument       (vla-get-document objMultileader))  
              (setq objOwner          (vla-objectidtoobject objDocument intOwnerID))
              (setq lstOfSublists     (MultiLeaderList objOwner objMultileader lstPoint))
              (setq lstPoint          (cadr (car (reverse lstOfSublists))))
         )
    ; lstPoint
      (vl-cmdf "circle" lstPoint 0.1)
     )
    )
    
    ;___________________________________________________________________________________________________________
    ; 
    ; Function to sort a list of sublists by item in sublists
    ;___________________________________________________________________________________________________________
    
    (defun ListofSublistsSortbyItem (lstOfSublists intItem)
     (vl-sort lstOfSublists '(lambda (X Y) (< (nth intItem X) (nth intItem Y))))
    )
    
    ;___________________________________________________________________________________________________________
    ; 
    ; Function to read get the list of ratio of distance and point sublists from each leader and sort them
    ;___________________________________________________________________________________________________________
    
    (defun MultiLeaderList (objOwner objMultileader lstPoint / intIndex
                                                               lstOfSublists 
                                                               lstPointNearest 
                                                               objPolyline 
                                                               sngDistance 
                                                               sngRatio 
                                                               sngLength 
                           )
     (foreach intIndex (vlax-invoke objMultileader "GetLeaderLineIndexes" 0)
      (if (and (setq lstLeaderLineIndexes (vlax-invoke objMultileader "GetLeaderLineVertices" intIndex))
               (setq objPolyline          (vlax-invoke objOwner "addpolyline" lstLeaderLineIndexes))
               (setq sngLength            (vla-get-length objPolyline))
               (setq lstPointNearest      (vlax-curve-getclosestpointto objPolyline lstPoint))
               (progn (vla-delete objPolyline) T)
               (setq sngDistance          (distance lstPoint lstPointNearest))
               (setq sngRatio             (/ sngLength sngDistance))
               (> sngRatio 20.0)           
                         
          )
       (setq lstOfSublists (cons (list sngRatio lstPointNearest) lstOfSublists))   
      )
     )
     (if lstOfSublists
      (listofsublistssortbyitem lstOfSublists 0)
      (print "Error Finding Nearest Point: ")
     )
    )
    
    ;___________________________________________________________________________________________________________
    ; 
    ; Function to select a multileader
    ;___________________________________________________________________________________________________________
    
    (defun MultileaderSelect (/ entSelection lstOfSublists lstPoint lstSelection objSelection ssSelection)
     (while (not (and (setq lstSelection (entsel "\nSelect Mleader"))
                      (setq lstPoint     (cadr lstSelection))
                      (setq ssSelection  (ssget lstPoint (list (cons 0 "MULTILEADER"))))
                      (setq entSelection (ssname ssSelection 0))
                      (setq objSelection (vlax-ename->vla-object entSelection))
                 )
            )
      (princ "\nError Selecting Multileader: ")
     )
     (list objSelection lstPoint)
    )
    
    (princ "!")
    (vl-load-com)
    Attached Files Attached Files
    AutomateCAD

  8. #8
    Member
    Join Date
    2020-01
    Posts
    2
    Login to Give a bone
    1

    Default Re: Exact point using ENTSEL

    Does this help ?

    (setq PICK_PT (cdr (entsel "Select Multileader: \n")))


  9. #9
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,416
    Login to Give a bone
    0

    Default Re: Exact point using ENTSEL

    Hi Langbolt, Welcome to AUGI!

    The problem with the entsel command is that it gives the EXACT location of the cursor, which may be a minuscule distance away from the leader, not actually ON the leader. The other code samples are trying different ways to compensate for that.
    C:> ED WORKING....


    LinkedIn

  10. #10
    Member
    Join Date
    2015-12
    Posts
    3
    Login to Give a bone
    0

    Default Re: Exact point using ENTSEL

    Quote Originally Posted by Ed Jobe View Post
    Hi Langbolt, Welcome to AUGI!

    The problem with the entsel command is that it gives the EXACT location of the cursor, which may be a minuscule distance away from the leader, not actually ON the leader. The other code samples are trying different ways to compensate for that.

    Maybe something Like This? I have used this effectively in the past.
    (setq PICK_PT (cadr (entsel "Select Multileader: \n"))
    Obj_Pt (osnap PICK_PT "NEA") ; Or could use mode "END" for a vertex.
    )

Page 1 of 2 12 LastLast

Similar Threads

  1. entsel point
    By Frank Dux in forum AutoLISP
    Replies: 2
    Last Post: 2019-09-05, 07:27 PM
  2. CV104-1P: One Point, Two Point, Red Point, Blue Point
    By Autodesk University in forum Civil Infrastructure
    Replies: 0
    Last Post: 2013-05-05, 03:17 AM
  3. CV12-4: One Point, Two Point, Red Point, Blue Point
    By Autodesk University in forum Civil Infrastructure
    Replies: 0
    Last Post: 2013-04-17, 04:50 AM
  4. Help with using entsel or nentselp
    By MWKINCAID1 in forum AutoLISP
    Replies: 3
    Last Post: 2007-03-10, 12:10 AM
  5. Point from entsel
    By wommack in forum AutoLISP
    Replies: 10
    Last Post: 2006-12-15, 06:01 PM

Posting Permissions

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