乐筑天下

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

[编程交流] [Help] How to check if entity

[复制链接]

22

主题

326

帖子

185

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
243
发表于 2022-7-6 08:42:10 | 显示全部楼层 |阅读模式
Please help me, i've a problem :
How to check if entity be viewed in a Viewport ?
For Ex, how can i erase , or locked...or do sth.. all viewport that view into a Line ?
Srr for my poor English and Thanks all ^^
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 08:54:51 | 显示全部楼层
You would need to translate the Viewport Boundary to Modelspace coordinates using the correct transformation matrix based on the scale/twist etc of the viewport (I think gile wrote a function to calculate this matrix), then check whether your objects lie within this point set.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 09:01:52 | 显示全部楼层
 
Found it:

http://www.theswamp.org/index.php?topic=29231.msg347755#msg347755
回复

使用道具 举报

22

主题

326

帖子

185

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
243
发表于 2022-7-6 09:10:40 | 显示全部楼层
Thank you very much Lee  I try it now ^^
P/s : i'm digging Theswamp and lisp..wow.. how a great data to learn and learn and learn...
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 09:17:51 | 显示全部楼层
 
You're welcome
 
 
TheSwamp is awesome - so many clever guys there.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 09:30:44 | 显示全部楼层
As an example for you, this quickly written code will use gile's PCS2WCS function to create an LWPolyline Viewport boundary in Modelspace:
 
  1. (defun c:test ( / _lwvertices _lwpoly cen ent lst vp x )   (defun _lwvertices ( e )       (if (setq e (member (assoc 10 e) e))           (cons (cons (cdr (assoc 10 e)) (assoc 42 e)) (_lwvertices (cdr e)))       )   )   (defun _lwpoly ( l )       (entmakex           (append               (list                  '(0 . "LWPOLYLINE")                  '(100 . "AcDbEntity")                  '(100 . "AcDbPolyline")                   (cons 90 (length l))                  '(70 . 1)                  '(410 . "Model")               )               (apply 'append l)           )       )   )      (if (setq vp (ssget "_+.:E:S" '((0 . "VIEWPORT"))))       (progn           (setq vp (entget (ssname vp 0)))           (if (setq ent (cdr (assoc 340 vp)))               (setq lst (_lwvertices (entget ent)))               (setq cen (mapcar 'list (cdr (assoc 10 vp))                             (list                                 (/ (cdr (assoc 40 vp)) 2.0)                                 (/ (cdr (assoc 41 vp)) 2.0)                             )                         )                     lst (mapcar                             (function                                 (lambda ( a ) (cons (mapcar 'apply a cen) '(42 . 0.0)))                             )                            '((- -) (+ -) (+ +) (- +))                         )               )           )           (setq vp (cdr (assoc -1 vp)))           (_lwpoly (mapcar '(lambda ( x ) (list (cons 10 (PCS2WCS (car x) vp)) (cdr x))) lst))       )   )   (princ))
回复

使用道具 举报

22

主题

326

帖子

185

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
243
发表于 2022-7-6 09:37:33 | 显示全部楼层
Thank you Lee, it gave me some new funny idea  ^^
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 09:45:21 | 显示全部楼层
.........
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-7 09:26 , Processed in 0.373103 second(s), 68 queries .

© 2020-2025 乐筑天下

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