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