ssget 選取集指令語法

  • Share this:

; ssget 選取集 ; ; -----------------------------------------------------

(setq sel1 ( ssget )) ; 純 ssget, 未設定選取的方式, 也未設過濾條件

(setq sel1 ( ssget "x" '((8 . "STEEL")))) ; "x"->作用中圖檔內的所有圖元, 點對的 8 -> 圖元的圖層, ; 此例是選取圖檔內, 圖層為 "STEEL" 的所有圖元.

(setq sel1 ( ssget "x" '((0 . "CIRCLE")(8 . "STEEL")))) ; 選取圖檔內, 所有 圖元名稱為 圓 "CIRCLE", 圖層設為 "STEEL" 的圖元.

(setq sel1 ( ssget '((0 . "CIRCLE")(8 . "STEEL")))) ; 在圖檔中選取圖元為"CIRCLE", 圖層為 "STEEL" 的圖元, 其餘的即使在 ; 選取框內,也不加入選集中.

(setq sel1 ( ssget "w" "\nSelect Objects by Window: ")) ; 設定選取的方式為 窗選 "W", "\n......"為在指令列顯示的提示語. ; W->Window selection.

; ---------------------------------------------------------------------------------------- (prompt "\nSelect Objects by Window") (setq p1 (getpoint "\nFirst Corner: ")) (setq p2 (getpoint p1 "\nSecond Corner: ")) (setq sel1 ( ssget "w" p1 p2)) ; ----------------------------------------------------------------------------------------

(setq sel1 ( ssget "P")) ; 設 sel1 為前一個建立的選取集 ; P->Last selection set created.

(setq sel1 ( ssget '((-4 . "<OR")(8 . "STEEL")(8 . "PIPE")(-4 . "OR>")))) ; 選取 圖層名稱為 "STEEL" 或 "PIPE" 的圖元.

(setq sel1 ( ssget '(0 . "CIRCLE")(-4 . ">=")(40 . 2.0))) ; 選取 圖元名稱為 圓 "CIRCLE", 且 半徑 >= 2.0 的圖元. ; 40 -> 圓的半徑 ; ----------------------------------------------------

(setq sel1 (ssget)) ; 設 sel1 為第一個選取集. (setq ent (car ( entsel )) ; 用 entsel 指令選取單一圖元 ; 再用 car 指令取出圖元名稱 (setq sel1 ( ssadd ent sel1)) ; 用 ssadd 指令, 將 ent 的圖元, 加入 sel1 的選取集內

; ---------------------------------------------------------------

(setq sel1 ( ssdel ent sel1)) ; 用 ssdel 指令, 將 sel1 選取集內的 ent 圖元刪除

; --------------------------------------------------------------- (setq ct 0) ;set counter to zero ( repeat ( sslength sel2) ;get the number of items in selection set 2 ;and loop that number of times ( ssadd ( ssname sel2 ct) sel1) ;get the name of the entity from selection set 2 ;by using the counter index number and add it to ;selection set 1 (setq ct (1+ ct)) ;increment the counter by 1 );end repeat

; ---------------------------------------------------------- (defun c:bcount ( / p1 b a n) (setq p1 ( getstring "\Name of Block : ")) ;get the name of the block (setq b ( cons 2 p1)) ;construct a dotted pair - code 2 is for blocks (setq a ( ssget "x" (list b))) ;filter for the block name (if (/= a nil) ;check if there are any blocks of that name (progn ;if there is… (setq n ( sslength a)) ;count the number of blocks ( alert ( strcat "\nThere are " ( itoa n) " in the DataBase")) ;display the result );progn ;if there are no blocks ( alert "\nThere are none in the DataBase") ;inform the user );if (princ) );defun (princ) ; ---------------------------------------------------------------

( ssget '((8 . "mylayer") (0 . "circle") )) ; 選取 圖層 "mylayer 的圓 "circle"

; -------------------------------------------------------------

; 後半段加入邏輯判別條件,

; 可能有點複雜, 但功能強大,

; 如果目前無法理解,

; 就放下它,

; 下回再看吧.

( ssget '((0 . circle) (-4 . "<or") (8 . "mylayer") (8 . "mylayer2") (-4 . "or>"))) ; 選取 圖層為 "mylayer 或 "mylayer2" 的圓 "circle"

; -------------------------------------------------------------

( ssget '( (-4 . "<or") (8 . "notes") (0 . "circle") (-4 . "<and") (8 . "s-boundary") (0 . "line") (-4 . "and>") (-4 . "or>") ) )

; ------------------------------------------------------------- ( ssget '((-4 . "<and") (0 . "line") (8 . "text") (62 . 3) (-4 . "and>") )) ; -------------------------------------------------------------

( ssget '((-4 . "<or") (0 . "line") (8 . "text") (62 . 3) (-4 . "or>") )) ; -------------------------------------------------------------

( ssget '((-4 . "<xor") (8 . "text") (62 . 3) (-4 . "xor>") )) ; -------------------------------------------------------------

( ssget '((-4 . "<not") (0 . "line") (-4 . "not>") )) ; ------------------------------------------------------------- ( ssget '((0 . "text") (-4 . "<or") (8. "notes) (62 . 3) (-4 . "or>") ))

; -------------------------------------------------------------

( ssget '((0 . "text") (-4 . "<xor") (8. "notes) (62 . 3) (-4 . "xor>") )) ; -------------------------------------------------------------

( ssget '( (0 . "text") (-4 . "<xor") (-4 . "<and") (8 . "notes") (62 . 3) (-4 . "and>") (-4 . "xor>") )) ; ------------------------------------------------------------ ( ssget '( (-4 . "<xor") (8 . "mylayer") (-4 . "<or") (0 . "text") (-4 . "<xor") (8 . "notes") (-4 . "<and") (62 . 2) (0 . "line") (-4 . "and>") (-4 . "xor>") (-4 . "or>") (-4 . "xor>") )) ; ------------------------------------------------------------

(defun c:layer_copy ( / laa la p1 p2 ss )

(princ "\n Choose an object on desired layer: ") (setq laa ( assoc 8 ( entget ( car ( entsel ))))) (princ "\n Choose another object a different desired layer: ") (setq la ( assoc 8 ( entget ( car ( entsel ))))) (setq ss ( ssget "x" ( list ( cons -4 "<or") laa la ( cons -4 "or>") ))) (command "copy" ss ) );defun (princ)

; ------------------------------------------------------- ( ssget "x" ( list '(0 . "INSERT") ( cons 2 name_block01) '( 410 . "Model") ) ) ; ---------------------------------

; 下面是阿貴程式裡寫到的 ssget 指令語法範例

; 可以複製, 修改變數名稱, 內化成您自己的程式碼

( ssget "x" ( list '(0 . "INSERT") ( cons 2 name_layout01)) )

; --------------------------------------------------- ( ssget "x" ( list '(0 . "lwpolyline") ( cons 8 name_layer01))) ; ----------------------------------------------------------

(setq frame_block ( ssget "x" ( list '(0 . "INSERT") ( cons 2 block_name) '(410 . "Model") ) ) )

; ----------------------------------------------------------- (setq frame_layer ( ssget "x" ( list '(0 . "LWPOLYLINE") ( cons 8 layer_name) '(410 . "Model") ) ) ) ; ------------------------------------------------------------- (setq obj_bigcircle ( ssget "l")) ; 要求取交點的圓 obj_bigcircle ; ------------------------------------------------------------

(setq regions ( ssget "x" '((0 . "region") (8 . "count_weight")))) ; ------------------------------------------------------------- (setq se (ssget '((-4 . "<or") (0 . "circle") (0 . "INSERT") (-4 . "or>") ) ) )

; -------------------------------------------------------------

(setq sel_dim_en ( ssget ( list '(0 . "DIMENSION"))) ) ; -------------------------------------------------------------


Tags: