AutoCAD 中當有物件被炸開之後,該物件選集便消失了,那怎麼取回被炸開後的那些物件呢?

AutoCAD 中當有物件被炸開之後,該物件選集便消失了,那怎麼取回被炸開後的那些物件呢?
找了好多網路文章 ... 想到黑眼圈都跑出來了.... 失敗了N 次,也沒人可問,乾脆寫信給國外的高手 :P 糗~~





他回答我 :


1. Selection Set 1 : Get selection set of everything in the drawing.
2. Remove the block that is about to be exploded from the set.
3. Explode the block.
4. Selection Set 2 :Get another selection set containing everything in the drawing.
5. Remove everything in Selection Set 2 that exist in Selection Set 1
6. Selection Set 2 should now contain the entities of the exploded block.
看到之後真是太開心了,他的回答的確可行,立刻隔著太平洋給他三拜。

他是這麼說 :
1. 取得圖中所有物件選集 (setq ssuni (ssget "x"))
2. 移除你要炸開的物件 (ssdel eni ss)
3. 炸開該物件 (command "explode" ss )
4. 再選一次所有物件,這次便會包含被炸開的物件 (setq ssuni2 (ssget "x"))
5. (setq ssuni2 (ssget "x")) - [(setq ssuni (ssget "x"))-SS]
6. 這樣就剩下被炸開的物件 exploded


接著冰雪聰明的我立刻寫出一個副程式就是下面安ㄋ :



這傻蛋又在陶醉了....


(defun ExplodeAndGetExplodedObject (SS          /         i
                   n          enNameI     enNameN
                   ssuni      ssuni2     ssExclude
                   ssexploded result
                  )
  (if (/= SS nil)
    (progn
      (setq ssuni (ssget "x"))
      (setq i 0)
      (repeat (sslength SS)
    (setq enNameI (ssname SS i))
    (setq ssExclude (ssdel enNameI ssuni))
    (setq i (+ 1 i))
      )
      ;;repeat

      (setvar "qaflags" 1)
      (command "explode" SS "")
      (setvar "qaflags" 2)

      (setq ssuni2 (ssget "x"))
      (setq n 0)
      (repeat (sslength ssExclude)
    (setq enNameN (ssname ssExclude n))
    (setq ssexploded (ssdel enNameN ssuni2))
    (setq n (+ 1 n))
      )
      ;;repeat
    )
    ;;progn
    (exit)
  )
  ;;if
  (setq result ssexploded)
)
;;defun


相關文章

留言

熱門文章