Lisp在specify上计算块数
如何操作此lisp以仅计算特定层上的块?我的所有图层都以“E_…”开头例如E_电源、E_灯等。
我得到了这个Lisp程序的网站,它的工作像一个梦。。。如果可以将if更改为仅在名称以“E_…”开头的图层上识别和计数块,则会更有帮助
谢谢
(defun c:test (/ SS)
(if (setq SS (ssget "_X"
(list (cons 0 "INSERT") (cons 410 (getvar "CTAB")) (cons 8 "E_*"))
)
)
(prompt (strcat "\nTotal " (itoa (sslength SS)) " blocks."))
)
(princ)
)
请注意,lisp仅统计当前空间中的块。对于整个DWG删除的计数
这(cons 410(getvar“CTAB”)) 这是你日常生活的一个模式。
;;********************
;;* *
;;* C:BlocksList.LSP *
;;* *
;;********************
(defun C:BlocksList ( ; Command emulation; ( local variables
/ Option; User option for output of block quantities (or exit)
C_layer ; Current layer's name con'd with its assoc key (
Block_list ; List of block's table information
Block_cons ; List of block's name con'd with 2 (its assoc key)
Block_set ; Selection set of all blocks with given name (& on curr layer)
Block_name ; Current block's name
Block_srch ; Search criteria for finding/selecting blocks
Count$ ; Quantity of selected blocks as a string value
Pattern ; Wild Card match layer name
) ; Close defun's local variables list
(cond ; Begin routine--get user input first
((initget "All Current Pattern eXit")) ; Initialize options for user input
((= "eXit"
(setq
Option (getkword
(strcat "List ["
"All occurrences/Current layer only/Pattern/eXit"
"] <Current layer only>: "
)
)
)
)
) ; Default is do blocks on current layer
(T
(if (= Option "Pattern") ; Wild Card match
(while (= (vl-string-trim " \t\n"
(setq Pattern (getstring t "\nEnter Layer name pattern. "))) "")
(prompt "\nYou must enter a layer name.")
)
)
(textscr)
(prompt
"\nPlease wait...Counting block insertions...Found..."
)
(cond
((= Option "All"))
((= Option "Pattern")(setq C_layer (cons 8 Pattern)))
((setq C_layer (cons 8 (getvar "CLAYER"))))
)
(while ; Inform user processing is starting
(setq Block_list (tblnext "BLOCK" (not Block_list)))
(setq Block_cons (assoc 2 Block_list)
Block_name (cdr Block_cons)
Block_srch (cond ; Step through entire block name database
((= (ascii Block_name) 42) nil)
; Ignore anonymous blocks: "*..."
((= Option "All") (list Block_cons))
(T (list Block_cons C_layer))
)
) ; Limit to current layer if All not opted
(cond ; Now output (ignores unused blocknames)
((and Block_srch (setq Block_set (ssget "X" Block_srch)))
(setq Count$ (itoa (sslength Block_set)))
(prompt
(strcat "\n" ; Build prompt string--pretty-print qty
(substr " " 1 (- 6 (strlen Count$)))
Count$
" "
Block_name ; Output qty & block name to screen
)
)
) ; Close cond's only opt & prompt-strcat
)
) ; Close processing while & its cond
(or Count$ (prompt "\n**< None Found >**"))
)
) ; Close main cond & its T option
(princ) ; Quiet exit
) ; The END (close defun C:BlocksList)
(C:BlocksList) ; Auto-call @ actual, not dummy, load 谢谢,很有效。
不过我有一个小问题。。。有一个街区叫“UnderFloorHeating”。。。现在,如果我用lisp并选择“All ocurances”,它会计算17。
但是如果我做一个quickselect,有21个。。。他们都在同一层,但Lisp程序似乎无法计算他们。
有什么帮助吗? 你能发布一个示例DWG,以便我们测试错误吗? 好啊开始了
UFH测试。图纸 将DWG保存回ACAD2000,这是我得到的。
没有名为“UnderFloorHeating”的区块
Command: blockslist
List <Current layer only>: a
Please wait...Counting block insertions...Found...
6 Double Fluorescent
358 Downlighter
20 1 Lever Switch
60 DimmerSwitch
26 2 Way Switching
9 Ceiling Mount Light
7 Shaver Socket
9 UpDown Wall Mounted Light
3 Distribution Board
6 Internal Wall Mounted Light
2 Pendant Light
11 Garden Light
3 Pool Light
70 Double Switched Socket
24 Single Switched Socket
3 Intermediate Switch
3 Enclosure
6 External Wall Mounted Light
3 Stove Isolator
7 Weather Proof Plug
使用另一个例程:
Command: blkcount
(("*U10" . 17)
("*U17" . 4)
("*U21" . 11)
("*U9" . 7)
("1 Lever Switch" . 20)
("2 Way Switching" . 26)
("Ceiling Mount Light" . 9)
("DimmerSwitch" . 60)
("Distribution Board" . 3)
("Double Fluorescent" . 6)
("Double Switched Socket" . 70)
("Downlighter" . 358)
("Enclosure" . 3)
("External Wall Mounted Light" . 6)
("Garden Light" . 11)
("Intermediate Switch" . 3)
("Internal Wall Mounted Light" . 6)
("Pendant Light" . 2)
("Pool Light" . 3)
("Shaver Socket" . 7)
("Single Switched Socket" . 24)
("Stove Isolator" . 3)
("UpDown Wall Mounted Light" . 9)
("Weather Proof Plug" . 7)) 这是我得到的
Command:
Current block modes: Unused = IGNORE,Anonymous = IGNORE, Layers = ALL
Send report to <c:\documents
and settings\design.desktop\desktop\ufh-test.blk>: S
Please wait...Counting block inserts...
Writing results to: Text Window
6 Double Fluorescent
358 Downlighter
20 1 Lever Switch
60 DimmerSwitch
26 2 Way Switching
9 Ceiling Mount Light
7 Shaver Socket
7 Heated Towel Rail
17 UnderFloorHeating
9 UpDown Wall Mounted Light
3 Distribution Board
6 Internal Wall Mounted Light
2 Pendant Light
11 Garden Light
3 Pool Light
70 Double Switched Socket
24 Single Switched Socket
3 Intermediate Switch
11 Aircon Point
3 Enclosure
6 External Wall Mounted Light
3 Stove Isolator
7 Weather Proof Plug 真奇怪。。。我用BCOUNT也得到17。Qselect给出21,图中有21。出于某种原因,块计数器LISP无法识别其中4个块。
Command: bcount
Initializing...
Press Enter to select all or...
Select objects:
Block............................Count
--------------------------------------
Double Fluorescent...............6
Distribution Board...............3
Pendant Light....................2
Internal Wall Mounted Light......6
UpDown Wall Mounted Light........9
Ceiling Mount Light..............9
2 Way Switching..................26
Garden Light.....................11
Pool Light.......................3
Downlighter......................358
Shaver Socket....................7
Heated Towel Rail................7
DimmerSwitch.....................60
Intermediate Switch..............3
Double Switched Socket...........70
Aircon Point.....................11
Enclosure........................3
1 Lever Switch...................20
External Wall Mounted Light......6
Stove Isolator...................3
Single Switched Socket...........24
Weather Proof Plug...............7
UnderFloorHeating................17
页:
[1]
2