forked from xplan001/AutoCad-App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path文本动态对齐于曲线.lsp
1565 lines (1087 loc) · 64.1 KB
/
文本动态对齐于曲线.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
;;;; ;;
;; --=={ Dynamic Text Curve Align }==-- ;;
;; ;;
;; The Program will prompt the user to either Select existing text to align, ;;
;; or specify New Text. The user will then be prompted to select a curve, and ;;
;; the text specified/selected will be dynamically aligned to the selected ;;
;; curve. ;;
;; ;;
;; Additionally, the user can press +/- to alter the text offset from the curve ;;
;; and furthermore, toggle the text perpendicularity by pressing 'P' during ;;
;; text alignment. A Background Mask can be toggled by pressing 'B' when ;;
;; aligning MText. The Text can also be mirrored by pressing 'M' during text ;;
;; alignment. The TextStyle and Text Height may be altered by pressing 'S' when ;;
;; aligning text. ;;
;; ;;
;; DTRemove:- ;;
;; ------------ ;;
;; This function allows the user to remove Text/Object Associativity. Upon ;;
;; invoking this function, the user is prompted to select either Text or ;;
;; object. ;;
;; ;;
;; If the user picks an object, all text associativity with that object is ;;
;; removed. If the user picks a text object, the associativity between the ;;
;; text and the object that it was aligned with, is removed. ;;
;; ;;
;; The user can also press 'A' to clear all associativity within the drawing. ;;
;; ;;
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=;;
;; ;;
;; FUNCTION SYNTAX: DTCurve/DTRemove ;;
;; ;;
;; Notes:- ;;
;; ------------ ;;
;; Text and MText Justification will be changed to Middle Center Justification ;;
;; to allow text to be correctly aligned. ;;
;; ;;
;; Background Mask functionality can only be used when aligning MText. ;;
;; ;;
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=;;
;; ;;
;; AUTHOR: ;;
;; ;;
;; Copyright ?Lee McDonnell, November 2009. All Rights Reserved. ;;
;; ;;
;; { Contact: Lee Mac @ TheSwamp.org, CADTutor.net } ;;
;; ;;
;; WITH ADDITIONAL THANKS TO: ;;
;; ;;
;; ? Luis Esquivel (LE) ;;
;; ;;
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=;;
;; ;;
;; VERSION: ;;
;; ;;
;; ?1.0 ~¤~ 6th November 2009 ~¤~ ?First Release ;;
;;...............................................................................;;
;; ?1.1 ~¤~ 13th November 2009 ~¤~ ?Fixed bug that allowed text to ;;
;; aligned to multiple objects. ;;
;;...............................................................................;;
;; ?1.2 ~¤~ 15th November 2009 ~¤~ ?Added DTRemove to remove align ;;
;; associativity. ;;
;;...............................................................................;;
;; ?1.3 ~¤~ 15th November 2009 ~¤~ ?Added Ability to Align MText. ;;
;;...............................................................................;;
;; ?1.4 ~¤~ 16th November 2009 ~¤~ ?Added Ability to use a ;;
;; Background Mask, when aligning ;;
;; MText. ;;
;;...............................................................................;;
;; ?1.5 ~¤~ 16th November 2009 ~¤~ ?General Bug Fixes. ;;
;;...............................................................................;;
;; ?1.6 ~¤~ 17th November 2009 ~¤~ ?Updated code to work in all UCS. ;;
;;...............................................................................;;
;; ?1.7 ~¤~ 17th November 2009 ~¤~ ?Added Logo to DTRemove function. ;;
;;...............................................................................;;
;; ?1.8 ~¤~ 17th November 2009 ~¤~ ?Fixed Bug to allow correct text ;;
;; offset/perpendicularity setting ;;
;; when updating text by Reactor. ;;
;; ?General Bug Fixes. ;;
;;...............................................................................;;
;; ?1.9 ~¤~ 17th November 2009 ~¤~ ?Fixed Text Rotation bug, for ;;
;; Vertical lines. ;;
;;...............................................................................;;
;; ?2.0 ~¤~ 17th November 2009 ~¤~ ?General Bug Fixes. ;;
;; ?Added ability for user to ;;
;; manually input offset distance. ;;
;;...............................................................................;;
;; ?2.1 ~¤~ 19th November 2009 ~¤~ ?DTRemove updated to remove all ;;
;; XData from object. ;;
;;...............................................................................;;
;; ?2.2 ~¤~ 20th November 2009 ~¤~ ?Added Mirror Text Option. ;;
;;...............................................................................;;
;; ?2.3 ~¤~ 25th November 2009 ~¤~ ?Added TextStyle/Height Dialog. ;;
;;...............................................................................;;
;; ?2.4 ~¤~ 2nd December 2009 ~¤~ ?Fixed Dialog Bug. ;;
;;...............................................................................;;
;; ?2.5 ~¤~ 3rd December 2009 ~¤~ ?Added Selection highlighting. ;;
;;...............................................................................;;
;; ?2.6 ~¤~ 4th December 2009 ~¤~ ?Upgraded DTRemove function to ;;
;; include option to Remove All ;;
;; associativity from objects. ;;
;;...............................................................................;;
;; ?2.7 ~¤~ 7th December 2009 ~¤~ ?Re-Structured xData Storage to ;;
;; allow text to be aligned to same ;;
;; part of object upon re-alignment ;;
;;...............................................................................;;
;; ?2.8 ~¤~ 15th February 2010 ~¤~ ?Fixed realignment bug when line ;;
;; length is less than text. ;;
;; ?General Bug Fixes. ;;
;;...............................................................................;;
;; ?2.9 ~¤~ 16th February 2010 ~¤~ ?Updated Code Layout. ;;
;; ?Added call to turn off reactor ;;
;; whilst main function is running. ;;
;;...............................................................................;;
;; ;;
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=;;
;;
(setq app "DTCURVE") ;; XData Application Name
(or *Mac$Str* (setq *Mac$Str* "text")) ;; First-time Default Text String
(or *Mac$Per* (setq *Mac$Per* (/ pi 2.))) ;; Default Perpendicularity Setting
(or *Mac$tOff* (setq *Mac$tOff* 1.)) ;; Default Offset Factor
(or *Mac$Mirr* (setq *Mac$Mirr* 0.)) ;; Default Mirror Setting
(setq *Mac$tObj* "MTEXT") ;; Default Text Object to be Created [TEXT/MTEXT]
(setq *Mac$Mask* nil) ;; Background Mask as Default [t/nil]
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
(defun c:DTC (/ ; --=={ Local Functions }==--
*error* putxdat
; --=={ Local Variables }==--
CANG COBJ CODE
DATA DC_FNAME DC_TITLE DERV DIS DOC DRFT
ENT
GR
HENT HI HND
LANG
MSG
ONME OPT OSGRV OV
PLST PT
RSLT
SPC STR
TOBJ TSTR TSZE TYP
UFLAG
VAL VL
XDAT XTYPE XVAL
; --=={ Global Variables }==--
; *Mac$Str* ~ Default Text String
; *Mac$tOff* ~ Default Offset Factor
; *Mac$Per* ~ Default Perpendicularity Setting
; *Mac$tObj* ~ Default Object Creation Setting (TEXT/MTEXT)
; *Mac$Mask* ~ Default Background Mask Setting
; *Mac$Mirr* ~ Default Text Mirror Setting
)
(vl-load-com)
(setq dc_fname "LMAC_DTCurve_V2.9.dcl"
dc_title "DTCurve V2.9 Settings")
;; --=={ Error Handler }==--
(defun *error* (msg)
(and tObj
(or
(and pLst
(mapcar
(function
(lambda (x)
(vlax-put tObj (car x) (cdr x)))) pLst))
(and
(not
(vlax-erased-p tObj)) (vla-delete tObj))))
(mapcar (function set) '(tObj pLst) (list 'nil 'nil))
(if (and uflag doc) (vla-EndUndoMark doc))
;(vl-bt)
(if (not (vlr-added-p *DCurve$Align$Reactor*))
(vlr-add *DCurve$Align$Reactor*))
(and ov (mapcar (function setvar) vl ov))
(or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
(princ (strcat "\n** Error: " msg " **")))
(redraw)
(princ))
;;...............................................................................;;
(defun putxdat (Obj App Data / xtype xval)
(setq xtype
(vlax-make-variant
(vlax-safearray-fill
(vlax-make-safearray
vlax-vbInteger '(0 . 1)) '(1001 1000))))
(setq xval
(vlax-make-variant
(vlax-safearray-fill
(vlax-make-safearray
vlax-vbVariant '(0 . 1)) (list App Data))))
(vla-setXData Obj xtype xval))
;;...............................................................................;;
(if (eq 4 (logand 4 (cdr (assoc 70 (tblsearch "LAYER" (getvar "CLAYER"))))))
(progn
(princ "\n<< Current Layer Locked >>") (exit)))
(setq doc (vla-get-ActiveDocument
(vlax-get-Acad-Object))
spc (if (zerop (vla-get-activespace doc))
(if (= (vla-get-mspace doc) :vlax-true)
(vla-get-modelspace doc)
(vla-get-paperspace doc))
(vla-get-modelspace doc))
drft (vla-get-drafting
(vla-get-preferences
(vlax-get-acad-object)))
osGrv (osmode-grvecs-lst
(vla-get-AutoSnapMarkerColor drft)
(vla-get-AutoSnapMarkerSize drft)))
(setq vl '("OSMODE") ov (mapcar (function getvar) vl))
(setq str "")
;;...............................................................................;;
;; LE - disable the reactor here to avoid the call to any notifier
;; must be before the selection of a text
(if (vlr-added-p *DCurve$Align$Reactor*) (vlr-remove *DCurve$Align$Reactor*))
;;...............................................................................;;
;; --=={ Text Entry/Selection }==--
(princ (setq msg (strcat "\nType or Select Text <" *Mac$Str* "> : ")))
(while
(progn
(setq gr (grread 't 15 2) code (car gr) data (cadr gr))
(cond ( (and (= 5 code) (listp data))
(if (and (setq hi (car (nentselp data)))
(vl-position (cdr (assoc 0 (entget hi))) '("MTEXT" "TEXT")))
(redraw (setq hEnt hi) 3)
(if hEnt (setq hEnt (redraw hEnt 4))))
t)
( (and (= 3 code) (listp data))
(cond ( (setq ent (car (nentselp data)))
(if (not (vl-position (cdr (assoc 0 (entget ent))) '("MTEXT" "TEXT")))
(princ (strcat "\n** Object Must be Text/MText **" msg))
(progn
(if hEnt (setq hEnt (redraw hEnt 4)))
(setq rslt ent ent nil))))
(t (princ (strcat "\n** Missed, Try Again... **" msg)))))
( (= 25 code)
(setq rslt str str nil))
( (= 2 code)
(cond ( (<= 32 data 126)
(setq str (strcat str (princ (chr data)))))
( (and (< 0 (strlen str)) (= 8 data))
(setq str (substr str 1 (1- (strlen str))))
(princ (vl-list->string '(8 32 8))))
( (= 13 data)
(setq rslt str str nil))
(t )))
(t ))))
;;...............................................................................;;
;; --=={ Functions to Handle Result of User Input }==--
(vla-StartUndoMark doc)
(setq uFlag t)
(cond ( (eq "" rslt))
( (eq 'STR (type rslt))
(setq *Mac$Str* rslt))
( (eq 'ENAME (type rslt))
(setq *Mac$Str* (vla-get-TextString
(setq tObj (vlax-ename->vla-object rslt)))
tSze (vla-get-Height tObj)
Hnd (vla-get-Handle tObj))
(cond ( (eq "AcDbText" (vla-get-ObjectName tObj))
(setq pLst (list (cons 'Alignment (vlax-get tObj 'Alignment))
(if (eq acAlignmentLeft (vla-get-Alignment tObj))
(cons 'InsertionPoint (vlax-get tObj 'InsertionPoint))
(cons 'TextAlignmentPoint (vlax-get tObj 'TextAlignmentPoint))))))
(t (setq pLst (list (cons 'AttachmentPoint (vlax-get tObj 'AttachmentPoint))
(cons 'InsertionPoint (vlax-get tObj 'InsertionPoint))))))
(foreach obj (vlr-owners *DCurve$Align$Reactor*)
(if (not (vlax-erased-p obj))
(progn
(vla-GetXData obj app 'typ 'val)
(if (and typ val)
(progn
(setq xDat
(cond ( (not (setq xDat
(vlax-variant-value
(cadr
(vlax-safearray->list val)))))
nil)
( (vl-remove-if-not
(function
(lambda (lst)
(entget (handent (car lst)))))
(read xDat)))
(t nil)))
(if (vl-position Hnd (mapcar (function car) xDat))
(progn
(putxDat obj app
(vl-prin1-to-string
(vl-remove-if
(function
(lambda (x) (eq Hnd (car x)))) xDat))))))))
(vlr-owner-remove *DCurve$Align$Reactor* obj)))))
(setq tStr *Mac$Str*)
(or tSze (setq tSze (getvar 'TEXTSIZE)))
;;...............................................................................;;
;; --=={ Curve Selection }==--
(while
(progn
(setq ent (nentsel "\nSelect Curve: "))
(cond ( (vl-consp ent)
(if (vl-catch-all-error-p
(vl-catch-all-apply
(function vlax-curve-getEndParam)
(list (setq cObj (vlax-ename->vla-object (car ent))))))
(princ "\n** Object not Valid **")))
(t (princ "\n** Missed, Try Again... **")))))
;;...............................................................................;;
;; --=={ Text Setup ~ Alignment/Creation }==--
(cond (tObj
(if (eq "AcDbText" (vla-get-ObjectName tObj))
(vla-put-Alignment tObj acAlignmentMiddleCenter)
(vla-put-attachmentpoint tObj acAttachmentPointMiddleCenter)))
(t
(if (eq "TEXT" (strcase *Mac$tObj*))
(vla-put-Alignment
(setq tObj (vla-addText spc tStr (vlax-3D-point '(0 0 0)) tSze)) acAlignmentMiddleCenter)
(vla-put-AttachmentPoint
(setq tObj (vla-addMText spc (vlax-3D-point '(0 0 0)) 0 tStr)) acAttachmentPointMiddleCenter))))
(setq oNme (vla-get-ObjectName tObj))
(and *Mac$Mask* (eq "AcDbMText" oNme)
(vla-put-BackgroundFill tObj :vlax-true))
;; Program doesn't work too well with NODE/INSERTION Snap enabled
(setvar "OSMODE" (boole 2 (getvar "OSMODE") 72))
;;...............................................................................;;
(princ (setq msg (strcat "\n[+] or [-] for [O]ffset, [P]erpendicularity Toggle"
"\n[M]irror Text, [S]tyle Settings"
(if (eq "AcDbText" oNme) "" ", [B]ackground Mask"))))
(while
(progn
(setq gr (grread t 15 0) code (car gr) data (cadr gr))
(redraw)
(cond ( (and (= 5 code) (listp data))
(setq data (trans data 1 0))
(setq pt (vlax-curve-getClosestPointto cObj data))
(if (and (< 0 (getvar "OSMODE") 16384)
(setq oPt (vl-remove-if (function null)
(mapcar
(function
(lambda (x / o)
(if (setq o (osnap data x))
(list (distance data o) o x data)))) (get_osmode)))))
(setq oPt (cdar (vl-sort oPt (function (lambda (a b) (< (car a) (car b)))))))
(setq oPt nil))
(and oPt (OsMark oPt))
(setq cAng (angle pt data) lAng (+ cAng *Mac$Per*))
(if (equal lAng (/ pi 2.) 0.001)
(setq lAng (/ pi 2.)))
(if (equal lAng (/ (* 3 pi) 2.) 0.001)
(setq lAng (/ (* 3 pi) 2.)))
(cond ( (and (> lAng (/ pi 2)) (<= lAng pi))
(setq lAng (- lAng pi)))
( (and (> lAng pi) (<= lAng (/ (* 3 pi) 2)))
(setq lAng (+ lAng pi))))
( (if (eq "AcDbText" oNme)
vla-put-TextAlignmentPoint
vla-put-InsertionPoint)
tObj (vlax-3D-point (polar pt cAng (* tSze *Mac$tOff*))))
(vla-put-Rotation tObj (+ *Mac$Mirr* lAng))
t)
( (= 2 code)
(cond ( (vl-position data '(43 61))
(setq *Mac$tOff* (+ 0.1 *Mac$tOff*)))
( (= data 45)
(setq *Mac$tOff* (- *Mac$tOff* 0.1)))
( (vl-position data '(77 109))
(setq *Mac$Mirr* (- pi *Mac$Mirr*)))
( (vl-position data '(83 115))
(TextSettings tObj)
(setq tSze (vla-get-Height tObj))
(princ "\n ~¤~ ~¤~ ~¤~ ~¤~ ~¤~ ~¤~ ~¤~ ~¤~ ~¤~ ~¤~ ~¤~ ~¤~ ~¤~")
(princ msg))
( (vl-position data '(79 111))
(if (setq dis (getdist
(strcat "\nSpecify Offset Distance <"
(rtos (* tSze *Mac$tOff*) 2 3) "> : ")))
(setq *Mac$tOff* (/ dis (float tSze))))
(princ msg))
( (vl-position data '(80 112))
(setq *Mac$Per* (- (/ pi 2.) *Mac$Per*)))
( (vl-position data '(66 98))
(if (eq oNme "AcDbMText")
(vla-put-backgroundfill tObj
(if (eq :vlax-true (vla-get-BackGroundFill tObj)) :vlax-false :vlax-true)))
t)
( (= 6 data) ; F3
(cond ( (< 0 (getvar "OSMODE") 16384)
(setvar "OSMODE" (+ 16384 (getvar "OSMODE")))
(princ "\n<Osnap off>"))
(t (setvar "OSMODE" (- (getvar "OSMODE") 16384))
(princ "\n<Osnap on>")))
(princ msg))
( (vl-position data '(13 32))
(SubData)
nil)
(t )))
( (and (= 3 code) (listp data))
(setq data (trans data 1 0))
(SubData)
(if (and (< 0 (getvar "OSMODE") 16384)
(setq oPt (vl-remove-if (function null)
(mapcar
(function
(lambda (x / o)
(if (setq o (osnap data x))
(list (distance data o) o x data)))) (get_osmode)))))
(setq oPt (cdar (vl-sort oPt (function (lambda (a b) (< (car a) (car b))))))
pt (osnap (caddr oPt) (cadr oPt))
derv (angle '(0 0 0) (vlax-curve-getFirstDeriv cObj
(vlax-curve-getParamatPoint cObj
(vlax-curve-getClosestPointto cObj pt))))
derv (- (+ derv (if (< (distance (polar pt derv 1) data)
(distance (polar pt (+ pi derv) 1) data)) 0 pi)) (/ pi 2.))))
(setq pt (vlax-curve-getClosestPointto cObj data) cAng (if derv derv (angle pt data)) lAng (+ cAng *Mac$Per*))
(if (equal lAng (/ pi 2.) 0.001)
(setq lAng (/ pi 2.)))
(if (equal lAng (/ (* 3 pi) 2.) 0.001)
(setq lAng (/ (* 3 pi) 2.)))
(cond ( (and (> lAng (/ pi 2)) (<= lAng pi))
(setq lAng (- lAng pi)))
( (and (> lAng pi) (<= lAng (/ (* 3 pi) 2)))
(setq lAng (+ lAng pi))))
( (if (eq "AcDbText" oNme)
vla-put-TextAlignmentPoint
vla-put-InsertionPoint)
tObj (vlax-3D-point (polar pt cAng (* tSze *Mac$tOff*))))
(vla-put-Rotation tObj (+ *Mac$Mirr* lAng))
nil)
( (= 25 code) nil)
(t ))))
;;...............................................................................;;
(vla-EndUndoMark doc)
(redraw)
;; LE - make the reactor active here - we are safe to allow the chance
;; to update the possible text around the notifiers (lines) when they are modified
(if (not (vlr-added-p *DCurve$Align$Reactor*)) (vlr-add *DCurve$Align$Reactor*))
(mapcar (function setvar) vl ov)
(princ))
(defun SubData (/ p# t#)
(vla-GetXData cObj app 'typ 'val)
(setq hand (list (vla-get-Handle tObj)
(vla-get-Handle cObj) *Mac$tOff* *Mac$Per* *Mac$Mirr*
(vlax-curve-getParamatPoint cObj
(setq p#
(vlax-curve-getClosestPointto cObj
(setq t#
(vlax-safearray->list
(vlax-variant-value
( (if (eq "AcDbText" (vla-get-ObjectName tObj))
vla-get-TextAlignmentPoint
vla-get-InsertionPoint)
tObj)))))))
(- (angle p# t#)
(angle '(0 0 0)
(vlax-curve-getFirstDeriv cObj
(vlax-curve-getParamatPoint cObj p#))))))
(if (and typ val)
(progn
;;; (setq xdat (apply (function mapcar)
;;; (cons (function cons)
;;; (list (vlax-safearray->list typ)
;;; (mapcar (function vlax-variant-value)
;;; (vlax-safearray->list val)))))
;;;
;;; xdat (read (cdr (assoc 1000 xdat))))
(setq xDat (vl-remove-if-not
(function
(lambda (lst)
(entget (handent (car lst)))))
(read
(vlax-variant-value
(cadr
(vlax-safearray->list val))))))
(if (not (vl-position (car hand) (mapcar (function car) xdat)))
(setq xdat (append xdat (list hand)))))
(setq xdat (list hand)))
(putxdat cObj app (vl-prin1-to-string xdat))
(or (vl-position cObj (vlr-owners *DCurve$Align$Reactor*))
(vlr-owner-add *DCurve$Align$Reactor* cObj)))
;;...............................................................................;;
;;;¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,;;;
;; --=={ Reactor Callback }==-- ;;
;;;¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,;;;
(defun DTCurveUpd (Obj Reac Args / *error*
typ val ObjxDat tObj dist perp
mirr para a#dif pt deriv cAng lAng)
(defun *error* (msg)
(or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
(princ (strcat "\n** Error: " msg " **")))
(princ))
(cond ( (and *Reactor$Command$Call*
(or (wcmatch *Reactor$Command$Call* "*UNDO")
(eq "U" *Reactor$Command$Call*))))
(t (if (vlax-erased-p obj)
(vlr-owner-remove Reac Obj)
(progn
(or doc (setq doc (vla-get-ActiveDocument
(vlax-get-acad-object))))
(vla-getXdata obj app 'typ 'val)
;;; (setq ObjxDat (vl-remove-if-not
;;; (function
;;; (lambda (lst)
;;; (entget (handent (car lst)))))
;;;
;;; (read
;;; (vlax-variant-value
;;; (cadr
;;; (vlax-safearray->list val))))))
(setq ObjxDat
(cond ( (not (setq ObjxDat
(vlax-variant-value
(cadr
(vlax-safearray->list val)))))
nil)
( (vl-remove-if-not
(function
(lambda (lst)
(entget (handent (car lst)))))
(read ObjxDat)))
(t nil)))
(foreach lst ObjxDat
(setq tObj (vlax-ename->vla-object (handent (car lst))))
(mapcar (function set) '(dist perp mirr para a#dif) (cddr lst))
(if (eq "AcDbText" (vla-get-ObjectName tObj))
(vla-put-Alignment tObj acAlignmentMiddleCenter)
(vla-put-AttachmentPoint tobj acAttachmentPointMiddleCenter))
(setq pt
(cond ( (vlax-curve-getPointatParam Obj para))
( (vlax-curve-getClosestPointto Obj
(vlax-get tObj
(if (eq "AcDbText" (vla-get-ObjectName tObj))
'TextAlignmentPoint
'InsertionPoint))))))
(setq para (vlax-curve-getParamatPoint Obj pt)
deriv (+ (angle '(0 0 0)
(vlax-curve-getFirstDeriv Obj para)) a#dif))
;;; (setq deriv (+ deriv (if (< (distance tpt (polar pt deriv 1))
;;; (distance tpt (polar pt (+ deriv pi) 1))) 0 pi)))
(setq cAng deriv lAng (rem (+ perp cAng) (* 2. pi)))
(if (equal lAng (/ pi 2.) 0.001)
(setq lAng (/ pi 2.)))
(if (equal lAng (/ (* 3 pi) 2.) 0.001)
(setq lAng (/ (* 3 pi) 2.)))
(and (minusp lAng) (setq lAng (+ lAng (* 2 pi))))
(cond ( (and (> lAng (/ pi 2)) (<= lAng pi))
(setq lAng (- lAng pi)))
( (and (> lAng pi) (<= lAng (/ (* 3 pi) 2)))
(setq lAng (+ lAng pi))))
( (if (eq "AcDbText" (vla-get-ObjectName tObj))
vla-put-TextAlignmentPoint
vla-put-InsertionPoint)
tObj (vlax-3D-point (polar pt cAng (* (vla-get-Height tObj) dist))))
(vla-put-Rotation tObj (+ mirr lAng)))))))
(princ))
;;...............................................................................;;
(defun DTCurveComm (Reac Args)
(setq *Reactor$Command$Call* (strcase (car Args)))
(princ))
;;...............................................................................;;
(defun icon_GrList (col sze / -sze)
(setq sze (1+ sze) -sze (- sze))
(list col (list 0. (1- -sze)) (list 0. sze)
col (list 1. (1- -sze)) (list 1. sze)
col (list -sze sze) (list sze sze)
col (list (1- -sze) (1+ sze)) (list (1+ sze) (1+ sze))))
(defun osMark (o / s)
(setq s (/ (getvar "VIEWSIZE") (cadr (getvar "SCREENSIZE")))
o (cons (trans (car o) 1 3) (cdr o)))
(grvecs (cdr (assoc (cadr o) osGrv))
(list (list s 0. 0. (caar o))
(list 0. s 0. (cadar o))
(list 0. 0. s 0.)
(list 0. 0. 0. 1.))))
;;...............................................................................;;
(defun get_osmode nil ; by Evgeniy Elpanov
(mapcar
(function cdr)
(vl-remove-if
(function (lambda (x) (zerop (logand (getvar "OSMODE") (car x)))))
'((1 . "_end")
(2 . "_mid")
(4 . "_cen")
(8 . "_nod")
(16 . "_qua")
(32 . "_int")
(64 . "_ins")
(128 . "_per")
(256 . "_tan")
(512 . "_nea")
(2048 . "_app")))))
;;...............................................................................;;
(defun osmode-grvecs-lst (col ass / -ASS ASS COL)
; By Evgeniy Elpanov (Modified by Lee McDonnell)
(setq -ass (- ass))
(list (list "_end"
col (list -ass -ass) (list -ass ass)
col (list (1- -ass) (1- -ass)) (list (1- -ass) (1+ ass))
col (list -ass ass) (list ass ass)
col (list (1- -ass) (1+ ass)) (list (1+ ass) (1+ ass))
col (list ass ass) (list ass -ass)
col (list (1+ ass) (1+ ass)) (list (1+ ass) (1- -ass))
col (list ass -ass) (list -ass -ass)
col (list (1+ ass) (1- -ass)) (list (1- -ass) (1- -ass)))
(list "_mid"
col (list -ass -ass) (list 0. ass)
col (list (1- -ass) (1- -ass)) (list 0. (1+ ass))
col (list 0. ass) (list ass -ass)
col (list 0. (1+ ass)) (list (1+ ass) (1- -ass))
col (list ass -ass) (list -ass -ass)
col (list (1+ ass) (1- -ass)) (list (1- -ass) (1- -ass)))
(list "_cen"
7 (list (* -ass 0.2) 0.) (list (* ass 0.2) 0.)
7 (list 0. (* -ass 0.2)) (list 0. (* ass 0.2))
col (list -ass 0.) (list (* -ass 0.86) (* ass 0.5))
col (list (* -ass 0.86) (* ass 0.5)) (list (* -ass 0.5) (* ass 0.86))
col (list (* -ass 0.5) (* ass 0.86)) (list 0. ass)
col (list 0. ass) (list (* ass 0.5) (* ass 0.86))
col (list (* ass 0.5) (* ass 0.86)) (list (* ass 0.86) (* ass 0.5))
col (list (* ass 0.86) (* ass 0.5)) (list ass 0.)
col (list ass 0.) (list (* ass 0.86) (* -ass 0.5))
col (list (* ass 0.86) (* -ass 0.5)) (list (* ass 0.5) (* -ass 0.86))
col (list (* ass 0.5) (* -ass 0.86)) (list 0. -ass)
col (list 0. -ass)(list (* -ass 0.5) (* -ass 0.86))
col (list (* -ass 0.5) (* -ass 0.86)) (list (* -ass 0.86) (* -ass 0.5))
col (list (* -ass 0.86) (* -ass 0.5)) (list -ass 0.))
(list "_nod"
col (list -ass -ass) (list ass ass)
col (list -ass ass) (list ass -ass)
col (list -ass 0.) (list (* -ass 0.86) (* ass 0.5))
col (list (* -ass 0.86) (* ass 0.5)) (list (* -ass 0.5) (* ass 0.86))
col (list (* -ass 0.5) (* ass 0.86)) (list 0. ass)
col (list 0. ass) (list (* ass 0.5) (* ass 0.86))
col (list (* ass 0.5) (* ass 0.86)) (list (* ass 0.86) (* ass 0.5))
col (list (* ass 0.86) (* ass 0.5)) (list ass 0.)
col (list ass 0.) (list (* ass 0.86) (* -ass 0.5))
col (list (* ass 0.86) (* -ass 0.5)) (list (* ass 0.5) (* -ass 0.86))
col (list (* ass 0.5) (* -ass 0.86)) (list 0. -ass)
col (list 0. -ass)(list (* -ass 0.5) (* -ass 0.86))
col (list (* -ass 0.5) (* -ass 0.86)) (list (* -ass 0.86) (* -ass 0.5))
col (list (* -ass 0.86) (* -ass 0.5)) (list -ass 0.))
(list "_qua"
col (list 0. -ass) (list -ass 0.)
col (list 0. (1- -ass)) (list (1- -ass) 0.)
col (list -ass 0.) (list 0. ass)
col (list (1- -ass) 0.) (list 0. (1+ ass))
col (list 0. ass) (list ass 0.)
col (list 0. (1+ ass)) (list (1+ ass) 0.)
col (list ass 0.) (list 0. -ass)
col (list (1+ ass) 0.) (list 0. (1- -ass)))
(list "_int"
col (list -ass -ass) (list ass ass)
col (list -ass (1+ -ass)) (list ass (1+ ass))
col (list (1+ -ass) -ass) (list (1+ ass) ass)
col (list -ass ass) (list ass -ass)
col (list -ass (1+ ass)) (list ass (1+ -ass))
col (list (1+ -ass) ass) (list (1+ ass) -ass))
(list "_ins"
col (list (* -ass 0.1) (* -ass 0.1)) (list -ass (* -ass 0.1))
col (list -ass (* -ass 0.1)) (list -ass ass)
col (list -ass ass) (list (* ass 0.1) ass)
col (list (* ass 0.1) ass) (list (* ass 0.1) (* ass 0.1))
col (list (* ass 0.1) (* ass 0.1)) (list ass (* ass 0.1))
col (list ass (* ass 0.1)) (list ass -ass)
col (list ass -ass) (list (* -ass 0.1) -ass)
col (list (* -ass 0.1) -ass) (list (* -ass 0.1) (* -ass 0.1))
col (list (1- (* -ass 0.1)) (1- (* -ass 0.1))) (list (1- -ass) (1- (* -ass 0.1)))
col (list (1- -ass) (1- (* -ass 0.1))) (list (1- -ass) (1+ ass))
col (list (1- -ass) (1+ ass)) (list (1+ (* ass 0.1)) (1+ ass))
col (list (1+ (* ass 0.1)) (1+ ass)) (list (1+ (* ass 0.1)) (1+ (* ass 0.1)))
col (list (1+ (* ass 0.1)) (1+ (* ass 0.1))) (list (1+ ass) (1+ (* ass 0.1)))
col (list (1+ ass) (1+ (* ass 0.1))) (list (1+ ass) (1- -ass))
col (list (1+ ass) (1- -ass)) (list (1- (* -ass 0.1)) (1- -ass))
col (list (1- (* -ass 0.1)) (1- -ass)) (list (1- (* -ass 0.1)) (1- (* -ass 0.1))))
(list "_tan"
col (list -ass ass) (list ass ass)
col (list (1- -ass) (1+ ass)) (list (1+ ass) (1+ ass))
col (list -ass 0.) (list (* -ass 0.86) (* ass 0.5))
col (list (* -ass 0.86) (* ass 0.5)) (list (* -ass 0.5) (* ass 0.86))
col (list (* -ass 0.5) (* ass 0.86)) (list 0. ass)
col (list 0. ass) (list (* ass 0.5) (* ass 0.86))
col (list (* ass 0.5) (* ass 0.86)) (list (* ass 0.86) (* ass 0.5))
col (list (* ass 0.86) (* ass 0.5)) (list ass 0.)
col (list ass 0.) (list (* ass 0.86) (* -ass 0.5))
col (list (* ass 0.86) (* -ass 0.5)) (list (* ass 0.5) (* -ass 0.86))
col (list (* ass 0.5) (* -ass 0.86)) (list 0. -ass)
col (list 0. -ass)(list (* -ass 0.5) (* -ass 0.86))
col (list (* -ass 0.5)(* -ass 0.86)) (list (* -ass 0.86) (* -ass 0.5))
col (list (* -ass 0.86)(* -ass 0.5)) (list -ass 0.))
(list "_per"
col (list -ass -ass) (list -ass ass)
col (list (1- -ass) (1- -ass)) (list (1- -ass) (1+ ass))
col (list ass -ass) (list -ass -ass)
col (list (1+ ass) (1- -ass)) (list (1- -ass) (1- -ass))
col (list -ass 0.) (list 0. 0.)
col (list -ass -1.) (list 0. -1.)
col (list 0. 0.) (list 0. -ass)
col (list -1. 0.) (list -1. -ass))
(list "_nea"
col (list -ass -ass) (list ass ass)
col (list -ass ass) (list ass ass)
col (list (1- -ass) (1+ ass)) (list (1+ ass) (1+ ass))
col (list -ass ass) (list ass -ass)
col (list ass -ass) (list -ass -ass)
col (list (1+ ass) (1- -ass)) (list (1- -ass) (1- -ass)))
(list "_app"
col (list -ass -ass) (list ass ass)
col (list ass -ass) (list -ass ass)
col (list -ass -ass) (list -ass ass)