乐筑天下

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

[编程交流] count blocks & set lookup1

[复制链接]

73

主题

261

帖子

195

银币

后起之秀

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

铜币
375
发表于 2022-7-5 15:28:34 | 显示全部楼层 |阅读模式
Hello lisp artists,
need some help with these lisps, I want to automatically set the cable tags (block "kabeltype A or B") in the attached drawing.
The lisp should count the blocks in a range than set the lookup1 from the "kabeltype A or B" block.
Lisp "test1" counts the blocks in a range. (does not work well, counts more blocks).
Lisp "test2" set the "lookup1" table of selected block (block "kabeltype A or B") (this should go automatically).
All cabletags have the attribute "TEXT1" and have the value of the first value of a module (EIDS, ETV or I / O).
Can someone help me with these lisps, especially at the first (test1) for counting the blocks ...
 
  1. (defun c:test1 ()(defun filter_set (blk tag lo hi / ss olst) (vl-load-com) (if (setq ss (ssget "_X" (list (cons 0 "INSERT") (cons 2 blk) (cons 66 1))))   (foreach blk (mapcar 'cadr (ssnamex ss))     (foreach att (vlax-invoke (vlax-ename->vla-object blk) 'getattributes)   (and (eq tag (vla-get-tagstring att))        (not (vla-object (car en))) (setq dblist (vlax-invoke eo 'GetDynamicBlockProperties)) (foreach dbprop dblist   (if (= (vla-get-PropertyName dbprop) "Lookup1")       (vlax-put dbprop 'Value "8"))))
 
 
 
thanks in advance
 
PmxCAD
Opt1.dwg
回复

使用道具 举报

58

主题

3353

帖子

33

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1761
发表于 2022-7-5 15:43:31 | 显示全部楼层
 
Here's a quick one to get you started.
  1. (defun c:foo (/ ss) (if (setq ss (ssget "_X" (list '(0 . "INSERT") '(66 . 1))))   (foreach b (mapcar 'cadr (ssnamex ss))     (if (null        (vl-some '(lambda (x) (= "TEXT1" (vla-get-tagstring x)))                 (vlax-invoke (vlax-ename->vla-object b) 'getattributes)        )  )(ssdel b ss)     )   ) ) (sssetfirst nil ss) (princ))
回复

使用道具 举报

73

主题

261

帖子

195

银币

后起之秀

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

铜币
375
发表于 2022-7-5 15:52:53 | 显示全部楼层
ronjonp, Thanks for your anwser.
I'm not that good with lisp.  I Can change it a bit and do some modifications.
As far as your lisp is concerned, it selects all the blocks with the tag TEXT1.
I'm not sure how I should apply it. I tried it in the existing lisp, but then the result remains the same, it counts all blocks (13) and yours lisp select everything.
 
PmxCAD
回复

使用道具 举报

rlx

21

主题

1505

帖子

1551

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
81
发表于 2022-7-5 16:06:23 | 显示全部楼层
dynamic blocks? -> get effective name
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 16:09:53 | 显示全部楼层
My $0.05 which may not be right need a dwg to test.
 
  1. (defun c:foo (/ ss)(setq count 0) (if (setq ss (ssget "_X" (list '(0 . "INSERT") '(2 . "Sab-kast,U00009,U00017,U00028,U00039") '(66 . 1)))); count could be added into foreach (setq count (+ count 1))
回复

使用道具 举报

73

主题

261

帖子

195

银币

后起之秀

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

铜币
375
发表于 2022-7-5 16:24:40 | 显示全部楼层
 
is not necessary if dynamic blocks are not yet changed. you can select them as regular blocks. they are not yet Anonymous.
回复

使用道具 举报

73

主题

261

帖子

195

银币

后起之秀

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

铜币
375
发表于 2022-7-5 16:32:29 | 显示全部楼层
Almost working,
Have a problem with the selection in "test3". Want to select the previous selection with entlast. I'm still playing around with the entsel or entlast. Do not get it working.
Does anyone have a suggestion?
 

[code](defun c:test1 (); Lee Mac(defun filter_set (blk tag lo hi / ss olst) (vl-load-com) (if (setq ss (ssget "_X" (list (cons 0 "INSERT") (cons 2 blk) (cons 66 1))))   (foreach blk (mapcar 'cadr (ssnamex ss))     (foreach att (vlax-invoke (vlax-ename->vla-object blk) 'getattributes)   (and (eq tag (vla-get-tagstring att))        (not (
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-14 13:08 , Processed in 0.421029 second(s), 66 queries .

© 2020-2025 乐筑天下

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