Jump to content

Is there a way get coordinates at the pick point when selecting objects with ssget?


vanowm

Recommended Posts

Hello.

 

When using ssget is there a way capture coordinates of the pick point on the object when it was selected?

 

Basically I'm looking for a way to determine what side of a pline the user picked during selection. Like in rulesurf command.

 

Thank you.

Link to comment
Share on other sites

Not familiar with rulesurf, and I don't use it often for my own use, but if SSGET can do this, it will likely include the +. Selection Mode String.

 

Another option, being that you know the entity type your filtering for:

 

;;...

(if 
 (and
   (setq e (entsel "\nSelect polyline: "))
   (wcmatch (cdr (assoc 0 (setq d (entget e)))) "*POLYLINE")
 )
 (progn 
   (prompt "\nCoordinate: ")
   (princ (last d))

   ;;<-- do something useful

 )
)

;;...

Link to comment
Share on other sites

When using ssget is there a way capture coordinates of the pick point on the object when it was selected?

 

Use the data returned by the ssnamex function.

Link to comment
Share on other sites

I am searching for the same question... But till now I think you can't get coordinates that belong to a picked entity by transforming picked point either with (ssget) or (entsel) or (nentsel)... Only thing you can get is coordinates of point that belong to "entity" - projection to current UCS... That coordinates are stored as second element of list obtained with (entsel) or (nentsel) or member of complex list returned by (ssnamex) function... To try to overcome this problem is to use (getpoint) function with "_nea" OSNAP mode - OSMODE 512 when acquiring entity and then pass this point to (nentselp) function... AFAIK till now there is no way you can transform picked point of UCS projection when in 3D View using (trans) function or any of (vlax-curve-getclosestpointto) or (vlax-curve-getclosestpointtoprojection) with optional T parameter for extending curves to corresponding point that belong to that curve/entity...

Link to comment
Share on other sites

Use the data returned by the ssnamex function.

 

THAT's what I was searching for last night :notworthy:; the online help doesn't play nice with iOS devices.

 

Cheers

Link to comment
Share on other sites

I am searching for the same question... But till now I think you can't get coordinates that belong to a picked entity by transforming picked point either with (ssget) or (entsel) or (nentsel)... Only thing you can get is coordinates of point that belong to "entity" - projection to current UCS... That coordinates are stored as second element of list obtained with (entsel) or (nentsel) or member of complex list returned by (ssnamex) function... To try to overcome this problem is to use (getpoint) function with "_nea" OSNAP mode - OSMODE 512 when acquiring entity and then pass this point to (nentselp) function... AFAIK till now there is no way you can transform picked point of UCS projection when in 3D View using (trans) function or any of (vlax-curve-getclosestpointto) or (vlax-curve-getclosestpointtoprojection) with optional T parameter for extending curves to corresponding point that belong to that curve/entity...

 

I've figured this out... I was wrong, you can get point on entity/curve if you use (ssget "_+.:E:S") method applied on curve entity and then obtain projection on WCS with (ssnamex)... Thanks to Lee and BB...

 

Here is an example where I used this method... :

 

(defun c:danr ( / *error* _plsegrad el ss e p pe d dn db dt r txt txtn x )

 (vl-load-com)

 (defun *error* ( msg )
   (if x (command "_.UCS" "_P"))
   (command "_.REGEN")
   (vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))
   (if msg (prompt msg))
   (princ)
 )
 
 (defun _plsegrad ( obj pt / n p1 p2 bulge rad )
   (setq n (fix (vlax-curve-getparamatpoint obj (vlax-curve-getclosestpointto obj pt))))
   (setq p1 (vlax-curve-getpointatparam obj (float n)))
   (setq p2 (vlax-curve-getpointatparam obj (float (1+ n))))
   (setq bulge (vla-getbulge obj (float n)))
   (if (/= bulge 0.0)
     (setq rad (/ (distance p1 p2) (* 2 (sin (* 2 (atan bulge))))))
   )
   (abs rad)
 )

 (vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))
 (setq el (entlast))
 (prompt "\nPick arced entity to dimension angular with radius value")
 (setq ss (ssget "_+.:E:S" '((0 . "ARC,CIRCLE,*POLYLINE"))))
 (while (null ss)
   (prompt "\nMissed, empty sel.set... Try picking arced entity again (ARC,CIRCLE,*POLYLINE)...")
   (setq ss (ssget "_+.:E:S" '((0 . "ARC,CIRCLE,*POLYLINE"))))
 )
 (setq e (ssname ss 0))
 (setq p (cadr (cadddr (car (ssnamex ss)))))
 (setq pe (vlax-curve-getclosestpointtoprojection e p '(0.0 0.0 1.0)))
 (command "_.UCS" "_E" (trans pe 0 1))
 (setq x t)
 (command "_.DIMANGULAR" (trans pe 0 1))
 (while (> (getvar 'cmdactive) 0) (command "\\"))
 (setq d (entlast))
 (if (not (equal d el))
   (progn
     (if (or (eq (cdr (assoc 0 (entget e))) "ARC") (eq (cdr (assoc 0 (entget e))) "CIRCLE"))
       (setq r (cdr (assoc 40 (entget e))))
       (if (eq (cdr (assoc 0 (entget e))) "POLYLINE")
         (progn
           (command "_.CONVERTPOLY" "_L" e "")
           (setq r (_plsegrad (vlax-ename->vla-object e) pe))
           (command "_.CONVERTPOLY" "_H" e "")
         )
         (setq r (_plsegrad (vlax-ename->vla-object e) pe))
       )
     )
     (setq dn (cdr (assoc 2 (entget d))))
     (setq db (tblobjname "BLOCK" dn))
     (setq dt db)
     (while (/= (cdr (assoc 0 (entget (setq dt (entnext dt))))) "MTEXT"))
     (setq txt (cdr (assoc 1 (entget dt))))
     (setq ang (substr txt (+ 2 (vl-string-search ";" txt))))
     (setq txtn (strcat "\\A1;\\S" ang "^R" (rtos r 2 2) ";"))
     (entmod (subst (cons 1 txtn) (assoc 1 (entget dt)) (entget dt)))
   )
 )
 (*error* nil)
)

 

HTH, M.R.

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