vanowm 发表于 2022-7-5 19:56:37

有办法得到坐标吗

你好
 
使用ssget时,是否有方法在选择对象时捕捉对象上拾取点的坐标?
 
基本上,我在寻找一种方法来确定用户在选择过程中选择了pline的哪一侧。类似于rulesurf命令。
 
非常感谢。

BlackBox 发表于 2022-7-5 20:16:13

不熟悉rulesurf,我也不经常将其用于我自己的使用,但如果SSGET可以做到这一点,它可能会包括+。选择模式字符串。
 
另一种选择是,您知道过滤对象的实体类型:
 

;;...

(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

)
)

;;...

 
HTH,M.R。

Lee Mac 发表于 2022-7-5 20:17:06

marko_ribar 发表于 2022-7-5 20:29:00

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

BlackBox 发表于 2022-7-5 20:38:11

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

Lee Mac 发表于 2022-7-5 20:47:09

 
No worries dude

marko_ribar 发表于 2022-7-5 20:57:23

 
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.
页: [1]
查看完整版本: 有办法得到坐标吗