找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1007|回复: 4

[讨论]:cad中如何编程实现将所选实体(不按层)隐藏,消隐?

[复制链接]
发表于 2002-5-15 19:49:03 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
cad中如何编程实现将所选实体(不按层)隐藏,消隐?
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2002-5-15 20:00:25 | 显示全部楼层

Re: [讨论]:cad中如何编程实现将所选实体(不按层)隐藏,消隐?

最初由 梦断江南 发布
cad中如何编程实现将所选实体(不按层)隐藏,消隐?

我的处理办法是根据所选择的实体所在的层创建新的临时层(在原层名前加前缀FRE_),然后把实体变到该层上,最后把该层冻结或关掉。恢复时在执行相反的操作。但由于恢复时无法选择到这些实体,所以只能一次把某一冻结层上的实体全部恢复转换回来。在我的asde软件中有两个命令:部分图快冻结,解冻所有图块命令及实现上述功能。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2002-5-15 20:05:15 | 显示全部楼层

  1. ;;;---------------------------------------------------------------------------;
  2. ;;;
  3. ;;;   BLANK.LSP   Version 1.0
  4. ;;;
  5. ;;;   Copyright (C) 1995 by Autodesk, Inc.
  6. ;;;
  7. ;;;   Permission to use, copy, modify, and distribute this software and its
  8. ;;;   documentation for any purpose and without fee is hereby granted.
  9. ;;;
  10. ;;;   THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
  11. ;;;   ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
  12. ;;;   MERCHANTABILITY ARE HEREBY DISCLAIMED.
  13. ;;;
  14. ;;;---------------------------------------------------------------------------;
  15. ;;;   BLANK, UNBLANK, and UNBLANKALL
  16. ;;;
  17. ;;;   This module provides functions to manipulate the visibility field of
  18. ;;;   AutoCAD objects.  BLANK will make a selection set of objects invisible.
  19. ;;;   UNBLANK will make a specified object (given its handle) visible.
  20. ;;;   UNBLANKALL will make all blanked entities visible.
  21. ;;;
  22. ;;;---------------------------------------------------------------------------;


  23. ;;;---------------------------------------------------------------------------;
  24. ;;; Internal error handling.
  25. ;;;---------------------------------------------------------------------------;
  26. (defun blank_error(s)
  27.   ;; The strings in the following statements can be translated.
  28.   (if (/= s ;|MSG1|;"Function cancelled")
  29.     (princ (strcat ;|MSG2|;"\nBLANK Error: " s))
  30.   )
  31.   (setq *error* olderr)
  32.   (princ)
  33. )

  34. (defun unblank_error(s)
  35.   ;; The strings in the following statements can be translated.
  36.   (if (/= s ;|MSG3|;"Function cancelled")
  37.     (princ (strcat ;|MSG3|;"\nUNBLANK Error: " s))
  38.   )
  39.   (setq *error* olderr)
  40.   (princ)
  41. )

  42. (defun blank60 (e / e2)
  43.   (if (not (null (assoc '60 e)))
  44.     (setq e2 (subst '(60 . 1) '(60 . 0) e))
  45.     (setq e2 (append e '((60 . 1))))
  46.   )
  47. )   

  48. (defun show60 (e / e2)
  49.   (if (not (null (assoc '60 e)))
  50.      (setq e2 (subst '(60 . 0) '(60 . 1) e))
  51.      (setq e2 (append e '((60 . 0))))
  52.   )
  53. )

  54. (defun setvis ( vis ename / e)
  55.   (setq e (entget ename))
  56.   (if (eq vis 0)
  57.      (entmod (show60 e))
  58.      (entmod (blank60 e))
  59.   )
  60.   (entupd ename)
  61.   ;; Blank vertices of polyline, if necessary
  62.   (if (eq (cdr (nth 1 e)) "POLYLINE")
  63.     (progn
  64.       (setq ename (entnext ename))
  65.       (setq e (entget ename))
  66.       (while (eq (cdr (nth 1 e)) "VERTEX")
  67.         (if (eq vis 0)
  68.            (entmod (show60 e))
  69.            (entmod (blank60 e))
  70.         )
  71.         (entupd ename)
  72.         (setq ename (entnext ename))
  73.         (setq e (entget ename))
  74.       ) ; while
  75.     ) ; progn
  76.   ) ; if polyline
  77.   (if (and (eq (cdr (nth 1 e)) "INSERT")
  78.            (assoc '66 e))
  79.     (progn
  80.       (setq ename (entnext ename))
  81.       (setq e (entget ename))
  82.       (while (eq (cdr (nth 1 e)) "ATTRIB")
  83.         (if (eq vis 0)
  84.            (entmod (show60 e))
  85.            (entmod (blank60 e))
  86.         )
  87.         (entupd ename)
  88.         (setq ename (entnext ename))
  89.         (setq e (entget ename))
  90.       ) ; while
  91.     ) ; progn
  92.   )
  93. )

  94. (defun c:blank ( ) ;;; / olderr echo ss i ename )
  95.   (setq olderr *error*                ; Redefine error handler.
  96.         echo (getvar ;|MSG0|;"cmdecho")
  97.         *error* blank_error)
  98.   (setvar ;|MSG0|;"cmdecho" 0)                ; Turn off cmdecho sysvar
  99.   (command ;|MSG0|;"_.undo" ;|MSG0|;"_group")

  100.   (setq ss (ssget))
  101.   (setq i 0)
  102.   (while (< i (sslength ss)) (progn
  103.      (setq ename (ssname ss i))
  104.      (setvis 1 ename)
  105.      (setq i (1+ i))
  106.   ))

  107.   (setq *error* old_error)            ; restore error function
  108.   (command ;|MSG0|;"_.undo" ;|MSG0|;"_end")
  109.   (setvar ;|MSG0|;"cmdecho" echo)             ; restore cmdecho sysvar
  110.   (princ)                             ; Quiet exit.
  111. )

  112. (defun c:unblankall ( ) ;;; / olderr echo ss i ename )
  113.   (setq olderr *error*                ; Redefine error handler.
  114.         echo (getvar ;|MSG0|;"cmdecho")
  115.         *error* unblank_error)
  116.   (setvar ;|MSG0|;"cmdecho" 0)                ; Turn off cmdecho sysvar
  117.   (command ;|MSG0|;"_.undo" ;|MSG0|;"_group")

  118.   ;; Select all blanked entities
  119.   (setq ss (ssget ;|MSG0|;"_x" '((60 . 1))))
  120.   (if (not (null ss))
  121.     (progn
  122.       (setq i 0)
  123.       (princ (sslength ss))
  124.       (princ " blanked entities found.\n");
  125.       ;; Unblank each entity in the set
  126.       (while (< i (sslength ss)) (progn
  127.          (setq ename (ssname ss i))
  128.          (setvis 0 ename)
  129.          (setq i (1+ i))
  130.       ))
  131.     )   
  132.     (princ "\n0 blanked entities found.\n");
  133.   )

  134.   (setq *error* old_error)            ; restore error function
  135.   (command ;|MSG0|;"_.undo" ;|MSG0|;"_end")
  136.   (setvar ;|MSG0|;"cmdecho" echo)             ; restore cmdecho sysvar
  137.   (princ)                             ; Quiet exit.
  138. )

  139. (defun c:unblank ( ) ;;; / olderr echo ss i ename hand )
  140.   (setq olderr *error*                ; Redefine error handler.
  141.         echo (getvar ;|MSG0|;"cmdecho")
  142.         *error* unblank_error)
  143.   (setvar ;|MSG0|;"cmdecho" 0)                ; Turn off cmdecho sysvar
  144.   (command ;|MSG0|;"_.undo" ;|MSG0|;"_group")

  145.   (setq hand (getstring ;|MSG5|;"\nEnter handle of entity to be unblanked: "))
  146.   ;; Unblank the entity if handle is not an empty string
  147.   (if (> (strlen hand) 0)
  148.     (progn
  149.       (setq ename (handent hand))
  150.       (if (/= nil ename)
  151.         (setvis 0 ename)
  152.         (princ ;|MSG6|;"Invalid handle.")
  153.       )
  154.     )
  155.   )

  156.   (setq *error* old_error)            ; restore error function
  157.   (command ;|MSG0|;"_.undo" ;|MSG0|;"_end")
  158.   (setvar ;|MSG0|;"cmdecho" echo)             ; restore cmdecho sysvar
  159.   (princ)                             ; Quiet exit.
  160. )
  161. (princ)
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 145个

财富等级: 日进斗金

发表于 2002-5-15 20:33:35 | 显示全部楼层

Re: [讨论]:cad中如何编程实现将所选实体(不按层)隐藏,消隐?

最初由 梦断江南 发布
[B]cad中如何编程实现将所选实体(不按层)隐藏,消隐? [/B]


晓东工具箱-对象工具箱下已经有了:隐藏实体和取消隐藏两个命令。


  1. [FONT=courier new]
  2. 1、LISP方法:
  3.    给实体加组码 60 =1
  4.      默认情况下没有60组码,因此要加入'(60 . 1)
  5.    
  6.      恢复的时候,把组码60=0 即可,LISP会自动从实体数据里面去掉60组码。

  7. 2、ARX方法(使用AcDbEntity类自身的方法)

  8.    pEnt->setVisibility(....)

  9. 3、XDRX_API方法:

  10.   两种:
  11.     a、xdrx_entity_visible (可以对选择集操作,使用ARX方法)
  12.               功能:设置一个实体的可见性

  13.        调用格式:(xdrx_entity_visible <实体或者选择集> [可见标记])


  14.         b、xdrx_modent 修改60组码
  15.       
  16.        (xdrx_setenttodb ent)
  17.              (xdrx_modent 60 1)
  18. [/FONT]
复制代码
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2003-12-11 13:49:10 | 显示全部楼层
(entget (car (entsel)))能够去出组码可是如何将(60 . 1)加入进去呀
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2025-10-11 00:16 , Processed in 0.604579 second(s), 40 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表