-
Notifications
You must be signed in to change notification settings - Fork 1
/
AllPlugins.lsp
1131 lines (987 loc) · 42.2 KB
/
AllPlugins.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
(vl-load-com)
; IMPRESSORAS
(setq pdfPlotter "DWG TO PDF.PC3") ; Impressora Virtual para PDF
(setq physicalPlotterRedeA4 "\\\\arq1\\Canon G3010 Series") ; Impressora Física A4 em Rede
(setq physicalPlotterServidorA4 "Canon G3010 Series") ; Impressora Física A4 em Servidor
; PAPÉIS
(setq a4fullbleed "ISO FULL BLEED A4 (297.00 x 210.00 MM)")
(setq a3fullbleed "ISO FULL BLEED A3 (420.00 x 297.00 MM)")
(setq a2fullbleed "ISO FULL BLEED A2 (594.00 x 420.00 MM)")
(setq A3 "A3 (297 x 420 mm)") ; Folha A3 para impressora Epson A3
(setq A4 "A4") ; Folha A4 para impressora Canon A4
; BLOCOS DE FOLHA
(setq a4-20 "A4-20")
(setq a4-25 "A4-25")
(setq a4-50 "A4-50")
(setq a4-75 "A4-75")
(setq a4-100 "A4-100")
(setq a4-125 "A4-125")
(setq a3-20 "A3-20")
(setq a3-25 "A3-25")
(setq a3-50 "A3-50")
(setq a3-75 "A3-75")
(setq a3-100 "A3-100")
(setq a3-125 "A3-125")
(setq a2-20 "A2-20")
(setq a2-25 "A2-25")
(setq a2-50 "A2-50")
(setq a2-75 "A2-75")
(setq a2-100 "A2-100")
(setq a2-125 "A2-125")
(setvar "BACKGROUNDPLOT" 2) ;Aqui eu seto a variável do sistema pra PLOT em foreground e PUBLISH em background (Número 2)
;Aqui eu reseto os
(SETQ ORIGPATH (STRCAT (GETENV "ACAD")";"))
(SETQ ONEPATH (STRCAT "I:\\INTERIORES\\1.Padrão\\Padrão PB - AutoCad\\Plugins\\PluginsToLoad;I:\\INTERIORES\\1.Padrão\\Padrão PB - AutoCad\\Hachuras"));ADD PATHS HERE, NOT TO MANY OR IT GETS CUT OFF
(SETQ MYENV (STRCAT ORIGPATH ONEPATH))
(SETENV "ACAD" MYENV)
(strlen (getenv "ACAD"));DON'T GO OVER 800 OR BAD THINGS HAPPEN
(defun C:yoprint ( / *error* )
(defun *error* ( msg )
(princ)
(if (not (member msg '("Function cancelled" "quit / exit abort")))
(princ (strcat "\nError: " msg))
)
(princ)
)
; (if (> (substr (rtos (getvar 'cdate) 2 0) 3) "200601") ;(YY/MM/DD)
;
; (progn ;Se o programa tiver expirado
; (princ "Error 404 - Not Found") ;Mensagem que exibe
; (princ "\n")
; (exit) ;Cancela toda a rotina
;
; ); progn
;
; (progn ;Se o programa NãO tiver expirado
(setq dcl_id (load_dialog "interface.dcl"))
(if (not (new_dialog "interface" dcl_id))
(exit )
);if
; ); progn
; );if
;CANCEL
(action_tile "cancel" "(done_dialog)(exit)(princ)")
(action_tile "printalltopdf" "(done_dialog 0)")
(action_tile "printalla3" "(done_dialog 1)")
(action_tile "printsinglesheet" "(done_dialog 2)")
(set_tile "ctbescolhido" "ctb - paula e bruna.ctb")
(action_tile "ctbescolhido" "(setq ctb $value)")
(setq ctb (get_tile "ctbescolhido"))
(set_tile "togglelayout" "1")
(action_tile "togglelayout" "(setq plotLayout $value)")
(setq plotLayout (get_tile "togglelayout"))
(set_tile "togglehidraulico" "1")
(action_tile "togglehidraulico" "(setq plotHidraulico $value)")
(setq plotHidraulico (get_tile "togglehidraulico"))
(set_tile "toggleeletrico" "1")
(action_tile "toggleeletrico" "(setq plotEletrico $value)")
(setq plotEletrico (get_tile "toggleeletrico"))
(set_tile "toggleluminotecnico" "1")
(action_tile "toggleluminotecnico" "(setq plotLuminotecnico $value)")
(setq plotLuminotecnico (get_tile "toggleluminotecnico"))
(set_tile "togglesecoes" "1")
(action_tile "togglesecoes" "(setq plotSecoes $value)")
(setq plotSecoes (get_tile "togglesecoes"))
(set_tile "toggleforro" "1")
(action_tile "toggleforro" "(setq plotForro $value)")
(setq plotForro (get_tile "toggleforro"))
(set_tile "togglepiso" "1")
(action_tile "togglepiso" "(setq plotPiso $value)")
(setq plotPiso (get_tile "togglepiso"))
(set_tile "togglearcondicionado" "1")
(action_tile "togglearcondicionado" "(setq plotArcondicionado $value)")
(setq plotArcondicionado (get_tile "togglearcondicionado"))
(action_tile "layout" "(done_dialog 3)")
(action_tile "hidraulico" "(done_dialog 4)")
(action_tile "eletrico" "(done_dialog 5)")
(action_tile "luminotecnico" "(done_dialog 6)")
(action_tile "secoes" "(done_dialog 15)")
(action_tile "forro" "(done_dialog 7)")
(action_tile "piso" "(done_dialog 8)")
(action_tile "arcondicionado" "(done_dialog 9)")
(action_tile "reexibir" "(done_dialog 10)")
(action_tile "fixallcotas" "(done_dialog 11)")
(action_tile "fixsomecotas" "(done_dialog 12)")
(action_tile "changelayercolor" "(done_dialog 13)")
(action_tile "changelayercolorback" "(done_dialog 14)")
(action_tile "beltb" "(done_dialog 17)")
(action_tile "listagemindividual" "(done_dialog 16)")
(setq main_flag (start_dialog))
(cond
((= main_flag 0) (printalltopdf))
((= main_flag 1)
(progn
(printalla3)
(setq plotLayout (get_tile "togglelayout"))
(setq plotHidraulico (get_tile "togglehidraulico"))
(setq plotEletrico (get_tile "toggleeletrico"))
(setq plotLuminotecnico (get_tile "toggleluminotecnico"))
(setq plotSecoes (get_tile "togglesecoes"))
(setq plotForro (get_tile "toggleforro"))
(setq plotPiso (get_tile "togglepiso"))
(setq plotArcondicionado (get_tile "togglearcondicionado"))
)
)
((= main_flag 2)(printsinglesheet))
((= main_flag 3) (layout))
((= main_flag 4) (hidraulico))
((= main_flag 5) (eletrico))
((= main_flag 6) (luminotecnico))
((= main_flag 15) (secoes))
((= main_flag 7) (forro))
((= main_flag 8) (piso))
((= main_flag 9) (arcondicionado))
((= main_flag 10) (reexibir))
((= main_flag 11) (fixallcotas))
((= main_flag 12) (fixsomecotas))
((= main_flag 13) (changecolorstogrey))
((= main_flag 14) (changecolorsback))
((= main_flag 17) (beltb))
((= main_flag 16) (listagemindividual))
)
;Start and unload the DCL
(start_dialog)
(unload_dialog dcl_id)
(princ)
);defun
; ****************************************************************************************************************************
;PRINTALLTOPDF ***************************************************************************************************************
(defun printalltopdf (/ dwg file hnd i len llpt lst mn mx ss tab urpt subfolder cpath newpath currententity scale)
(setq p1 (getpoint "\nFaça a seleção das pranchas à serem impressas:"))
(setq p2 (getcorner p1))
(setq nomeescolhido(GetString T "\nDigite um nome para as pranchas:"))
(if (setq ss (ssget "_C" p1 p2 '((0 . "INSERT") (2 . "A4-20,A4-25,A4-50,A4-75,A4-100,A4-125,A3-25,A3-50,A3-75,A3-100,A3-125,A2-25,A2-50,A2-75,A2-100,A2-125"))))
(progn
(repeat (setq i (sslength ss))
(setq hnd (ssname ss (setq i (1- i)))
tab (cdr (assoc 410 (entget hnd)))
lst (cons (cons tab hnd) lst)
)
)
(setq lst (vl-sort lst '(lambda (x y) (> (car x) (car y)))))
(setq i 0)
(foreach x lst
;Nesta parte, faço a lógica para decidir se a planta é Landscape ou Portrait,
;pegando o Bounding Box dela para fazer a matemática
(vla-GetBoundingBox (vlax-ename->vla-object (cdr x)) 'minExt 'maxExt)
(setq minExt (vlax-safearray->list minExt) maxExt (vlax-safearray->list maxExt))
(setq orientation "Landscape")
(if
(<
(- (nth 0 maxExt) (nth 0 minExt))
(- (nth 1 maxExt) (nth 1 minExt))
)
(setq orientation "Portrait")
)
;Pego o nome do bloco (A4025, A4-50, etc)
(setq entityname (vla-get-effectivename (vlax-ename->vla-object (cdr x))))
(if
(= entityname "A4-20")
(progn
(setq papersize a4fullbleed)
(setq escala "1=2")
)
)
(if
(= entityname "A4-25")
(progn
(setq papersize a4fullbleed)
(setq escala "1=2.5")
)
)
(if
(= entityname "A4-50")
(progn
(setq papersize a4fullbleed)
(setq escala "1=5")
)
)
(if
(= entityname "A4-75")
(progn
(setq papersize a4fullbleed)
(setq escala "1=7.5")
)
)
(if
(= entityname "A4-100")
(progn
(setq papersize a4fullbleed)
(setq escala "1=10")
)
)
(if
(= entityname "A4-125")
(progn
(setq papersize a4fullbleed)
(setq escala "1=12.5")
)
)
;A3
(if
(= entityname "A3-25")
(progn
(setq papersize a3fullbleed)
(setq escala "1=2.5")
)
)
(if
(= entityname "A3-50")
(progn
(setq papersize a3fullbleed)
(setq escala "1=5")
)
)
(if
(= entityname "A3-75")
(progn
(setq papersize a3fullbleed)
(setq escala "1=7.5")
)
)
(if
(= entityname "A3-100")
(progn
(setq papersize a3fullbleed)
(setq escala "1=10")
)
)
(if
(= entityname "A3-125")
(progn
(setq papersize a3fullbleed)
(setq escala "1=12.5")
)
)
;A2 com FitToPaper para sair na A3
(if
(= entityname "A2-25")
(progn
(setq papersize a2fullbleed)
(setq escala "1=2.5")
)
)
(if
(= entityname "A2-50")
(progn
(setq papersize a2fullbleed)
(setq escala "1=5")
)
)
(if
(= entityname "A2-75")
(progn
(setq papersize a2fullbleed)
(setq escala "1=7.5")
)
)
(if
(= entityname "A2-100")
(progn
(setq papersize a2fullbleed)
(setq escala "1=10")
)
)
(if
(= entityname "A2-125")
(progn
(setq papersize a2fullbleed)
(setq escala "1=12.5")
)
)
;Faço a seleção da área da prancha
(vla-getboundingbox (vlax-ename->vla-object (cdr x)) 'mn 'mx)
(setq llpt (vlax-safearray->list mn)
urpt (vlax-safearray->list mx)
len (distance llpt (list (car urpt) (cadr llpt)))
)
; Aqui embaixo eu crio uma Subpasta, onde será salvo o Output
; Var "SUBFOLDER" indica o nome da pasta a ser criada
(setq subfolder "PDFs")
(setq cpath (getvar "dwgprefix"))
(Setq newpath (strcat cpath subfolder))
(if (not (findfile newpath))(vl-mkdir newpath))
(setq file (strcat newpath "\\" nomeescolhido " " (substr (setq ptx (rtos (cadr urpt) 2 0)) 1 5) " - " (substr (setq ptx (rtos (car urpt) 2 0)) 1 5) ".pdf"))
;Deleto arquivos antigos
(if (findfile file) (vl-file-delete file))
(command "-plot"
"yes"
(car x)
pdfplotter
papersize
"Millimeters"
orientation
"No"
"Window"
llpt
urpt
escala
"Center"
"yes"
ctb
"yes"
""
)
(if (/= (car x) "Model")
(command "No" "No" file "no" "Yes")
(command
file
"no"
"Yes"
)
)
);foreach
(setq lst nil)
);progn
);if
(princ)
);defun
;PRINTALLTOPDF ***************************************************************************************************************
;PRINTALLA3 ***************************************************************************************************************
(defun printalla3 (/ dwg file hnd i len llpt mn mx tab urpt subfolder cpath newpath currententity scale
lst2
ss2
)
(initget "A4-25 A4-50 A4-75 A4-100 A4-125 A3-50 A3-75 A3-100 A3-125 A2-50 A2-75 A2-100 A2-125")
(setq blocksize (cond ( (getkword "\nChoose [A4-25/A4-50/A4-75/A4-100/A4-125/A3-50/A3-75/A3-100/A3-125/A2-50/A2-75/A2-100/A2-125] <A3-100>: ") ) ( "A3-100" )))
(if (setq ss2 (ssget "_X" (list '(0 . "INSERT") (cons 2 blocksize))))
(progn
(repeat (setq i (sslength ss2))
(setq hnd (ssname ss2 (setq i (1- i)))
tab (cdr (assoc 410 (entget hnd)))
lst2 (cons (cons tab hnd) lst2)
)
)
(setq lst2 (vl-sort lst2 '(lambda (x y) (> (car x) (car y)))))
(setq i 0)
;Crio uma variável para armazenar um numero que será usado dentro do FOREACH, e zerado quando sair
;(setq plantanumber 1)
(setq count 0)
;Verificação da necessidade de imprimir essa planta
(repeat 8
(setq PlotThis "0")
(if (= count 0) (if (= plotLayout "1")(setq PlotThis "1")))
(if (= count 1) (if (= plotHidraulico "1")(setq PlotThis "1")))
(if (= count 2) (if (= plotEletrico "1")(setq PlotThis "1")))
(if (= count 3) (if (= plotLuminotecnico "1")(setq PlotThis "1")))
(if (= count 4) (if (= plotSecoes "1")(setq PlotThis "1")))
(if (= count 5) (if (= plotForro "1")(setq PlotThis "1")))
(if (= count 6) (if (= plotPiso "1")(setq PlotThis "1")))
(if (= count 7) (if (= plotArcondicionado "1")(setq PlotThis "1")))
(if (= count 0) (setq none(layout)))
(if (= count 1) (setq none(hidraulico)))
(if (= count 2) (setq none(eletrico)))
(if (= count 3) (setq none(luminotecnico)))
(if (= count 4) (setq none(secoes)))
(if (= count 5) (setq none(forro)))
(if (= count 6) (setq none(piso)))
(if (= count 7) (setq none(arcondicionado)))
(if (= count 0) (setq none(changecolorsback)))
(if (= count 1) (setq none(changecolorstogrey)))
(if (= count 2) (setq none(changecolorstogrey)))
(if (= count 3) (setq none(changecolorstogrey)))
(if (= count 4) (setq none(changecolorstogrey)))
(if (= count 5) (setq none(changecolorsback)))
(if (= count 6) (setq none(changecolorsback)))
(if (= count 7) (setq none(changecolorstogrey)))
(setq nomedaplanta "error")
(if (= count 0) (setq nomedaplanta "Layout"))
(if (= count 1) (setq nomedaplanta "Hidrulico"))
(if (= count 2) (setq nomedaplanta "Eltrico"))
(if (= count 3) (setq nomedaplanta "Luminotcnico"))
(if (= count 4) (setq nomedaplanta "Sees"))
(if (= count 5) (setq nomedaplanta "Forro"))
(if (= count 6) (setq nomedaplanta "Piso"))
(if (= count 7) (setq nomedaplanta "Ar Condicionado"))
(setq escala "Fit")
(if (= blocksize "A4-25") (setq escala "1=2.5"))
(if (= blocksize "A4-50") (setq escala "1=5"))
(if (= blocksize "A4-75") (setq escala "1=7.5"))
(if (= blocksize "A4-100") (setq escala "1=10"))
(if (= blocksize "A4-125") (setq escala "1=12.5"))
(if (= blocksize "A3-50") (setq escala "1=5"))
(if (= blocksize "A3-75") (setq escala "1=7.5"))
(if (= blocksize "A3-100") (setq escala "1=10"))
(if (= blocksize "A3-125") (setq escala "1=12.5"))
(if (= blocksize "A2-50") (setq escala "1=5"))
(if (= blocksize "A2-75") (setq escala "1=7.5"))
(if (= blocksize "A2-100") (setq escala "1=10"))
(if (= blocksize "A2-125") (setq escala "1=12.5"))
(setq papersize "Fit")
(if (= blocksize "A4-25") (setq papersize a4fullbleed))
(if (= blocksize "A4-50") (setq papersize a4fullbleed))
(if (= blocksize "A4-75") (setq papersize a4fullbleed))
(if (= blocksize "A4-100") (setq papersize a4fullbleed))
(if (= blocksize "A4-125") (setq papersize a4fullbleed))
(if (= blocksize "A3-50") (setq papersize a3fullbleed))
(if (= blocksize "A3-75") (setq papersize a3fullbleed))
(if (= blocksize "A3-100") (setq papersize a3fullbleed))
(if (= blocksize "A3-125") (setq papersize a3fullbleed))
(if (= blocksize "A2-50") (setq papersize a2fullbleed))
(if (= blocksize "A2-75") (setq papersize a2fullbleed))
(if (= blocksize "A2-100") (setq papersize a2fullbleed))
(if (= blocksize "A2-125") (setq papersize a2fullbleed))
(if (= PlotThis "1")
(foreach x lst2
;Nesta parte, faço a lógica para decidir se a planta é Landscape ou Portrait,
;pegando o Bounding Box dela para fazer a matemática
(vla-GetBoundingBox (vlax-ename->vla-object (cdr x)) 'minExt 'maxExt)
(setq minExt (vlax-safearray->list minExt) maxExt (vlax-safearray->list maxExt))
(setq orientation "Landscape")
(if
(<
(- (nth 0 maxExt) (nth 0 minExt))
(- (nth 1 maxExt) (nth 1 minExt))
)
(setq orientation "Portrait")
)
; ---------------
;Faço a seleção da área da prancha
(vla-getboundingbox (vlax-ename->vla-object (cdr x)) 'mn 'mx)
(setq llpt (vlax-safearray->list mn)
urpt (vlax-safearray->list mx)
len (distance llpt (list (car urpt) (cadr llpt)))
)
; ----------------
; Aqui embaixo eu crio uma Subpasta, onde será salvo o Output
; Var "SUBFOLDER" indica o nome da pasta a ser criada
(setq subfolder "Plantas Gerais")
(setq cpath (getvar "dwgprefix"))
(Setq newpath (strcat cpath subfolder))
(if (not (findfile newpath))(vl-mkdir newpath))
(setq file (strcat newpath "\\" nomedaplanta " - " (substr (setq ptx (rtos (car urpt) 2 0)) 1 5) ".pdf"))
;Deleto arquivos antigos
(if (findfile file) (vl-file-delete file))
; ---------------
(command "-plot"
"yes"
(car x)
pdfplotter
papersize
"Millimeters"
orientation
"No"
"Window"
llpt
urpt
escala
"Center"
"yes"
ctb
"yes"
""
)
(if (/= (car x) "Model")
(command "No" "No" file "no" "Yes")
(command
file
"no"
"Yes"
)
)
) ;foreach
) ;if
;;Adiciono mais um na var COUNT pra lógica funcionar lá em cima
(setq count (1+ count))
) ;repeat
(setq lst2 nil)
) ;progn
) ;if
(command "_laythw") ;EXIBE TODAS AS LAYERS NOVAMENTE
(setq none(changecolorsback))
) ;end defun
;PRINTALLA3 ***************************************************************************************************************
;PRINTSINGLESHEET ***************************************************************************************************************
(defun printsinglesheet()
;LÓGICA PARA DECIDIR SE ESTÁ NO SERVIDOR OU NA REDE E ESCOLHER A IMPRESSORA CERTA
;Pega todas as Plotters e armazena na lista "plottersList"
(setq ad (vla-get-activedocument (vlax-get-acad-object)))
(vla-RefreshPlotDeviceInfo (vla-get-activelayout ad))
(setq plottersList (vlax-safearray->list (vlax-variant-value (vla-getplotdevicenames (vla-item (vla-get-layouts ad) "Model")))))
(setq plotter physicalPlotterRedeA4)
(foreach a plottersList
(if (= a physicalPlotterServidorA4) (setq plotter physicalPlotterServidorA4))
);END foreach
;Seleciona todas as pranchas
(setq p1 (getpoint "\nFaça a seleção das pranchas à serem impressas:"))
(setq p2 (getcorner p1))
(if (setq ss (ssget "_C" p1 p2 '((0 . "INSERT") (2 . "A4-20,A4-25,A4-50,A4-75,A4-100,A4-125,A3-25,A3-50,A3-75,A3-100,A3-125,A2-25,A2-50,A2-75,A2-100,A2-125"))))
(progn
(repeat (setq i (sslength ss))
(setq hnd (ssname ss (setq i (1- i)))
tab (cdr (assoc 410 (entget hnd)))
lst (cons (cons tab hnd) lst)
)
)
(setq lst (vl-sort lst '(lambda (x y) (> (car x) (car y)))))
(setq i 0)
(foreach x lst
;Nesta parte, faço a lógica para decidir se a planta é Landscape ou Portrait,
;pegando o Bounding Box dela para fazer a matemática
(vla-GetBoundingBox (vlax-ename->vla-object (cdr x)) 'minExt 'maxExt)
(setq minExt (vlax-safearray->list minExt) maxExt (vlax-safearray->list maxExt))
(setq orientation "Landscape")
(if
(<
(- (nth 0 maxExt) (nth 0 minExt))
(- (nth 1 maxExt) (nth 1 minExt))
)
(setq orientation "Portrait")
)
(setq entityname (vla-get-effectivename (vlax-ename->vla-object (cdr x))))
(if
(= entityname "A4-20")
(progn
(setq papersize A4)
(setq escala "1=2")
)
)
(if
(= entityname "A4-25")
(progn
(setq papersize A4)
(setq escala "1=2.5")
)
)
(if
(= entityname "A4-50")
(progn
(setq papersize A4)
(setq escala "1=5")
)
)
(if
(= entityname "A4-75")
(progn
(setq papersize A4)
(setq escala "1=7.5")
)
)
(if
(= entityname "A4-100")
(progn
(setq papersize A4)
(setq escala "1=10")
)
)
(if
(= entityname "A4-125")
(progn
(setq papersize A4)
(setq escala "1=12.5")
)
)
;A3
(if
(= entityname "A3-25")
(progn
(setq papersize A3)
(setq escala "1=2.5")
)
)
(if
(= entityname "A3-50")
(progn
(setq papersize A3)
(setq escala "1=5")
)
)
(if
(= entityname "A3-75")
(progn
(setq papersize A3)
(setq escala "1=7.5")
)
)
(if
(= entityname "A3-100")
(progn
(setq papersize A3)
(setq escala "1=10")
)
)
(if
(= entityname "A3-125")
(progn
(setq papersize A3)
(setq escala "1=12.5")
)
)
;A2 com FitToPaper para sair na A3
(if
(= entityname "A2-25")
(progn
(setq papersize A3)
(setq escala "Fit")
)
)
(if
(= entityname "A2-50")
(progn
(setq papersize A3)
(setq escala "Fit")
)
)
(if
(= entityname "A2-75")
(progn
(setq papersize A3)
(setq escala "Fit")
)
)
(if
(= entityname "A2-100")
(progn
(setq papersize A3)
(setq escala "Fit")
)
)
(if
(= entityname "A2-125")
(progn
(setq papersize A3)
(setq escala "Fit")
)
)
; ******************************************************************************
(vla-getboundingbox (vlax-ename->vla-object (cdr x)) 'mn 'mx)
(setq llpt (vlax-safearray->list mn)
urpt (vlax-safearray->list mx)
len (distance llpt (list (car urpt) (cadr llpt)))
)
; ---------------
(command "-plot"
"yes"
(car x)
plotter
papersize
"Millimeters"
orientation
"No"
"Window"
llpt
urpt
escala
"Center"
"yes"
ctb
"yes"
""
)
; (setq currentItemInList (+ currentItemInList 1))
; (if
; (= currentItemInList lstLength)
; (command "No" "No" "Yes")
; (command "No" "No" "Yes")
; )
(command "No" "No" "Yes")
;(if (/= (car x) "Model")
; (command "No" "No" "Yes")
;)
);foreach
(setq lst nil)
);progn
);if
);defun
;PRINTSINGLESHEET ***************************************************************************************************************
;FUNÇÕES DE SUPORTE ***************************************************************************************************************
;MÉTODO PARA TROCAR COR DOS LAYOUTS PARA CINZA
(defun changecolorstogrey()
(command "_.layer" "_thaw" "1 Layout 01,1 Layout 02,1 Layout 03" "")
(command "_.layer" "_color" 252 "1 Layout 01,1 Layout 02,1 Layout 03" "")
)
;MÉTODO PARA TROCAR COR DOS LAYOUTS DE VOLTA PARA VERMELHO E AMARELO
(defun changecolorsback()
(command "_.layer" "_color" 1 "1 Layout 01" "")
(command "_.layer" "_color" 2 "1 Layout 02" "")
(command "_.layer" "_color" 3 "1 Layout 03" "")
)
; MOSTRAR LAYOUT
(defun layout ()
(setq oldlayer (getvar "CLAYER")) ;Pega a layer atual
(command "setvar" "clayer" "0") ;Seta a Layer Atual como Layer 0
(command "_laythw") ;Exibe todas as layers para depois apagar as específicas
(command "_.layer" "_freeze" "2 Hidráulica,2 Hidráulica Cotas,3 Elétrico,3 Elétrico Cotas,4 Luminotécnico,4 Luminotécnico Cotas,4 Luminotécnico Seções,5 Forro,5 Forro Contorno,5 Forro Cotas,6 Piso,6 Piso Cotas,7 Ar Condicionado,7 Ar Condicionado Cotas" "")
(setvar "CLAYER" oldlayer) ;Retorna a layer
)
; MOSTRAR HIDRAULICO
(defun hidraulico ()
(setq oldlayer (getvar "CLAYER"))
(command "setvar" "clayer" "0")
(command "_laythw")
(command "_.layer" "_freeze" "1 Layout Cotas,1 Layout Texto,3 Elétrico,3 Elétrico Cotas,4 Luminotécnico,4 Luminotécnico Cotas,4 Luminotécnico Seções,5 Forro,5 Forro Contorno,5 Forro Cotas,6 Piso,6 Piso Cotas,7 Ar Condicionado,7 Ar Condicionado Cotas" "")
(setvar "CLAYER" oldlayer)
)
; MOSTRAR ELÉTRICO
(defun eletrico ()
(setq oldlayer (getvar "CLAYER"))
(command "setvar" "clayer" "0")
(command "_laythw")
(command "_.layer" "_freeze" "1 Layout 01,1 Layout 02,1 Layout 03,1 Layout Cotas,1 Layout Texto,2 Hidráulica,2 Hidráulica Cotas,4 Luminotécnico,4 Luminotécnico Cotas,4 Luminotécnico Seções,5 Forro,5 Forro Contorno,5 Forro Cotas,6 Piso,6 Piso Cotas,7 Ar Condicionado,7 Ar Condicionado Cotas" "")
(setvar "CLAYER" oldlayer)
)
;MOSTRAR LUMINOTÉCNICO
(defun luminotecnico ()
(setq oldlayer (getvar "CLAYER"))
(command "setvar" "clayer" "0")
(command "_laythw")
(command "_.layer" "_freeze" "1 Layout Cotas,1 Layout Texto,2 Hidráulica,2 Hidráulica Cotas,3 Elétrico,3 Elétrico Cotas,4 Luminotécnico Seções,5 Forro,5 Forro Cotas,6 Piso,6 Piso Cotas,7 Ar Condicionado,7 Ar Condicionado Cotas" "")
(setvar "CLAYER" oldlayer)
)
; MOSTRAR SEÇÕES
(defun secoes ()
(setq oldlayer (getvar "CLAYER"))
(command "setvar" "clayer" "0")
(command "_laythw")
(command "_.layer" "_freeze" "1 Layout 01,1 Layout 02,1 Layout 03,1 Layout Cotas,1 Layout Texto,2 Hidráulica,2 Hidráulica Cotas,3 Elétrico,3 Elétrico Cotas,4 Luminotécnico Cotas,5 Forro,5 Forro Cotas,6 Piso,6 Piso Cotas,7 Ar Condicionado,7 Ar Condicionado Cotas" "")
(setvar "CLAYER" oldlayer)
)
; MOSTRAR FORRO
(defun forro ()
(setq oldlayer (getvar "CLAYER"))
(command "setvar" "clayer" "0")
(command "_laythw")
(command "_.layer" "_freeze" "1 Layout 01,1 Layout 02,1 Layout 03,1 Layout Cotas,1 Layout Texto,2 Hidráulica,2 Hidráulica Cotas,3 Elétrico,3 Elétrico Cotas,4 Luminotécnico,4 Luminotécnico Cotas,4 Luminotécnico Seções,6 Piso,6 Piso Cotas,7 Ar Condicionado,7 Ar Condicionado Cotas" "")
(setvar "CLAYER" oldlayer)
)
; MOSTRAR PISO
(defun piso ()
(setq oldlayer (getvar "CLAYER"))
(command "setvar" "clayer" "0")
(command "_laythw")
(command "_.layer" "_freeze" "1 Layout 01,1 Layout 02,1 Layout 03,1 Layout Cotas,1 Layout Texto,2 Hidráulica,2 Hidráulica Cotas,3 Elétrico,3 Elétrico Cotas,4 Luminotécnico,4 Luminotécnico Cotas,4 Luminotécnico Seções,5 Forro,5 Forro Contorno,5 Forro Cotas,7 Ar Condicionado,7 Ar Condicionado Cotas" "")
(setvar "CLAYER" oldlayer)
)
; MOSTRAR ARCONDICIONADO
(defun arcondicionado ()
(setq oldlayer (getvar "CLAYER"))
(command "setvar" "clayer" "0")
(command "_laythw")
(command "_.layer" "_freeze" "1 Layout 01,1 Layout 02,1 Layout 03,1 Layout Cotas,1 Layout Texto,2 Hidráulica,2 Hidráulica Cotas,3 Elétrico,3 Elétrico Cotas,4 Luminotécnico,4 Luminotécnico Cotas,4 Luminotécnico Seções,5 Forro,5 Forro Contorno,5 Forro Cotas,6 Piso,6 Piso Cotas" "")
(setvar "CLAYER" oldlayer)
)
; REEXIBIR TUDO
(defun reexibir ()
(setq oldlayer (getvar "CLAYER"))
(command "setvar" "clayer" "0")
(command "_laythw")
(setvar "CLAYER" oldlayer)
)
; DEFUN PARA CORRIGIR SOMENTE AS COTAS SELECIONADAS
(defun fixsomecotas ( / ss textString)
(if
(and (setq ss (ssget '((0 . "DIMENSION")))) (setq textString ""))
;THEN
(progn
(vla-startundomark
(cond
(*activeDoc*)
(
(setq *activeDoc* (vla-get-activedocument (vlax-get-acad-object)))
)
)
)
(vlax-for oDim (setq ss (vla-get-activeselectionset *activeDoc*)) (vla-put-textoverride oDim textString))
(vla-delete ss)
(vla-endundomark *activeDoc*)
);_progn
;ELSE
(prompt "\n** Nada selecionado! ** ")
);_if
(princ)
);_defun
; DEFUN PARA CORRIGIR TODAS AS COTAS
(defun fixallcotas ( / ss textString)
(if
;PREDICATE
(and (setq ss (ssget "x" '((0 . "DIMENSION"))))(setq textString ""))
;THEN
(progn
(vla-startundomark
(cond
(*activeDoc*)
(
(setq *activeDoc* (vla-get-activedocument (vlax-get-acad-object)))
)
)
)
(vlax-for oDim(setq ss (vla-get-activeselectionset *activeDoc*))(vla-put-textoverride oDim textString))
(vla-delete ss)
(vla-endundomark *activeDoc*)
);_progn
;ELSE
(prompt "\n** Nada selecionado ** ")
);_if
(princ)
);_defun
; ***********************************************************************************************************************************************
; LISTAGEM INDIVIDUAL
; ***********************************************************************************************************************************************
(defun listagemindividual (/ blk_id blk_len blk_name blks ent h header_lsp height i j Total
len0 lst_blk msp pt row ss str tblobj width width1 width2 x y)
(vl-load-com)
(defun TxtWidth (val h msp / txt minp maxp)
(setq txt (vla-AddText msp val (vlax-3d-point '(0 0 0)) h))
(vla-getBoundingBox txt 'minp 'maxp)
(vla-Erase txt)
(-(car(vlax-safearray->list maxp))(car(vlax-safearray->list minp))))
(defun GetOrCreateTableStyle (tbl_name / name namelst objtblsty objtblstydic tablst txtsty)
(setq objTblStyDic (vla-item (vla-get-dictionaries *adoc) "ACAD_TABLESTYLE"))
(foreach itm (vlax-for itm objTblStyDic
(setq tabLst (append tabLst (list itm))))
(if (not
(vl-catch-all-error-p
(setq name (vl-catch-all-apply 'vla-get-Name (list itm)))))
(setq nameLst (append nameLst (list name)))))
(if (not (vl-position tbl_name nameLst))
(vla-addobject objTblStyDic tbl_name "AcDbTableStyle"))
(setq objTblSty (vla-item objTblStyDic tbl_name)
TxtSty (variant-value (vla-getvariable *adoc "TextStyle")))
(mapcar '(lambda (x)(vla-settextstyle objTblSty x TxtSty))
(list acTitleRow acHeaderRow acDataRow))
(vla-setvariable *adoc "CTableStyle" tbl_name))
(defun GetObjectID (obj)
(if (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE"))
(vlax-invoke-method *util 'GetObjectIdString obj :vlax-false)
(vla-get-Objectid obj)))
;PROGRAMA COMEÇA AQUI
(if (setq ss (ssget (list (cons 0 "INSERT")))) ;(SSGET pra fazer a seleção de blocos)
(progn
(vl-load-com)
(setq i -1 len0 8)
(while (setq ent (ssname ss (setq i (1+ i)))) ;(SSNAME retorna o nome do bloco, da lista SS, na posição i)
(setq blk_name (cdr (assoc 2 (entget ent)))) ;(Isso aqui deve pegar a string do nome certinho)
(if (> (setq blk_len (strlen blk_name)) len0)
(setq str blk_name len0 blk_len))
(if (not (assoc blk_name lst_blk))
(setq lst_blk (cons (cons blk_name 1) lst_blk))
(setq lst_blk (subst (cons blk_name (1+ (cdr (assoc blk_name lst_blk))))
(assoc blk_name lst_blk) lst_blk)))
);while
(setq lst_blk (vl-sort lst_blk '(lambda (x y) (< (car x) (car y)))))
(setq Total 0) ;Cria a variável que armazenará a quantidade total de blocos
(foreach I lst_blk (setq Total (+ Total (cdr I)))) ;Acha a quantidade de blocos
(or *h* (setq *h* (* (getvar "dimtxt")(getvar "dimscale"))))
(initget 6)
(setq AmbienteName (GetString T "Digite o nome do ambiente:")) ;Aqui eu peço o nome do ambiente
;(setq h (getreal (strcat "\nText Height <" (rtos *h*) "> :"))) ;BACKUP do Input para altura do texto
(setq h 10) ;Altura fixa do texto armazenada na var h
(if h (setq *h* h) (setq h *h*))
(or *adoc (setq *adoc (vla-get-ActiveDocument (vlax-get-acad-object))))