乐筑天下

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

[编程交流] lisp将所有实体移动到l

[复制链接]

42

主题

173

帖子

132

银币

后起之秀

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

铜币
220
发表于 2022-7-5 18:13:34 | 显示全部楼层 |阅读模式
大家好
我有这个Lisp程序的程序
  1. (vl-load-com)
  2. (defun c:COMBINELAYERS(/ doc blocks blk eo layers lay)
  3. ;CHANGE BY LAYER COLOR TO OVERRIDE COLOR
  4. ;; Get the ActiveX object of the current dwg
  5. (setq doc    (vla-get-ActiveDocument (vlax-get-acad-object))
  6.        blocks (vla-get-Blocks doc) ;Get the blocks collection
  7.        layers (vla-get-Layers doc) ;Get the layers collection
  8. ) ;_ end of setq
  9. ;; Step through all blocks (including Model Space & Layouts)
  10. (vlax-for blk blocks
  11.    ;; Step through all contained entities in block
  12.    (vlax-for eo blk
  13.      ;; Get the layer the entity is placed on
  14.      (setq lay (vla-Item layers (vla-get-Layer eo)))
  15.      (vla-put-Layer eo (getvar "CLAYER")) ;Change the entity to the current layer
  16.      (if (= (vla-get-Color eo) 256)
  17.        ;;If its colour bylayer, change it to overridden color to match
  18.        (vla-put-Color eo (vla-get-color lay))
  19.      ) ;_ end of if
  20.      (if (= (strcase (vla-get-Linetype eo)) "BYLAYER")
  21.        ;;If its linetype bylayer, change it to overridden linetype to match
  22.        (vla-put-Linetype eo (vla-get-Linetype lay))
  23.      ) ;_ end of if
  24.      (if (= (vla-get-Lineweight eo) -1)
  25.        ;;If its lineweight bylayer, change it to overridden lineweigth to match
  26.        (vla-put-Lineweight eo (vla-get-Lineweight lay))
  27.      ) ;_ end of if
  28.    ) ;_ end of vlax-for
  29. ) ;_ end of vlax-for
  30. (princ)
  31. ) ;_ end of defun

将所有对象(包括块子图元)移动到第0层或当前层。。并将所有bylayer颜色的对象更改为不考虑颜色
 
但我申请了所有的图纸,没有选择
 
我希望lisp要求用户选择要应用到的对象。。。提前感谢
回复

使用道具 举报

55

主题

402

帖子

357

银币

后起之秀

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

铜币
274
发表于 2022-7-5 18:45:28 | 显示全部楼层
试试这个:-
您只能更改选定对象。。。
注意-块内的对象不会更改,只会更改块颜色(如果已设置为“按块”)和图层。不能更改块实体,因为它将更改块定义,并反映对远离选定块的其他块的影响。希望你明白我的意思
  1. (defun c:test (/ a b i)
  2. (if (setq a (ssget))
  3.    (repeat (setq i (sslength a))
  4.      (setq b (vlax-ename->vla-object (ssname a (setq i (1- i)))))
  5.      (vla-put-layer b "sat")                ;Replace "0" with (getvar "CLAYER") for current layer
  6.      (vla-put-color b 256)
  7.    )
  8. )
  9. (princ)
  10. )
回复

使用道具 举报

42

主题

173

帖子

132

银币

后起之秀

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

铜币
220
发表于 2022-7-5 19:30:33 | 显示全部楼层
@satishrajdev感谢您的回复。。。您可以修改我的lisp,让用户从图形中选择对象吗?我对lisps及其编码相当陌生。。。
谢谢你的支持
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-12 20:38 , Processed in 0.392804 second(s), 58 queries .

© 2020-2025 乐筑天下

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