Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

select select an object and get the point I just picked and enames

5 REPLIES 5
Reply
Message 1 of 6
cadking2k5
435 Views, 5 Replies

select select an object and get the point I just picked and enames

I want to pick one object and the point I pick on the object I want to save it and I want all of the ename of it

 

((-1 . <Entity name: 7ffffb06660>) (0 . "LINE") (330 . <Entity name: 7ffffb039f0>) (5 . "346") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbLine") (10 4.64456 1.92781 0.0) (11 13.3127 8.70008 0.0) (210 0.0 0.0 1.0))

5 REPLIES 5
Message 2 of 6
hmsilva
in reply to: cadking2k5

Something like this perhaps.

(if (setq sel (entsel "\nSelect a object"))
  (setq	ent (entget (car sel))
	pt  (cadr sel)
  )
);; if

HTH

Henrique

EESignature

Message 3 of 6
Lee_Mac
in reply to: hmsilva

Be careful Henrique, as the point returned by entsel is merely the center of the selection aperture, and will not necessarily lie directly on the object (in fact, it won't in most cases).

 

One solution is to use vlax-curve-getclosestpointto or (osnap <point> "_nea") to snap the point to the selected object, however, this may not yield the exact point desired (especially if the user wishes to select a vertex or other definitive point).

 

For this, I would instead suggest:

 

(defun c:test1 ( / pnt sel )
    (while
        (and
            (setq pnt (getpoint "\nPick point on an object: "))
            (not (setq sel (ssget pnt)))
        )
        (princ "\nPoint does not lie on an object.")
    )
    (if pnt
        (mapcar 'princ
            (list
                "\nYou picked: " pnt " on a "
                (cdr (assoc 0 (entget (ssname sel 0))))
            )
        )
    )
    (princ)
)

 

And for nested objects:

 

(defun c:test2 ( / ent pnt )
    (while
        (and
            (setq pnt (getpoint "\nPick point on an object: "))
            (not (setq ent (car (nentselp pnt))))
        )
        (princ "\nPoint does not lie on an object.")
    )
    (if pnt
        (mapcar 'princ
            (list
                "\nYou picked: " pnt " on a "
                (cdr (assoc 0 (entget ent)))
            )
        )
    )
    (princ)
)

 

Message 4 of 6
hmsilva
in reply to: Lee_Mac


@Lee_Mac wrote:

Be careful Henrique, as the point returned by entsel is merely the center of the selection aperture...


Agreed.

Should have read all the post...

Misled by the title...

"select an object and get the point I just picked and enames"

 

Cheers

Henrique

EESignature

Message 5 of 6
Lee_Mac
in reply to: hmsilva

Message 6 of 6
cadking2k5
in reply to: Lee_Mac

I used this in case the point was not on the object (setq ep (osnap (cadr sel) "nea"))

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost