乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 6|回复: 6

[编程交流] 有办法得到坐标吗

[复制链接]

31

主题

106

帖子

76

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
154
发表于 2022-7-5 19:56:37 | 显示全部楼层 |阅读模式
你好
 
使用ssget时,是否有方法在选择对象时捕捉对象上拾取点的坐标?
 
基本上,我在寻找一种方法来确定用户在选择过程中选择了pline的哪一侧。类似于rulesurf命令。
 
非常感谢。
回复

使用道具 举报

44

主题

3166

帖子

2803

银币

中流砥柱

Rank: 25

铜币
557
发表于 2022-7-5 20:16:13 | 显示全部楼层
不熟悉rulesurf,我也不经常将其用于我自己的使用,但如果SSGET可以做到这一点,它可能会包括+。选择模式字符串。
 
另一种选择是,您知道过滤对象的实体类型:
 
  1. ;;...
  2. (if
  3. (and
  4.    (setq e (entsel "\nSelect polyline: "))
  5.    (wcmatch (cdr (assoc 0 (setq d (entget e)))) "*POLYLINE")
  6. )
  7. (progn
  8.    (prompt "\nCoordinate: ")
  9.    (princ (last d))
  10.    ;;<-- do something useful
  11. )
  12. )
  13. ;;...

 
HTH,M.R。
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 20:17:06 | 显示全部楼层
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 2022-7-5 20:29:00 | 显示全部楼层
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...
回复

使用道具 举报

44

主题

3166

帖子

2803

银币

中流砥柱

Rank: 25

铜币
557
发表于 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
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 20:47:09 | 显示全部楼层
 
No worries dude
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 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... :
 
  1. (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.
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-12 00:54 , Processed in 0.625007 second(s), 66 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表