乐筑天下

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

[编程交流] 多段线上的GRVEC

[复制链接]

66

主题

1552

帖子

1514

银币

后起之秀

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

铜币
325
发表于 2022-7-5 17:22:43 | 显示全部楼层 |阅读模式
大家好,
最近几天,我试图在闭合多段线的顶点上做一些事情。
仍不成功。。那么,你能看看可能出了什么问题吗
 
  1. (setq bply-verts (mapcar 'cdr (vl-remove-if '(lambda (x) (/= (car x) 10)) bply-elist)))
  2. (grvecs (list -3 bply-verts)) ; <- I've seen Tharwat doing something like this, instead of whats been written in HELP

我仍然在想到底出了什么问题,因为我不能使用“MkWipeout”子函数——即使我提供了正确的点列表。
回复

使用道具 举报

18

主题

1529

帖子

973

银币

中流砥柱

Rank: 25

铜币
649
发表于 2022-7-5 17:40:46 | 显示全部楼层
4件事:
 
1.
我无法复制您的错误消息(“自动错误。对象已被擦除”)。
 
2.
我必须更改命令调用(注意:我使用BricsCAD而不是AutoCAD):
(vl cmdf“_。-boundary”“\u advanced”“\u island”“\u no”“pt”“)
为了便于阅读,我不希望缩写命令选项。
 
3.
函数grvecs需要不同格式的列表。
在最初的帖子中,您有:
(GRVEC(列表3(列表ptA ptB ptC ptD)))
这必须是:
(grvecs(列表-3 ptA ptB ptB ptC ptD ptD ptA))
实现这一点的一种方法:
  1. Command: test
  2. Pick a point inside a closed boundary: Automation Error. Object was erased
4。
为了使MkWipeout生成的擦除正确显示,我必须将(70.7)添加到entmakex列表中:
  1. ;;  Requires a point list and layer name
  2. (defun MkWipeout (lst lay / c m p)
  3. (setq lst (cons (last lst) lst)
  4.         p (apply 'mapcar (cons 'min lst))
  5.         m (apply 'max (mapcar '- (apply 'mapcar (cons 'max lst)) p))
  6.         c (mapcar '+ p (list (/ m 2.0) (/ m 2.0)))
  7. )
  8. (entmakex
  9.         (append
  10.                 (list
  11.                         '(000 . "WIPEOUT")
  12.                         '(100 . "AcDbEntity")
  13.                         '(100 . "AcDbWipeout")
  14.                         (cons 8 lay)
  15.                         (cons 10 (trans p 1 0))
  16.                         (cons 11 (trans (list m 0.0) 1 0))
  17.                         (cons 12 (trans (list 0.0 m) 1 0))
  18.                         '(280 . 1)
  19.                         '(071 . 2)
  20.                 )
  21.                 (mapcar
  22.                         (function
  23.                                 (lambda (x)
  24.                                 (cons 14 (mapcar '(lambda (a b c) (/ (- a b) c)) x c (list m (- m)))))) lst)))
  25. )
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

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

铜币
325
发表于 2022-7-5 17:45:47 | 显示全部楼层
下面是另一种选择,使用grdraw:
PS:FWIW,擦除代码实际上是我从这个线程得到的。
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

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

铜币
325
发表于 2022-7-5 17:58:05 | 显示全部楼层
非常感谢你的修改和帮助,罗伊!
正确使用上述解决方案中的GRVEC或grdraw时,自动化错误消失。
我不太擅长列表操作,很明显,我很高兴在这个论坛上有一个更有经验的LISPer回复。
 
李,很抱歉造成了混乱。。我指的是CAB的子功能,它是根据您最初的wipeout代码创建的(我从同一个线程中获取),但现在我将使用您的LM:polywipeout。
aa谢谢你的替代代码!
 
我最初的想法是从闭合多段线创建一个覆盖,但后来我决定练习使用GRVEC和grtext。
现在有趣的是,所有发布的解决方案都可以工作,但不会使实际的结果消失(至少在我尝试我的计算机时)。有人能证实这一点吗?
回复

使用道具 举报

18

主题

1529

帖子

973

银币

中流砥柱

Rank: 25

铜币
649
发表于 2022-7-5 18:03:35 | 显示全部楼层
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 18:22:32 | 显示全部楼层
Here is an alternative, using grdraw:
  1. (defun c:test ( / *error* enl enx lst ply pnt )   (defun *error* ( msg )       (if (and (= 'ename (type ply)) (entget ply)) (entdel ply))       (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))           (princ (strcat "\nError: " msg))       )       (redraw) (grtext) (princ)   )   (while (setq pnt (getpoint "\nPick a point within a closed boundary : "))       (redraw)       (setq enl (entlast))       (vl-cmdf "_.-boundary" "_A" "_I" "_N" "" "_O" "_P" "" "_non" pnt "")       (if (and (not (eq enl (setq ply (entlast))))                (setq enx (entget ply))                (= "LWPOLYLINE" (cdr (assoc 0 enx)))                (= 1 (logand 1 (cdr (assoc 70 enx))))           )           (progn               (mapcar                  '(lambda ( a b ) (grdraw a b 3 1))                   (setq lst (mapcar 'cdr (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) enx)))                   (cons (last lst) lst)               )               (LM:polywipeout lst)               (grtext -1 (strcat "Enclosed area: " (rtos (vlax-curve-getarea ply) 2 0) " m2"))               (entdel ply)           )           (princ "\nNo valid boundary found.")       )   )   (redraw) (grtext) (princ));; Polygonal Wipeout  -  Lee Mac;; Constructs a polygonal wipeout with vertices positioned at the supplied coordinates.;; l - [lst] List of wipeout vertices (UCS)(defun LM:polywipeout ( l / c m p )   (setq l (cons (last l) l)         p (apply 'mapcar (cons 'min l))         m (apply 'max (mapcar '- (apply 'mapcar (cons 'max l)) p))         c (mapcar '+ p (list (/ m 2.0) (/ m 2.0)))   )   (entmakex       (append           (list              '(000 . "WIPEOUT")              '(100 . "AcDbEntity")              '(100 . "AcDbWipeout")               (cons 10 (trans p 1 0))               (cons 11 (trans (list m 0.0) 1 0))               (cons 12 (trans (list 0.0 m) 1 0))              '(280 . 1)              '(070 . 7)              '(071 . 2)           )           (mapcar               (function                   (lambda ( x )                       (cons 14 (mapcar '(lambda ( a b c ) (/ (- a b) c)) x c (list m (- m))))                   )               )               l           )       )   ))(vl-load-com) (princ)
PS: FWIW, the wipeout code is actually mine from this thread.
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

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

铜币
325
发表于 2022-7-5 18:23:27 | 显示全部楼层
Thanks alot for your revision and help, Roy!
The automation error disappeared when using correctly grvecs or grdraw from the solutions above.
I'm not that good with list manipulation, obviously and I'm happy that theres one more experienced LISPer in this forum who replies.
 
Sorry for the created confusion, Lee.. I was refering to CAB's subfunction - created from your original wipeout code (I took it from the same thread) but now I'll use your LM:polywipeout instead.
Aaand thanks for the alternative code!
 
My initial idea was to create a wipeout from a closed polyline, but then I've decided to put some practice with using grvecs and grtext.
Now the funny thing is that all of the posted solutions work, but won't entmakex the actual wipeout (atleast when I try on my computer). Can anyone confirm this?
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-13 04:18 , Processed in 0.617662 second(s), 66 queries .

© 2020-2025 乐筑天下

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