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))
Something like this perhaps.
(if (setq sel (entsel "\nSelect a object")) (setq ent (entget (car sel)) pt (cadr sel) ) );; if
HTH
Henrique
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) )