乐筑天下

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

[编程交流] Select texts & change color

[复制链接]

30

主题

81

帖子

59

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
146
发表于 2022-7-5 15:36:02 | 显示全部楼层 |阅读模式
help with error code
 
  1. (defun c:somework ()(setvar "cmdecho" 0)(command "_.select" "Fence" "-0.6,1.127" "36.9,1.245" " ")  (command "_.change" "p" "c" "1")(princ))
回复

使用道具 举报

58

主题

3353

帖子

33

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1761
发表于 2022-7-5 15:53:30 | 显示全部楼层
Items selected with the fence method need to be visible on the screen.
 
Try something like this to remove command calls.
  1. (defun c:foo (/ s) (if (setq s (ssget "_F" '((-0.6 1.127) (36.9 1.245))))   (mapcar '(lambda (x) (entmod (append (entget x) '((62 . 1))))) (mapcar 'cadr (ssnamex s))) ) (princ))
回复

使用道具 举报

30

主题

81

帖子

59

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
146
发表于 2022-7-5 16:11:38 | 显示全部楼层
 
thanks a lot
 
if I want to add more lines
Example:   (-0.274,3.183)  (11.324,2.947)
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 16:15:14 | 显示全部楼层
A fence can be as many points as you like, if two seperate lines look into ssad running ssget as required.
  1. (defun c:foo (/ s lst )(setq lst '((-0.6 -1.127) (36.9 1.245) (-0.274 3.183) (11.324 2.947))) ; note comma removed (if (setq s (ssget "_F" lst ))   (mapcar '(lambda (x) (entmod (append (entget x) '((62 . 1))))) (mapcar 'cadr (ssnamex s))) )
  (princ)
)
回复

使用道具 举报

30

主题

81

帖子

59

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
146
发表于 2022-7-5 16:30:52 | 显示全部楼层
 
many thanks Bigal
 
Last question!
If I want to add different color, say color number 2 to this line (-0.6 -1.127) (36.9 1.245)
回复

使用道具 举报

58

主题

3353

帖子

33

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1761
发表于 2022-7-5 16:47:12 | 显示全部楼层
Try this:
  1. (defun c:foo (/ s) ;; List of '((color point point)(color point point)...) (foreach l '((2 (-0.6 1.127) (36.9 1.245)) (1 (-0.274 3.183) (11.324 2.947)))   (if        (setq s (ssget "_F" (cdr l)))     (mapcar '(lambda (x) (entmod (append (entget x) (list (cons 62 (car l))))))      (mapcar 'cadr (ssnamex s))     )   ) ) (princ))
Do you have an example drawing of what you're trying to accomplish? This process seems a bit odd to me.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-7-2 14:41 , Processed in 0.524539 second(s), 64 queries .

© 2020-2025 乐筑天下

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