-
Notifications
You must be signed in to change notification settings - Fork 1
/
zzACAD16ToolBox.lsp
1805 lines (1689 loc) · 40.2 KB
/
zzACAD16ToolBox.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
;;---------------------=={ Area Label }==---------------------;;
;; ;;
;; Allows the user to label picked areas or objects and ;;
;; either display the area in an ACAD Table (if available), ;;
;; optionally using fields to link area numbers and objects; ;;
;; or write it to file. ;;
;;------------------------------------------------------------;;
;; Author: Lee Mac, Copyright ?2011 - www.lee-mac.com ;;
;;------------------------------------------------------------;;
;; Version 1.9 - 29-10-2011 ;;
;;------------------------------------------------------------;;
(defun c:zzArea nil (AreaLabel 3))
(defun c:zzA nil (AreaLabel 3))
;; Areas to Text
(defun c:zzArea2Table nil (AreaLabel 1))
;; Areas to Table
(defun c:zzArea2File nil (AreaLabel 2))
;点抽稀VBA宏,将VBA宏命名为acad.dvb并放到AutoCAD安装目录下自动加载
(defun c:zzDcx ()
(command "_-VBARUN" "vba_zzDcx")
)
;; Areas to File
;;------------------------------------------------------------;;
(defun AreaLabel (flag / *error* _startundo _endundo
_centroid _text _open _select
_getobjectid _isannotative acdoc acspc
ap ar as cf cm el
fd fl fo n of om
p1 pf pt sf st t1
t2 tb th ts tx ucsxang
ucszdir
)
;;------------------------------------------------------------;;
;; Adjustments ;;
;;------------------------------------------------------------;;
(setq h1 "断 面 面 积 统 计 表"
;; Heading
t1 "序号"
;; Number Title
t2 "面积"
;; Area Title
pf ""
;; Number Prefix (optional, "" if none)
sf ""
;; Number Suffix (optional, "" if none)
ap ""
;; Area Prefix (optional, "" if none)
as ""
;; Area Suffix (optional, "" if none)
cf 1.0
;; Area Conversion Factor (e.g. 1e-6 = mm2->m2)
fd t
;; Use fields to link numbers/objects to table (t=yes, nil=no)
fo "%lu6%qf1"
;; Area field formatting
)
(if (= nil areaName)
(setq areaName "")
)
;;------------------------------------------------------------;;
(defun *error* (msg)
(if cm
(setvar 'CMDECHO cm)
)
(if el
(progn (entdel el) (setq el nil))
)
(if acdoc
(_EndUndo acdoc)
)
(if (and of (eq 'FILE (type of)))
(close of)
)
(if (and Shell (not (vlax-object-released-p Shell)))
(vlax-release-object Shell)
)
(if (null (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
(princ (strcat "\n--> Error: " msg))
)
(princ)
)
;;------------------------------------------------------------;;
(defun _StartUndo (doc)
(_EndUndo doc)
(vla-StartUndoMark doc)
)
;;------------------------------------------------------------;;
(defun _EndUndo (doc)
(if (= 8 (logand 8 (getvar 'UNDOCTL)))
(vla-EndUndoMark doc)
)
)
;;------------------------------------------------------------;;
(defun _centroid (space objs / reg cen)
(setq reg (car (vlax-invoke space 'addregion objs))
cen (vlax-get reg 'centroid)
)
(vla-delete reg)
(trans cen 1 0)
)
;;------------------------------------------------------------;;
(defun _text (space point string height rotation / text)
(setq text (vla-addtext space string (vlax-3D-point point) height))
(vla-put-alignment text acalignmentmiddlecenter)
(vla-put-textalignmentpoint text (vlax-3D-point point))
(vla-put-rotation text rotation)
text
)
;;------------------------------------------------------------;;
(defun _Open (target / Shell result)
(if (setq Shell (vla-getInterfaceObject
(vlax-get-acad-object)
"Shell.Application"
)
)
(progn
(setq result
(and
(or (eq 'INT (type target)) (setq target (findfile target)))
(not
(vl-catch-all-error-p
(vl-catch-all-apply
'vlax-invoke
(list Shell 'Open target)
)
)
)
)
)
(vlax-release-object Shell)
)
)
result
)
;;------------------------------------------------------------;;
(defun _Select (msg pred func init / e)
(setq pred (eval pred))
(while
(progn (setvar 'ERRNO 0)
(apply 'initget init)
(setq e (func msg))
(cond
((= 7 (getvar 'ERRNO))
(princ "\nMissed, try again.")
)
((eq 'STR (type e))
nil
)
((vl-consp e)
(if (and pred (not (pred (setq e (car e)))))
(princ "\nInvalid Object Selected.")
)
)
)
)
)
e
)
;;------------------------------------------------------------;;
(defun _GetObjectID (doc obj)
(if (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE"))
(vlax-invoke-method
(vla-get-Utility doc)
'GetObjectIdString
obj
:vlax-false
)
(itoa (vla-get-Objectid obj))
)
)
;;------------------------------------------------------------;;
(defun _isAnnotative (style / object annotx)
(and
(setq object (tblobjname "STYLE" style))
(setq
annotx (cadr (assoc -3 (entget object '("AcadAnnotative"))))
)
(= 1 (cdr (assoc 1070 (reverse annotx))))
)
)
;;------------------------------------------------------------;;
(setq acdoc (vla-get-activedocument (vlax-get-acad-object))
acspc (vlax-get-property
acdoc
(if (= 1 (getvar 'CVPORT))
'Paperspace
'Modelspace
)
)
ucszdir (trans '(0. 0. 1.) 1 0 t)
ucsxang (angle '(0. 0. 0.) (trans (getvar 'UCSXDIR) 0 ucszdir))
)
(_StartUndo acdoc)
(setq cm (getvar 'CMDECHO))
(setvar 'CMDECHO 0)
(setq om (eq "1"
(cond ((getenv "LMAC_AreaLabel"))
((setenv "LMAC_AreaLabel" "0"))
)
)
)
(setq ts
(/ (getvar 'TEXTSIZE)
(if (_isAnnotative (getvar 'TEXTSTYLE))
(cond ((getvar 'CANNOSCALEVALUE))
(1.0)
)
1.0
)
)
)
(cond
((not (vlax-method-applicable-p acspc 'addtable))
(princ "\n--> Table Objects not Available in this Version.")
)
((= 4
(logand 4
(cdr (assoc 70 (tblsearch "LAYER" (getvar 'CLAYER))))
)
)
(princ "\n--> Current Layer Locked.")
)
((not
(setq *al:num
(cond
((= flag 3) 1)
(
(getint
(strcat "\n面积序号起始值 <"
(itoa (setq *al:num (1+ (cond (*al:num)
(0)
)
)
)
)
">: "
)
)
)
(*al:num)
)
)
)
)
((= flag 1)
(setq th
(* 2.
(if
(zerop
(setq th
(vla-gettextheight
(setq st
(vla-item
(vla-item
(vla-get-dictionaries acdoc)
"ACAD_TABLESTYLE"
)
(getvar 'CTABLESTYLE)
)
)
acdatarow
)
)
)
ts
(/ th
(if (_isAnnotative (vla-gettextstyle st acdatarow))
(cond ((getvar 'CANNOSCALEVALUE))
(1.0)
)
1.0
)
)
)
)
)
(if
(cond
(
(progn (initget "Add")
(vl-consp (setq pt
(getpoint "\n输入放置面积表的位置 <选择现有面积表>: "
)
)
)
)
(setq tb
(vla-addtable
acspc
(vlax-3D-point (trans pt 1 0))
2
2
th
(* 1.5 th (max (strlen t1) (strlen t2)))
;表格宽度在这设置
)
)
(vla-put-direction tb (vlax-3D-point (getvar 'UCSXDIR)))
(vla-settext tb 0 0 h1)
(vla-settext tb 1 0 t1)
(vla-settext tb 1 1 t2)
(while
(progn
(if om
(setq p1
(_Select
(strcat "\n选择下一个对象[拾点]<退出>: ")
'(lambda (x)
(and
(vlax-property-available-p
(vlax-ename->vla-object x)
'area
)
(not (eq "HATCH" (cdr (assoc 0 (entget x)))))
(or (eq "REGION" (cdr (assoc 0 (entget x))))
(vlax-curve-isclosed x)
)
)
)
entsel
'("Pick")
)
)
(progn (initget "Object")
(setq p1 (getpoint "\n选择区域[对象]<退出>: "))
)
)
(cond
((null p1)
(vla-delete tb)
)
((eq "Pick" p1)
(setq om nil)
t
)
((eq "Object" p1)
(setq om t)
)
((eq 'ENAME (type p1))
(setq tx
(cons
(_text acspc
(_centroid
acspc
(list (setq p1 (vlax-ename->vla-object p1)))
)
(strcat pf (itoa *al:num) sf)
ts
ucsxang
)
tx
)
)
(vla-insertrows tb (setq n 2) th 1)
(vla-settext
tb
n
1
(if fd
(strcat "%<\\AcObjProp Object(%<\\_ObjId "
(_GetObjectID acdoc p1)
">%).Area \\f \""
fo
"\">%"
)
(strcat ap (rtos (* cf (vla-get-area p1)) 2 2) as)
)
)
(vla-settext
tb
n
0
(if fd
(strcat "%<\\AcObjProp Object(%<\\_ObjId "
(_GetObjectID acdoc (car tx))
">%).TextString>%"
)
(strcat pf (itoa *al:num) sf)
)
)
nil
)
((vl-consp p1)
(setq el (entlast))
(vl-cmdf "_.-boundary" "_A" "_I" "_N"
"" "_O" "_P" "" "_non"
p1 ""
)
(if (not (equal el (setq el (entlast))))
(progn
(setq tx
(cons
(_text
acspc
(_centroid acspc
(list (vlax-ename->vla-object el))
)
(strcat pf (itoa *al:num) sf)
ts
ucsxang
)
tx
)
)
(vla-insertrows tb (setq n 2) th 1)
(vla-settext
tb
n
1
(strcat ap
(rtos (* cf (vlax-curve-getarea el)) 2 2)
as
)
)
(vla-settext
tb
n
0
(if fd
(strcat "%<\\AcObjProp Object(%<\\_ObjId "
(_GetObjectID acdoc (car tx))
">%).TextString>%"
)
(strcat pf (itoa *al:num) sf)
)
)
(redraw el 3)
nil
)
(vla-delete tb)
)
)
)
)
)
(not (vlax-erased-p tb))
)
(
(and
(setq tb
(_Select "\n选择现有表加入: "
'(lambda (x)
(eq "ACAD_TABLE" (cdr (assoc 0 (entget x))))
)
entsel
nil
)
)
(< 1
(vla-get-columns (setq tb (vlax-ename->vla-object tb)))
)
)
(setq n (1- (vla-get-rows tb))
*al:num (1- *al:num)
)
)
)
(progn
(while
(if om
(setq p1
(_Select (strcat "\nSelect Object ["
(if tx
"Undo/"
""
)
"Pick] <Exit>: "
)
'(lambda (x)
(and
(vlax-property-available-p
(vlax-ename->vla-object x)
'area
)
(not (eq "HATCH" (cdr (assoc 0 (entget x)))))
(or (eq "REGION" (cdr (assoc 0 (entget x))))
(vlax-curve-isclosed x)
)
)
)
entsel
(list (if tx
"Undo Pick"
"Pick"
)
)
)
)
(progn (initget (if tx
"Undo Object"
"Object"
)
)
(setq p1 (getpoint (strcat "\n选择区域["
(if tx
"Undo/"
""
)
"Object] <Exit>: "
)
)
)
)
)
(cond
((and tx (eq "Undo" p1))
(if el
(progn (entdel el) (setq el nil))
)
(vla-deleterows tb n 1)
(vla-delete (car tx))
(setq n (1- n)
tx (cdr tx)
*al:num (1- *al:num)
)
)
((eq "Undo" p1)
(princ "\n--> 啥也没干.")
)
((eq "Object" p1)
(if el
(progn (entdel el) (setq el nil))
)
(setq om t)
)
((eq "Pick" p1)
(setq om nil)
)
((and om (eq 'ENAME (type p1)))
(setq tx
(cons
(_text acspc
(_centroid
acspc
(list (setq p1 (vlax-ename->vla-object p1)))
)
(strcat pf (itoa (setq *al:num (1+ *al:num))) sf)
ts
ucsxang
)
tx
)
)
(vla-insertrows tb (setq n (1+ n)) th 1)
(vla-settext
tb
n
1
(if fd
(strcat "%<\\AcObjProp Object(%<\\_ObjId "
(_GetObjectID acdoc p1)
">%).Area \\f \""
fo
"\">%"
)
(strcat ap (rtos (* cf (vla-get-area p1)) 2 2) as)
)
)
(vla-settext
tb
n
0
(if fd
(strcat "%<\\AcObjProp Object(%<\\_ObjId "
(_GetObjectID acdoc (car tx))
">%).TextString>%"
)
(strcat pf (itoa *al:num) sf)
)
)
)
((vl-consp p1)
(if el
(progn (entdel el) (setq el nil))
)
(setq el (entlast))
(vl-cmdf "_.-boundary" "_A" "_I" "_N"
"" "_O" "_P" "" "_non"
p1 ""
)
(if (not (equal el (setq el (entlast))))
(progn
(setq tx
(cons
(_text
acspc
(_centroid acspc
(list (vlax-ename->vla-object el))
)
(strcat pf (itoa (setq *al:num (1+ *al:num))) sf)
ts
ucsxang
)
tx
)
)
(vla-insertrows tb (setq n (1+ n)) th 1)
(vla-settext
tb
n
1
(strcat ap
(rtos (* cf (vlax-curve-getarea el)) 2 2)
as
)
)
(vla-settext
tb
n
0
(if fd
(strcat "%<\\AcObjProp Object(%<\\_ObjId "
(_GetObjectID acdoc (car tx))
">%).TextString>%"
)
(strcat pf (itoa *al:num) sf)
)
)
(redraw el 3)
)
(princ "\n--> Error Retrieving Area.")
)
)
)
)
(if el
(progn (entdel el) (setq el nil))
)
)
)
)
((= flag 2)
(and
(setq fl (getfiled "创建面积统计文件"
(cond (*file*)
("")
)
"txt;csv;xls"
1
)
)
(setq of (open fl "w"))
)
(setq *file* (vl-filename-directory fl)
de (cdr
(assoc (strcase (vl-filename-extension fl) t)
'((".txt" . "\t") (".csv" . ",") (".xls" . "\t"))
)
)
*al:num (1- *al:num)
)
(write-line h1 of)
(write-line (strcat t1 de t2) of)
(while
(if om
(setq p1
(_Select (strcat "\n选择对象[拾取]<退出>: ")
'(lambda (x)
(and
(vlax-property-available-p
(vlax-ename->vla-object x)
'area
)
(not (eq "HATCH" (cdr (assoc 0 (entget x)))))
(or (eq "REGION" (cdr (assoc 0 (entget x))))
(vlax-curve-isclosed x)
)
)
)
entsel
'("Pick")
)
)
(progn
(initget "Object")
(setq p1 (getpoint (strcat "\n选择区域[对象]<退出>: ")))
)
)
(cond
((eq "Object" p1)
(if el
(progn (entdel el) (setq el nil))
)
(setq om t)
)
((eq "Pick" p1)
(setq om nil)
)
((eq 'ENAME (type p1))
(_text
acspc
(_centroid acspc
(list (setq p1 (vlax-ename->vla-object p1)))
)
(strcat pf (itoa (setq *al:num (1+ *al:num))) sf)
ts
ucsxang
)
(write-line
(strcat pf
(itoa *al:num)
sf
de
ap
(rtos (* cf (vla-get-area p1)) 2)
as
)
of
)
)
((vl-consp p1)
(if el
(progn (entdel el) (setq el nil))
)
(setq el (entlast))
(vl-cmdf "_.-boundary" "_A" "_I" "_N"
"" "_O" "_P" "" "_non"
p1 ""
)
(if (not (equal el (setq el (entlast))))
(progn
(_text
acspc
(_centroid acspc (list (vlax-ename->vla-object el)))
(strcat pf (itoa (setq *al:num (1+ *al:num))) sf)
ts
ucsxang
)
(write-line
(strcat pf
(itoa *al:num)
sf
de
ap
(rtos (* cf (vlax-curve-getarea el)) 2 2)
as
)
of
)
(redraw el 3)
)
(princ "\n--> Error Retrieving Area.")
)
)
)
)
(if el
(progn (entdel el) (setq el nil))
)
(setq of (close of))
(_Open (findfile fl))
)
((= flag 3)
;为面积指定编号或名称,以便与方量表对应
;(setq areaName
; (cond
; (
; (getstring (strcat "\n面积编号 <\042" areaName "\042>: " ) )
; )
; (areaName)
; )
; )
(princ
"功能:标注封闭区域的面积。(C)中国电建一二·五联合体测量队 覃东 2017.05 [email protected]\n"
)
(if (= areaName "zz")
(setq areaName "")
)
(setq areaName_old areaName)
(setq areaName
(getstring (strcat "\n面积编号 <\042" areaName "\042>: ")
)
)
(if (= areaName "")
(setq areaName areaName_old)
)
(while
(if om
(setq p1
(_Select (strcat "\n选择对象[拾取]<退出>: ")
'(lambda (x)
(and
(vlax-property-available-p
(vlax-ename->vla-object x)
'area
)
(not (eq "HATCH" (cdr (assoc 0 (entget x)))))
(or (eq "REGION" (cdr (assoc 0 (entget x))))
(vlax-curve-isclosed x)
)
)
)
entsel
'("Pick")
)
)
(progn
(initget "Object")
(setq p1 (getpoint (strcat "\n选择区域<退出>: ")))
)
)
(cond
((eq "Object" p1)
(if el
(progn (entdel el) (setq el nil))
)
(setq om t)
)
((eq "Pick" p1)
(setq om nil)
)
((eq 'ENAME (type p1))
(_text
acspc
(_centroid acspc
(list (setq p1 (vlax-ename->vla-object p1)))
)
(strcat pf (rtos (* cf (vla-get-area p1)) 2) sf)
ts
ucsxang
)
)
((vl-consp p1)
(setq el (entlast))
(vl-cmdf "_.-boundary" "_A" "_I" "_N"
"" "_O" "_P" "" "_non"
p1 ""
)
(if (not (equal el (setq el (entlast))))
(progn
(_text
acspc
(_centroid acspc (list (vlax-ename->vla-object el)))
(strcat (if (and (/= areaName "zz") (/= areaName ""))
(strcat areaName ":")
(strcat "" "")
)
(rtos (* cf (vlax-curve-getarea el)) 2 2)
sf
)
ts
ucsxang
)
(redraw el 1)
)
(princ "\n--> Error Retrieving Area.")
)
)
)
)
)
)
(setenv "LMAC_AreaLabel"
(if om
"1"
"0"
)
)
(setvar 'CMDECHO cm)
(_EndUndo acdoc)
(princ)
)
;;生成方格网数据文件------------------------------------------------------------;;
;;;求模
(defun mod (numA numB)
(- (/ (* 1.0 numA) (* numB 1.0))
(fix (/ (* numA 1.0) (* 1.0 numB)))
)
)
(defun C:zzFGW (/ mscale gridDistCm pointId
datFile pointA pointB pA pB
gridDist zx_x zx_y zs_x zs_y
fileId gridPointX gridPointY
)
(princ
"功能:生成地形图方格网数据文件。(C)中国电建一二·五联合体测量队 覃东 2017.05 [email protected]\n"
)
(setq mscale
(getint "请输入成图比例尺分母(100/200/500/1000/2000/5000):"
)
)
(while (or (/= (mod mscale 100) 0) (<= mscale 0))
(setq mscale
(getint "请输入成图比例尺分母100/200/500/1000/2000/5000:")
)
)
;;;(setq gridDistCm (getint "请输入格网距离(cm):"))
(setq gridDistCm 10)
;;;默认10cm
(setq pointId 0)
;;;(setq datFile
;;; (getfiled "请输入格网坐标文件名:"
;;; (cond (*file*)
;;; ("")
;;; )
;;; "dat"
;;; 1
;;;)
;;;)
(setq datFile "D:\\地形图坐标方格网数据.dat")
(setq pointA (getpoint "请输入第一点:"))
(princ (strcat "N:"
(rtos (cadr pointA) 2 3)
" E:"
(rtos (car pointA) 2 3)
"\n"
)
)
(setq pointB (getpoint "请输入第二点:"))
(princ (strcat "N:"
(rtos (cadr pointB) 2 3)
" E:"
(rtos (car pointB) 2 3)
"\n"
)
)
(setq pA pointA
pB pointB
)
(setq pointA (list (min (car pA) (car pB))
(min (cadr pA) (cadr pB))
)
)
(setq pointB (list (max (car pA) (car pB))
(max (cadr pA) (cadr pB))
)
)
;;;格网距离:米
(setq gridDist (* (/ mscale 100) gridDistCm))
(setq zx_x (* (+ (fix (/ (car pointA) gridDist)) 1) gridDist))
(setq zx_y (* (+ (fix (/ (cadr pointA) gridDist)) 1) gridDist))
(setq zs_x (* (fix (/ (car pointB) gridDist)) gridDist))
(setq zs_y (* (fix (/ (cadr pointB) gridDist)) gridDist))
(setq gridPointX zx_x)