乐筑天下

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

[编程交流] 在铝的两端放置砌块

[复制链接]

3

主题

9

帖子

6

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 15:19:53 | 显示全部楼层 |阅读模式
你好
 
有人能帮我用lisp吗?我有一个块,我想用lisp把它放在所有行的两端
 
为了更好地理解,我还附上了同样的图片
 
提前感谢
161953w9cdsg7e7qcecfq9.jpg
回复

使用道具 举报

24

主题

1265

帖子

1028

银币

后起之秀

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

铜币
362
发表于 2022-7-5 15:29:24 | 显示全部楼层
是否有任何线路共享一个公共端点?
如果是这样,你想在那里住一个或两个街区吗?
回复

举报

66

主题

1552

帖子

1514

银币

后起之秀

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

铜币
325
发表于 2022-7-5 15:31:17 | 显示全部楼层
  1. (defun-q C:BlockOnBothEndsOfLine nil
  2. ( '( ( f L ) (if L (apply (function f) (cons 0 L))))
  3.    '( (i a b c / tmp)
  4.      (and
  5.        (setq tmp (ssname b i))
  6.        (setq tmp (entget tmp))
  7.        (mapcar ''( (x) (vlax-invoke c 'InsertBlock (cdr (assoc x tmp)) a 1 1 1 0)) '(10 11))
  8.        (f (1+ i) a b c)
  9.      )
  10.    )
  11.    ( '( (f L / tmp) (if (= (length L) (length (setq tmp (f L)))) tmp))
  12.      '( ( L / tmp ) (if (and L (setq tmp (eval (car L)))) (cons tmp (f (cdr L)))) )
  13.      '(
  14.        ('((v) (if (and v (member '(0 . "INSERT") (entget v)))  (vla-get-EffectiveName (vlax-ename->vla-object v)))) (car (entsel "\nPick the block: ")))
  15.        (progn (princ "\nSelect the lines: ") (ssget '((0 . "LINE"))))
  16.        ( '((f)(f (vlax-get-acad-object) (reverse '(Block ActiveLayout ActiveDocument))))
  17.          (lambda ( o L / tmp) (if (setq tmp (car L))  (f (vlax-get o tmp) (cdr L)) o ))
  18.        )
  19.      )
  20.    )
  21. )
  22. (princ)
  23. )
回复

举报

58

主题

3353

帖子

33

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1761
发表于 2022-7-5 15:39:58 | 显示全部楼层
另一个是露齿而笑
  1. (defun c:foo (/ e o s tmp)
  2. (if (and (setq e (car (entsel "\nSelect a block to copy: ")))
  3.    (vlax-write-enabled-p (setq o (vlax-ename->vla-object e)))
  4.    (vlax-property-available-p o 'insertionpoint)
  5.    (setq s (ssget '((0 . "line"))))
  6.      )
  7.    (foreach l (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
  8.      (mapcar '(lambda (x)
  9.          (and (not (vl-position x tmp))
  10.               (setq tmp (cons x tmp))
  11.               (setq o (vla-copy o))
  12.               (vlax-put o 'insertionpoint x)
  13.          )
  14.        )
  15.       (list (vlax-curve-getstartpoint l) (vlax-curve-getendpoint l))
  16.      )
  17.    )
  18. )
  19. (princ)
  20. )
  21. (vl-load-com)
回复

举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-5 15:46:08 | 显示全部楼层
你好
就这么简单。
  1. (defun c:test (/ pck sel int ent get bnm)
  2. (and
  3.    (setq pck (car (entsel "\nPick on the target block :")))
  4.    (or (and (= (cdr (assoc 0 (setq get (entget pck)))) "INSERT")
  5.             (null (assoc 66 get))
  6.        )
  7.        (alert "Invalid object. Try again.<!>")
  8.    )
  9.    (princ
  10.      (strcat "\nSelect Polyline/Line(s) to place <"
  11.              (setq bnm (vla-get-effectivename (vlax-ename->vla-object pck)))
  12.              "> at their Endpoints :"
  13.      )
  14.    )
  15.    (setq int -1
  16.          sel (ssget '((0 . "LINE,LWPOLYLINE")))
  17.    )
  18.    (while (setq ent (ssname sel (setq int (1+ int))))
  19.      (foreach p (list (vlax-curve-getstartpoint ent) (vlax-curve-getendpoint ent))
  20.        (entmake (list '(0 . "INSERT") (cons 2 bnm) (cons 10 (trans p 0 1))))
  21.      )
  22.    )
  23. )
  24. (princ)
  25. ) (vl-load-com)
回复

举报

5

主题

956

帖子

963

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 15:50:55 | 显示全部楼层
OP是幸运的3种不同的方法
@grrr vla插入块方法
@ronjonp vla复制方法&删除重复项
@Tharwat entmake方法美观简单
回复

举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-5 15:54:29 | 显示全部楼层
谢谢hanhphuc。
祝您今天过得愉快。
回复

举报

58

主题

3353

帖子

33

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1761
发表于 2022-7-5 15:59:47 | 显示全部楼层
 
我选择了复制方法,因此块将保留其层/比例/旋转等。。。
回复

举报

3

主题

9

帖子

6

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 16:05:20 | 显示全部楼层
感谢分享Grrr
回复

举报

3

主题

9

帖子

6

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 16:09:10 | 显示全部楼层
感谢分享ronjonp
回复

举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-14 10:38 , Processed in 0.914878 second(s), 75 queries .

© 2020-2025 乐筑天下

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