明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3221|回复: 10

感谢G版再次出手相助!为什么不能删除块中WIPEOUT实体呢?

[复制链接]
发表于 2012-6-20 14:53:06 | 显示全部楼层 |阅读模式
本帖最后由 smartstar 于 2012-6-29 12:53 编辑

下面程序哪里有问题,为什么不能删除块中WIPEOUT实体呢?
(defun c:111 ()
  (defun GRP (GCC EL) (cdr (assoc GCC EL)))
  (setq BlkEntName (car (entsel)))
  (setq Blist (ayGetAllEntInBLK BlkEntName))
  (setq n 0)
  (while (< n (length Blist))
    (setq ENAME (nth n Blist))
    (if        (= "WIPEOUT" (GRP 0 (entget ENAME)))
        (entdel ENAME)
    )
    (setq n (1+ n))
  )
  (princ)
)
;;;以下是晓城的子程,写的非常棒!!
;;;普通浏览复制代码
;;;***********************************************************
;;; No.1-2  获取图块内的所有非图块对象(含嵌套块中的)名称 函数
;;;***********************************************************
(defun ayGetAllEntInBLK  (BlkEntName / xBlkName xBlkDef entName1 entType entNameList)
  (setq xBlkName (cdr (assoc 2 (entget BlkEntName))))
  (setq xBlkDef (tblobjname "Block" xBlkName))
  (while (setq entName1 (entnext xBlkDef))
    (setq entType (cdr (assoc 0 (entget entName1))))
    (if        (= entType "INSERT")
      (setq entNameList
             (append (ayGetAllEntInBLK entName1) entNameList)
      )
      (setq entNameList (cons entName1 entNameList))
    )                                        ;end_if
    (setq xBlkDef entName1)
  )                                        ;end_while   entNameList
  entNameList
)                                        ;end_defun
(princ)

"觉得好,就打赏"
还没有人打赏,支持一下
 楼主| 发表于 2012-6-21 10:40:26 来自手机 | 显示全部楼层
恳请高人出手相助,谢谢。
 楼主| 发表于 2012-6-21 20:14:44 来自手机 | 显示全部楼层
顶出答案。
发表于 2012-6-21 21:07:00 | 显示全部楼层
这样就行。
游客,本帖隐藏的内容需要发帖数高于 5 才可浏览,你当前发帖数只有 0
 楼主| 发表于 2012-6-25 12:28:28 | 显示全部楼层
ZZXXQQ 发表于 2012-6-21 21:07
这样就行。
[/post]

谢谢版主回复。
试用了一下,没有成功。而且您给的程序里也没有对嵌套块的处理。
发表于 2012-6-25 13:18:54 | 显示全部楼层
smartstar 发表于 2012-6-25 12:28
谢谢版主回复。
试用了一下,没有成功。而且您给的程序里也没有对嵌套块的处理。

  1. (defun delblkwipe  (blkname / blkdef objname)
  2.   (setq        blkdef
  3.          (vla-item (vla-get-blocks
  4.                      (vla-get-ActiveDocument (vlax-get-acad-object)))
  5.                    blkname))
  6.   (if (/= :vlax-true (vla-get-IsXRef blkdef))
  7.     (vlax-for obj  blkdef
  8.       (cond
  9.         ((= "AcDbWipeout" (setq objname (vla-get-ObjectName obj)))
  10.          (vla-delete obj)
  11.          )
  12.         ((or (= "AcDbMInsertBlock" objname)
  13.              (= "AcDbBlockReference" objname)
  14.              )
  15.          (delblkwipe (vla-get-name obj))
  16.          )
  17.         )
  18.       )
  19.     )
  20.   )
  21. ;;
  22. (defun c:111(/ e)
  23.   (while (and (setq e (car(entsel)))
  24.               (=  "INSERT" (cdr (assoc 0 (entget e))))
  25.               )
  26.     (delblkwipe (cdr (assoc 2 (entget e))))
  27.     (command "_.regen")
  28.     )
  29.   (princ)
  30.   )

点评

试用了,很完美!谢谢G版主。但如过不是删除WIPEOUT实体,而是将其转化为pline线可以吗?  发表于 2012-6-26 09:00
 楼主| 发表于 2012-6-27 18:12:08 来自手机 | 显示全部楼层
劳烦G版主再修改一下。达到功能:将WIPEOUT实体转化为pline线,若不能转成pline线,炸成line线也行。G版主辛苦了,谢谢。
 楼主| 发表于 2012-6-28 18:21:49 来自手机 | 显示全部楼层
劳烦G版主再次出手相助,谢谢。
发表于 2012-6-28 22:19:43 | 显示全部楼层
smartstar 发表于 2012-6-28 18:21
劳烦G版主再次出手相助,谢谢。

  1. ;; WO2PL (gile)
  2. ;; Re-creates a wipeout boundary (lwpolyline)
  3. ;; http://www.theswamp.org/index.php?topic=28059.msg336431#msg336431
  4. ;; returns the wipeout point list (WCS)
  5. (defun wipeout2plst (wo / elst u v mat)
  6.   (setq         elst (entget wo)
  7.          u    (cdr (assoc 11 elst))
  8.          v    (cdr (assoc 12 elst))
  9.          mat  (list u (mapcar '- v) '(0. 0. 1.))
  10.   )
  11.   (mapcar
  12.     '(lambda (p)
  13.        (mapcar '+
  14.                 (mxv (trp mat) p)
  15.                 (mapcar '(lambda (x y) (/ (+ x y) 2.)) u v)
  16.                 (cdr (assoc 10 elst))
  17.        )
  18.      )
  19.     (cdr
  20.       (mapcar 'cdr
  21.                (vl-remove-if-not '(lambda (x) (= (car x) 14)) elst)
  22.       )
  23.     )
  24.   )
  25. )

  26. ;; Transpose a matrix Doug Wilson
  27. (defun trp (m)
  28.   (apply 'mapcar (cons 'list m))
  29. )
  30. (mapcar 'list '(1 2 3) '(4 5 6)  '(7 8 9 10))

  31. ;; Apply a transformation matrix to a vector by Vladimir Nesterovsky
  32. (defun mxv (m v)
  33.   (mapcar '(lambda (r) (apply '+ (mapcar '* r v))) m)
  34. )
  35. (defun delblkwipe  (blkname / blkdef objname)

  36.   (setq        blkdef

  37.          (vla-item (vla-get-blocks

  38.                      (vla-get-ActiveDocument (vlax-get-acad-object)))

  39.                    blkname))

  40.   (if (/= :vlax-true (vla-get-IsXRef blkdef))

  41.     (vlax-for obj  blkdef

  42.       (cond

  43.         ((= "AcDbWipeout" (setq objname (vla-get-ObjectName obj)))
  44.          (setq pl (wipeout2plst (vlax-vla-object->ename obj))
  45.                pl (apply 'append (mapcar '(lambda (X) (list (car x) (cadr x)) ) pl))
  46.                )
  47.          (setq o
  48.                 (vla-AddLightWeightPolyline blkdef (vlax-safearray-fill
  49.                                               (vlax-make-safearray
  50.                                                 vlax-vbDouble
  51.                                                 (cons 0 (1- (length pl)))
  52.                                               )
  53.                                               pl
  54.                                             )
  55.            )
  56.                )
  57.          (vla-put-closed o :vlax-true)
  58.          (vla-put-layer o (vla-get-layer obj))
  59.          (vla-delete obj)

  60.          )

  61.         ((or (= "AcDbMInsertBlock" objname)

  62.              (= "AcDbBlockReference" objname)

  63.              )

  64.          (delblkwipe (vla-get-name obj))

  65.          )

  66.         )

  67.       )

  68.     )

  69.   )

  70. ;;

  71. (defun c:111(/ e)

  72.   (while (and (setq e (car(entsel)))

  73.               (=  "INSERT" (cdr (assoc 0 (entget e))))

  74.               )

  75.     (delblkwipe (cdr (assoc 2 (entget e))))

  76.     (command "_.regen")

  77.     )

  78.   (princ)

  79.   )

点评

G版好人啊,呵呵!  发表于 2012-6-29 08:29
 楼主| 发表于 2012-6-29 12:54:44 | 显示全部楼层
感谢G版主再次出手相助!!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-5-21 18:21 , Processed in 0.194207 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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