-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTools.lsp
3541 lines (3541 loc) · 102 KB
/
Tools.lsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(lib::lsp "MyFan.lsp")
(setfunhelp "c:Bbl" "Tssd" "bbl")
(Defun c:Bbl (/ newp shdcl upaxl updim upgrp uppln uptxt _sc _sd e ea eax eg en l lab
lac lac1 lax p0 sc sd ss ssx sx
)
(Defun newp (p p0)
(polar p0 (angle p0 p) (* sx (distance p p0)))
)
(defun shdcl (/ #flash #ret scn sco sdn sdo tgc tgd)
(defun #flash ()
(mode_tile "sdo" (- 1 (atoi tgd)))
(mode_tile "sdn" (- 1 (atoi tgd)))
(mode_tile "txd" (- 1 (atoi tgd)))
(mode_tile "sco" (- 1 (atoi tgc)))
(mode_tile "scn" (- 1 (atoi tgc)))
(mode_tile "txc" (- 1 (atoi tgc)))
)
(defun #ret (/)
(if
(or
(= tgc tgd "0")
(and (= tgd "1") (= sdo sdn))
(and (= tgc "1") (= sco scn))
)
(set_tile "error" "**请先改变对话框中的比例!")
(progn
(&GLAY "Tssd/Dcl_Myj/chscl" (strcat tgd "\t" tgc))
(if (= tgd "0")
(setq sdn -1
sdo -1
)
)
(if (= tgc "0")
(setq scn -1
sco -1
)
)
(done_dialog 1)
)
)
)
(if
(not
(and
(setq tgc (&GPTS "Tssd/Dcl_Myj/chscl"))
(/= tgc "")
(setq tgc (&PLCN tgc "\t"))
(= (length tgc) 2)
)
)
(setq tgc '("1" "0"))
)
(setq tgd (car tgc)
tgc (cadr tgc)
)
(if (new_dialog "chscl" (lib::dcl "Tools"))
(progn
(&SWAP T)
(setq sdo (fix (/ &sp &sc))
sdn sdo
sco &sp
scn sco
)
(foreach x '("sdo" "sdn" "sco" "scn")
(set_tile x (itoa (eval (read x))))
(action_tile x "(#isnum 0 10000)")
)
(set_tile "tgc" tgc)
(set_tile "tgd" tgd)
(#flash)
(action_tile "tgc" "(setq tgc $value) (#flash)")
(action_tile "tgd" "(setq tgd $value) (#flash)")
(action_tile "help" "(help \"Tssd\" \"bbl\")")
(action_tile "accept" "(#ret)")
(if (= (start_dialog) 1)
(list (/ sdn 1. sdo) (/ scn 1. sco) sdn scn)
)
)
)
)
(defun updim (/ e3 el p10 p11 p13 p13n p14 p14n p15 p15n sd1 sc1)
(setq el (entget e)
e3 (&DRAG 3)
p10 (&DRAG 10)
p11 (&DRAG 11)
p13 (&DRAG 13)
p14 (&DRAG 14)
)
(cond
((wcmatch e3 "TSSD*")
(setq e3 (&PLCN e3 "_"))
(&GVAL
(if (minusp _sd) (atoi (cadr e3)) _sd)
(if (minusp _sc) (atoi (caddr e3)) _sc)
)
(setq el (subst (cons 3 (getvar "dimstyle")) (assoc 3 el) el))
(if (= sx 1)
(setq p13n p13
p14n p14
)
(setq p13n (newp p13 p0)
p14n (newp p14 p0)
el (subst (cons 13 (@wcs p13n)) (assoc 13 el) el)
el (subst (cons 14 (@wcs p14n)) (assoc 14 el) el)
)
)
(if (< (distance p13 p10) (distance p14 p10))
(setq p10 (polar p13n (angle p13 p10) (* sc (distance p13 p10))))
(setq p10 (polar p14n (angle p14 p10) (* sc (distance p14 p10))))
)
(setq p13 (&N2S p13 p14)
p14 (&N2S p13n p14n)
p11 (polar p14 (angle p13 p11) (* sc (distance p13 p11)))
el (subst (cons 10 (@wcs p10)) (assoc 10 el) el)
el (subst (cons 11 (@wcs p11)) (assoc 11 el) el)
)
(entmod el)
)
((wcmatch e3 "TSAN*")
(setq e3 (&PLCN e3 "_"))
(&GVAL
(if (minusp _sd) (atoi (cadr e3)) _sd)
(if (minusp _sc) (atoi (caddr e3)) _sc)
t
)
(setq el (subst (cons 3 (getvar "dimstyle")) (assoc 3 el) el)
p15 (&DRAG 15)
)
(if (= (logand (&DRAG 70) 5) 5)
(progn
(if (= sx 1)
(setq p15n p15)
(setq p13n (newp p13 p0)
p14n (newp p14 p0)
p15n (newp p15 p0)
el (subst (cons 13 (@wcs p13n)) (assoc 13 el) el)
el (subst (cons 14 (@wcs p14n)) (assoc 14 el) el)
el (subst (cons 15 (@wcs p15n)) (assoc 15 el) el)
)
)
(setq p10 (polar
p15n
(angle p15 p10)
(-
(* sx (distance p15 p13))
(* sc (- (distance p15 p13) (distance p15 p10)))
)
)
p11 (polar
p15n
(angle p15 p11)
(-
(* sx (distance p15 p13))
(* sc (- (distance p15 p13) (distance p15 p11)))
)
)
el (subst (cons 10 (@wcs p10)) (assoc 10 el) el)
el (subst (cons 11 (@wcs p11)) (assoc 11 el) el)
)
)
(if (/= sx 1)
(setq p13 (&N2S p10 p15)
p10 (newp p10 p0)
p15 (newp p15 p0)
p14 (&N2S p10 p15)
p11 (polar p14 (angle p13 p11) (* sc (distance p13 p11)))
el (subst (cons 10 (@wcs p10)) (assoc 10 el) el)
el (subst (cons 11 (@wcs p11)) (assoc 11 el) el)
el (subst (cons 15 (@wcs p15)) (assoc 15 el) el)
)
)
)
(entmod el)
)
((/= sx 1) (ssadd e ssx))
)
)
(defun upaxl (/ e1 p10)
(setq p10 (&DRAG 10)
e1 (entnext e)
)
(if
(and
(= (&DRAG e1 0) "INSERT")
(wcmatch (strcase (&DRAG 2)) "TS_AXNO*")
)
(progn
(ssdel e1 ss)
(if (member e1 eax) (setq eax (subst 'nil e1 eax)))
)
(setq e1 nil)
)
(if (/= sx 1)
(progn
(command ".move" e)
(if e1 (command e1))
(command "" p10 (setq p10 (newp p10 p0)))
)
)
(if (/= sc 1)
(progn
(command ".scale" e)
(if e1 (command e1))
(command "" p10 sc)
)
)
)
(defun uptxt (p10)
(if (/= sx 1)
(command ".move" e "" p10 (setq p10 (newp p10 p0)))
)
(if (/= sc 1) (command ".scale" e "" p10 sc))
)
(defun uppln (/ el i p10 x xi)
(defun reinbf (e / sp r l rn ln ll lln p10l h42 pt10l enl)
(defun modewg (e el p10l pt10l / flag enl no p1 p2)
(if
(and
(equal (distance (car p10l) (cadr p10l)) l (* 0.5 l))
(or
(equal (cadr h42) 1.0 0.001)
(equal (cadr h42) -1.0 0.001)
)
(equal
(distance (cadr p10l) (caddr p10l))
(* 2 r)
(* 1.1 &sp (&GSYS "板筋宽度"))
)
)
(progn
(setq flag 2
p2 (polar
(caddr pt10l)
(angle (caddr pt10l) (cadr pt10l))
(* 2 rn)
)
p1 (polar p2 (angle (cadr pt10l) (car pt10l)) ln)
el (subst (cons 10 p1) (assoc 10 el) el)
)
(while (>= flag 1)
(setq no (car el)
el (cdr el)
)
(if (= (car no) 10) (setq flag (1- flag)))
(if (= flag 0)
(setq enl (append enl (list (cons 10 p2)))
flag -1
)
(setq enl (append enl (list no)))
)
)
(setq enl (append enl el))
)
(if
(and
(equal (distance (car p10l) (cadr p10l)) ll (* 0.5 l))
(equal
(abs (&MIDP (car p10l) (cadr p10l) (caddr p10l)))
(/ ll (sqrt 2.0))
(* 0.01 _sc)
)
)
(setq p1 (polar
(cadr pt10l)
(angle (cadr pt10l) (car pt10l))
lln
)
enl (subst (cons 10 p1) (assoc 10 el) el)
)
)
)
enl
)
(if (= _sc -1)
(setq sp &sp
sca &sp
)
(setq sp (/ _sc sc)
sca _sc
)
)
(setq r (&GSYS "圆钩半径")
l (&GSYS "圆钩长度")
ll (&GSYS "直斜钩长")
rn (* sca r)
r (* sp r)
ln (* sca l)
l (* sp l)
lln (* sca ll)
ll (* sp ll)
p10l (&DRAG e 10)
h42 (&DRAG 42)
)
(command ".scale" e "" p0 sx)
(setq pt10l (&DRAG e 10))
(if (> (length p10l) 2)
(progn
(if (setq enl (modewg e (entget e) p10l pt10l))
(entmod enl)
)
(if
(setq enl (reverse
(modewg
e
(reverse (entget e))
(reverse p10l)
(reverse pt10l)
)
)
)
(entmod enl)
)
)
)
)
(setq p10 (&DRAG 10))
(if
(and
(member (&DRAG 42) '((1.0 1.0) (-1.0 -1.0)))
(equal (distance (car p10) (cadr p10)) (&DRAG 43) 1.0)
)
(progn
(setq p10 (&N2S (car p10) (cadr p10)))
(if (/= sx 1)
(command ".move" e "" p10 (setq p10 (newp p10 p0)))
)
(if (/= sc 1) (command ".scale" e "" p10 sc))
)
(progn
(if (/= sx 1) (reinbf e))
(if (/= sd 1)
(progn
(foreach x (entget e)
(if
(and
(member (setq i (car x)) '(40 41 43))
(not (zerop (setq xi (cdr x))))
)
(if (= i 10)
(setq x (cons i (@wcs (* xi sd))))
(setq x (cons i (* xi sd)))
)
)
(setq el (cons x el))
)
(entmod (reverse el))
)
)
)
)
)
(defun upgrp (/ e en p10 ss1 tf)
(setq ss1 (ssadd))
(foreach x eg
(if (= (car x) 340)
(progn
(setq e (cdr x)
en (&DRAG e 0)
)
(ssdel e ss)
(cond
((= en "DIMENSION") (updim) (setq tf t))
((and (= en "LWPOLYLINE") (> (&DRAG 43) 0))
(uppln)
(setq tf t)
)
(t
(ssadd e ss1)
(if (null p10) (setq p10 (&DRAG 10)))
(if (wcmatch en "*TEXT,INSERT") (setq tf t))
)
)
)
)
)
(if (> (sslength ss1) 0)
(if tf
(progn
(if (/= sx 1)
(command ".move" ss1 "" p10 (setq p10 (newp p10 p0)))
)
(if (/= sc 1) (command ".scale" ss1 "" p10 sc))
)
(if (/= sx 1) (command ".scale" ss1 "" p0 sx))
)
)
)
(if
(and
(> (&UTXT) -1)
(setq l (shdcl))
(setq sd (car l)
sc (cadr l)
_sd (caddr l)
_sc (cadddr l)
sx (/ sc sd)
)
(setq ss (&DSTR "\n选择要改变比例的实体<退出>: "))
(setq p0 (&OSNP "\n点取比例缩放基点<退出>: "))
)
(progn
(setq lax (&LJIG "平面轴线编号")
lac (&LJIG "平面柱子")
lac1 (&LJIG "平面柱子虚线")
lab (&LJIG "图框")
ssx (ssadd)
)
(while (setq e (ssname ss 0))
(setq en (&DRAG e 0)
eg (&DRAG 330)
ea (&DRAG 8)
)
(ssdel e ss)
(cond
((and
eg
(setq eg (entget eg))
(= (cdr (assoc 0 eg)) "GROUP")
)
(upgrp)
)
((and (= ea lax) (= en "LINE")) (upaxl))
((= en "DIMENSION") (updim))
((and
(= en "INSERT")
(wcmatch (strcase (&DRAG 2)) "TS_AXNO*")
)
(setq eax (cons e eax))
)
((or
(= en "TEXT")
(= en "MTEXT")
(and
(= en "INSERT")
(wcmatch
(strcase (&DRAG 2))
"REIN_INDEX_BLOCK,COMPASS,TS_IDX*,TS_REINO*"
)
)
)
(uptxt (&DRAG 10))
)
((and (= en "LWPOLYLINE") (/= ea lac) (/= ea lac1))
(uppln)
)
((= ea lab))
((/= sx 1) (ssadd e ssx))
)
)
(foreach e eax (if e (uptxt (&DRAG e 10))))
(if (> (sslength ssx) 0)
(command ".scale" ssx "" p0 sx)
)
)
)
(&TSTY)
)
(defun join2ln (la / 2pi a01 a02 a11 a12 e0 e1 la1 la2 mm mma msg ofr p01 p02 p1 p11
p12 p2 r0 r1 tf0 tf1
)
(if (< (&UTXT) 0) (exit))
(setq ofr (getvar "filletrad")
mm 0.1
mma 0.01
2pi (+ pi pi)
msg (strcat
"\n选取第一根要连接的"
(if (= la "*") "直线或圆弧" "梁线")
"<退出>:"
)
)
(while
(and
(setq e0 (&DOVR msg (list '(0 . "line,arc") (cons 8 la))))
(@Hlt (car e0) 3)
(setq la1 (&DRAG (car e0) 8)
la1 (cond
((= la "*") la1)
((wcmatch la1 (setq la2 (&LJIG "平面主梁,平面主梁实线"))) la2)
((wcmatch la1 (setq la2 (&LJIG "平面次梁,平面次梁实线"))) la2)
((wcmatch la1 (setq la2 (&LJIG "平面过梁,平面过梁实线"))) la2)
((wcmatch la1 (setq la2 (&LJIG "平面连梁,平面连梁实线"))) la2)
)
e1 (&DOVR
"\t第二根<退出>:"
(list '(0 . "line,arc") (cons 8 la1))
)
)
)
(if (not (equal (car e0) (car e1)))
(progn
(if
(setq p01 (&DRAG (car e0) 10)
tf0 (= "LINE" (&DRAG 0))
)
(setq p02 (&DRAG 11))
(setq r0 (&DRAG 40)
a01 (&DRAG 50)
a02 (&DRAG 51)
a02 (if (< a02 a01) (+ a02 2pi) a02)
)
)
(if
(setq p11 (&DRAG (car e1) 10)
tf1 (= "LINE" (&DRAG 0))
)
(setq p12 (&DRAG 11))
(setq r1 (&DRAG 40)
a11 (&DRAG 50)
a12 (&DRAG 51)
a12 (if (< a12 a11) (+ a12 2pi) a12)
)
)
(cond
((and tf0 tf1)
(if (equal (sin (- (angle p01 p02) (angle p11 p12))) 0 mma)
(if (equal (&MIDP p01 p11 p12) 0 mm)
(progn
(setq r0 0
r1 0
)
(mapcar
'(lambda (p1 p2)
(if (> (setq r1 (distance p1 p2)) r0)
(setq r0 r1
p01 p1
p02 p2
)
)
)
(list p01 p01 p01 p02 p02 p11)
(list p02 p11 p12 p11 p12 p12)
)
(setq e0 (entget (car e0))
e0 (subst (cons 10 (@wcs p01)) (assoc 10 e0) e0)
e0 (subst (cons 11 (@wcs p02)) (assoc 11 e0) e0)
)
(entdel (car e1))
(entmod e0)
)
(progn (princ "\n***两直线平行!") (@Hlt (car e0) 4))
)
(command ".fillet" "r" 0 ".fillet" e0 e1)
)
)
((or tf0 tf1) (command ".fillet" "r" 0 ".fillet" e0 e1))
((equal p01 p11 mm)
(if (equal r0 r1 mm)
(progn
(setq r0 (min a01 a02 a11 a12)
r1 (max a01 a02 a11 a12)
e0 (entget (car e0))
e0 (subst (cons 50 (@wcs r0)) (assoc 50 e0) e0)
e0 (subst (cons 51 (@wcs r1)) (assoc 51 e0) e0)
)
(entdel (car e1))
(entmod e0)
)
(progn (princ "\n**两圆弧共圆心, 但半径不同!") (@Hlt (car e0) 4))
)
)
(t (command ".fillet" "r" 0 ".fillet" e0 e1))
)
)
(progn (princ "\n**不能选取同一个实体!") (@Hlt (car e0) 4))
)
)
(if e0 (@Hlt (car e0) 4))
(setvar "filletrad" ofr)
(&TSTY)
)
(setfunhelp "c:Ljxd" "Tssd" "LJXD")
(defun c:Ljxd () (join2ln "*"))
(setfunhelp "c:LJLX" "Tssd" "LJLX")
(defun C:Ljlx ()
(join2ln
(&LJIG "平面主梁,平面主梁实线,平面次梁,平面次梁实线,平面过梁,平面过梁实线,平面连梁,平面连梁实线")
)
)
(defun DrawPdx (p1 p6 / a d p2 p3 p4 p5 sc)
(if (and p1 p6)
(progn
(&LJIG "细线符号" T)
(setvar "plinewid" 0)
(if (< (distance p1 p6) (* 4 &sp))
(setq sc (* 0.002 (distance p1 p6)))
(setq sc (* 0.01 &sp))
)
(setq d (* 0.5 (distance p1 p6))
a (angle p1 p6)
p2 (polar p1 a (- d (* sc 130)))
p5 (polar p6 a (- (* sc 130) d))
p3 (polar (polar p2 a (* sc 70)) (+ a _pi2) (* sc 220))
p4 (polar (polar p5 a (* sc -70)) (+ a _pi2) (* sc -220))
p1 (polar p1 a (* sc -280))
p6 (polar p6 a (* sc 280))
)
(command ".pline" p1 p2 p3 p4 p5 p6 "")
)
)
)
(setfunhelp "c:Pdx" "Tssd" "pdx")
(defun c:Pdx (/ e p1 p2)
(if (> (&UTXT) -1)
(progn
(if (setq p1 (&OSNP "\n点取剖断线的起点<选直线>: "))
(setq p2 (&OSNP p1 "\t终点<退出>: "))
(if (setq e (&DOVR "\n选取剖断线的基线<退出>: " '((0 . "LINE"))))
(progn
(setq p1 (&DRAG 10)
p2 (&DRAG 11)
)
(entdel (car e))
)
)
)
(if (and p1 p2) (DrawPdx p1 p2))
)
)
(&TSTY)
)
(setfunhelp "c:ljfh" "Tssd" "ljfh")
(defun c:ljfh (/ a p1 p2 pa pb sc)
(if
(and
(> (&UTXT) -1)
(setq p1 (&OSNP "\n点取剖断线的起点<退出>: "))
(setq p2 (&OSNP p1 "\t终点<退出>: "))
)
(progn
(setq sc (* 1. &sp)
a (+ (angle p1 p2) _pi2)
pa (polar p1 a sc)
pb (polar p2 a sc)
)
(DrawPdx pa pb)
(setq pa (polar p1 a (- sc))
pb (polar p2 a (- sc))
)
(DrawPdx pa pb)
)
)
(&TSTY)
)
(setfunhelp "c:Jddd" "Tssd" "JDDD")
(defun c:Jddd (/ *error* ints getcon en ent pt ptl ss del p0 p1 p2 pint pintl en_l)
(defun *error* (msg)
(if
(not
(or
(= msg "Function cancelled")
(= msg "quit/exit abort")
)
)
(if del (ss::del del))
)
(&TSTY)
)
(defun inst (s en / l i co sdel e e1 p pl ar)
(setq l (sslength s)
l (1- l)
co (getvar "cecolor")
sdel (ssadd)
)
(setvar "cecolor" "2")
(while (setq e (ssname s l))
(setq pl (&ORDR e en))
(while (setq p (car pl))
(setq pl (cdr pl))
(command
".circle"
p
(* 0.006 (getvar "viewsize"))
".circle"
p
(* 0.01 (getvar "viewsize"))
)
)
(setq l (1- l))
)
(while (entnext ent)
(ssadd (setq ent (entnext ent)) sdel)
)
(setvar "cecolor" co)
(if (> (sslength sdel) 0) sdel nil)
)
(defun getcon (en / flag p10 p11 ptl pc r qi zh ang p0 p1 p2 p3 px py)
(setq flag (strcase (&DRAG en 0)))
(if (wcmatch flag "LINE")
(setq p10 (&DRAG 10)
p11 (&DRAG 11)
ang (angle p10 p11)
ptl (list
(polar
p10
(+ ang (* 0.5 pi))
(* 0.01 (getvar "viewsize"))
)
(polar
p10
(- ang (* 0.5 pi))
(* 0.01 (getvar "viewsize"))
)
(polar
p11
(- ang (* 0.5 pi))
(* 0.01 (getvar "viewsize"))
)
(polar
p11
(+ ang (* 0.5 pi))
(* 0.01 (getvar "viewsize"))
)
)
)
(if (wcmatch flag "ARC")
(progn
(setq pc (&DRAG en 10)
r (&DRAG 40)
qi (&DRAG 50)
zh (&DRAG 51)
p0 (polar pc qi r)
p3 (polar pc zh r)
ang (- zh qi)
)
(if (< ang 0) (setq ang (+ ang pi pi)))
(setq ang (+ qi (* 0.5 ang))
p1 (polar
(polar pc ang r)
(angle p3 p0)
(* 0.5 (distance p0 p3))
)
p2 (polar p1 (angle p0 p3) (distance p0 p3))
ptl (list p0 p1 p2 p3)
)
)
(if (wcmatch flag "LWPOLYLINE")
(progn
(setq p10 (&DRAG en 10))
(while (setq p0 (car p10))
(setq p10 (cdr p10)
px (cons (car p0) px)
py (cons (cadr p0) py)
)
)
(setq px (@ran1 px)
py (@ran1 py)
ptl (list
(list (car px) (car py))
(list (last px) (car py))
(list (last px) (last py))
(list (car px) (last py))
)
)
)
)
)
)
ptl
)
(if (< (&UTXT) 0) (exit))
(if (setq en (entsel "\n选取需要打断的实体<退出>: "))
(progn
(setq pt (cadr en)
en (car en)
ptl (getcon en)
en_l (cons en en_l)
)
(if ptl
(if (setq ss (ssget "cp" ptl '((0 . "line,lwpolyline,arc"))))
(progn
(setq ent (entlast)
del (inst ss en)
)
(while (setq p0 (&OSNP "\n在实体上选取要打断的点<退出>: "))
(setq p1 (polar p0 (* 0.25 pi) (* 0.006 (getvar "viewsize")))
p2 (polar p0 (* 1.25 pi) (* 0.006 (getvar "viewsize")))
)
(if (setq ss (ssget "c" p1 p2 '((0 . "line,lwpolyline,arc"))))
(while (setq ent (ssname ss 0))
(ssdel ent ss)
(setq l (length en_l))
(while (> l 0)
(setq l (1- l)
en (nth l en_l)
pintl (&ORDR en ent)
)
(while (setq pint (car pintl))
(setq pintl (cdr pintl))
(if (< (distance pint p0) (* 0.0065 (getvar "viewsize")))
(progn
(command ".Break" en pint pint)
(setq en_l (cons (entlast) en_l)
l 0
)
)
)
)
)
)
)
)
(ss::del del)
)
)
)
)
)
(&TSTY)
)
(setfunhelp "c:Jdjc" "Tssd" "JDjc")
(defun c:Jdjc ()
(if (> (&UTXT) -1)
(progn
(command "trim" "" "E" "N")
(while (/= (getvar "cmdactive") 0)
(princ "\r选择要剪裁的实体<退出>: ")
(command pause)
)
)
)
(&TSTY)
)
(setfunhelp "c:Hjt" "Tssd" "HJT")
(defun c:Hjt (/ p1 p2 p3 asz blk)
(if
(and
(> (&UTXT) -1)
(setq p1 (&OSNP "\n点取箭头的第一点<退出>: "))
(setq p2 (&OSNP p1 "\t第二点<退出>: \n"))
)
(progn
(&LJIG "细线符号" t)
(setq asz (getvar "Dimasz"))
(setvar "Dimasz" (* 2 &sp))
(if (< (distance p1 p2) (* 4.2 &sp))
(setq p2 (polar p1 (angle p1 p2) (* 4.2 &sp)))
)
(command ".Leader" p1 p2)
(grdraw p1 p2 7)
(while (setq p3 (&OSNP p2 "\r下一点<结束>: "))
(command p3)
(grdraw p2 p3 7)
(setq p2 p3)
)
(command "A" "" "N")
(setvar "Dimasz" asz)
)
)
(&TSTY)
)
(setfunhelp "c:Lxfzh" "Tssd" "LXFZH")
(Defun c:Lxfzh (/ e ky p)
(if (> (&UTXT) -1)
(progn
(setq ky (&OSNP "\n输入复制距离<通过方式>: " 0)
ky (if ky ky "T")
)
(while
(setq e (&DOVR
"\n选择要连续复制的实体<退出>: \n"
'((0 . "line,arc,circle,lwpolyline,text,mtext,insert"))
)
)
(setq e (car e))
(@Hlt e 3)
(while
(if (= ky "T")
(progn
(initget 128)
(setq p (&OSNP "\r点取复制目标点或 输入复制距离<结束>: "))
)
(progn
(initget "T" 128)
(setq p (&OSNP
(strcat "\r当前距离=" (&RTXT ky) ", 点取方向或输距离 [通过方式(T)]<结束>: ")
)
)
)
)
(cond
((listp p)
(@Hlt e 4)
(command ".offset" ky e p "")
(setq e (entlast))
(@Hlt e 3)
)
((= (read p) (atof p))
(setq ky (atof p))
(princ "\n")
)
((= p "T") (setq ky p) (princ "\n"))
(t (prompt "\n**输入错误, 再试一次!\n"))
)
)
(@Hlt e 4)
)
)
)
(&TSTY)
)
(setfunhelp "c:Txyh" "Tssd" "TXYH")
(defun c:Txyh (/ e si ss st chone mode_dim)
(defun chone (e tf / e1 i ix)
(setq e (entget e))
(foreach x e
(setq i (car x)
ix (cdr x)
)
(cond
((and tf (= i 8))
(setq e1 (cons '(62 . 7) (cons x e1)))
)
((and tf (= i 62)) nil)
((and (null tf) (< 9 i 20) (cddr ix))
(setq e1 (cons (list i (car ix) (cadr ix) 0.0) e1))
)
(t (setq e1 (cons x e1)))
)
)
(setq e1 (reverse e1))
(if (not (equal e e1)) (entmod e1))
)
(defun mode_dim (/ flag diml)
(setq flag T)
(while (setq diml (tblnext "dimstyle" flag))
(setq flag nil)
(if
(and
(wcmatch "ARCHTICK" (strcase (cdr (assoc 5 diml))))
(not
(or
(wcmatch (strcase (cdr (assoc 2 diml))) "TSSD*")
(wcmatch (strcase (cdr (assoc 2 diml))) "TSSD*")
)
)
(not (equal (cdr (assoc 41 diml)) &sp (* 0.01 &sp)))
)
(command
"dim"
"dimasz"
&sp
"save"
(cdr (assoc 2 diml))
"y"
"exit"
)
)
)
)
(if (and (> (&UTXT) -1) (setq ss (ssget "x")))
(progn
(command
".Insert"
"_ArchTick=_Tsdbk1"
(list 0. 0. 0.)
1
1
0
)
(entdel (entlast))
(repeat 3
(command ".purge" "all" "*")
(while (not (zerop (getvar "cmdactive")))
(command "y")
)
)
(mode_dim)
(setq tf nil
si 0
st (strcat "\r图中共有" (itoa (sslength ss)) "个实体, 已经处理")
)
(while (setq e (ssname ss si))
(setq si (1+ si))
(if (zerop (rem si 50))
(princ (strcat st ":" (itoa si)))
)
(chone e tf)
(while (and (setq e (entnext e)) (= (&DRAG e 0) "ATTRIB"))
(chone e tf)
)
)
(if (> si 0) (princ (strcat st "完毕! \n")))
(setq si 0
e (tblnext "block" t)
st "\r正在处理图块: "
)
(while e
(if (wcmatch (cdr (assoc 2 e)) "~[*]*")
(progn
(setq e (cdr (assoc -2 e)))
(while e
(chone e tf)
(setq e (entnext e)
si (1+ si)
)
(if (zerop (rem si 50)) (princ (strcat st (itoa si))))
)
)
)