Debian Codegraph @

texmf-dist/doc/latex/circuit-macros/examples/Plate.m4

raw
1 .PS
2 # Plate.m4
3 # ASME_Y14-5.m4
4 # https://en.wikipedia.org/wiki/Geometric_dimensioning_and_tolerancing
5 # See the ASME Y14.5 standard, Figure 6-30.
6 scale = 100/3
7 cct_init
8 ifdef(`ASME_Y14-5_',,
9 `sinclude(ASME_Y14-5.m4def)
10 sinclude(../ASME_Y14-5.m4def) ')
11 ifsvg(`svg_font(sans-serif,10bp__)',
12 `textht = 10bp__*2/3
13 ifpostscript(,latexcommand({\sf\small))')
14 # ASME Y14.5 specs:
15 arrowht = textht*0.8
16 arrowwid = textht*0.6
17 maxpswid = 12
18
19 # Diameters
20 d1 = (20.13+20.00)/2
21 d2 = 31.7
22 d3 = 36
23 d4 = (40.60+40.45)/2
24 d5 = 57
25 d6 = 86
26 d7 = 100
27 d8 = 8.0
28 adj = 1.5
29
30 Section: [
31 Orig: (0,0)
32 T0: (0,-d7/2)
33 T1: (6,-d5/2)
34 T2: (15.5,-d3/2)
35 T3: (22,-d3/2-adj)
36 T4: (32,-d2/2)
37 T5: (41.3,0)
38 T6: (9.5,-d4/2)
39 # for_(0,5,1,`"m4x" at T`'m4x')
40 # Hatching
41 H: hatchbox(invis ht d7 wid 41.3,2,thick 0.4,-45) with .w at Orig
42 box invis fill_(1) wid T5.x-T1.x ht T1.y-H.s.y with .se at H.se
43 box same with .ne at H.ne
44 box invis fill_(1) wid T3.x-T2.x ht T2.y-T1.y with .nw at T2
45 box same with .sw at (T2.x,-T2.y)
46 box invis fill_(1) wid T4.x-T3.x ht T3.y-T1.y with .nw at T3
47 box same with .sw at (T3.x,-T3.y)
48 box invis fill_(1) wid T5.x-T4.x ht T4.y-T1.y with .nw at T4
49 box same with .sw at (T4.x,-T4.y)
50 # Section outline lower
51 line from (0,-d4/2) to T0 then right T1.x-T0.x then up 1
52 arcto(T1,(T2,T1),1)
53 line to (T2,T1) then up 1
54 arcto(T2,(T3,T2),1)
55 arcto((T3,T2),T3,0.5)
56 arcto(T3,(T4,T3),0.5)
57 arcto((T4,T3),T4,1)
58 arcto(T4,(T5,T4),1)
59 line to (T5,T4) then to (T5.x,-T4.y) then left 1
60 # Section outline upper
61 line from (0,d4/2) to (0,-T0.y) then right T1.x-T0.x then down 1
62 arcto((T1.x,-T1.y),(T2.x,-T1.y),1)
63 line to (T2.x,-T1.y) then down 1
64 arcto((T2.x,-T2.y),(T3.x,-T2.y),1)
65 arcto((T3.x,-T2.y),(T3.x,-T3.y),0.5)
66 arcto((T3.x,-T3.y),(T4.x,-T3.y),0.5)
67 arcto((T4.x,-T3.y),(T4.x,-T4.y),1)
68 arcto((T4.x,-T4.y),(T5.x,-T4.y),1)
69 line to (T5.x,-T4.y)
70
71 box wid 6 ht d8 fill_(1) with .w at (0,d6/2)
72 box wid 6 ht d8 fill_(1) with .w at (0,-d6/2)
73 box invis wid T6.x ht d4 fill_(1) with .w at Orig
74 box wid T5.x-T6.x ht d1 fill_(1) with .e at T5
75
76 line from (Orig.x,-T6.y) to (Orig.x,T6.y)
77 arcto(T6,(T6,Orig),1)
78 arcto((T6.x,-T6.y),(0,-T6.y),1)
79 line to (0,-T6.y)
80
81 define(`dialabel',
82 `[tmpthick = linethick; linethick_(1)
83 [Y14_dia_]; [$1 wid ifelse(`$2',,textht,`$2')] with .w at last [].e+(0.5,0)
84 linethick_(tmpthick)]')
85
86 thinlines_
87 dimension_(from (0,T6.y) to (0,-T6.y),40,dialabel("40.60" "40.45",12),textht*3)
88 line up 4 from AE_dimen_.end
89 Y14_frame(Y14_per_,Y14_dia_;"0";"(M)","A") with .sw at Here
90 Y14_frame("B") with .s at last [].n+(0,6)
91 thicklines_(1)
92 datumarrow(from last [].s to 2nd last [].n)
93 thinlines_
94 dimension_(from T2 to (T2.x,-T2.y),30,
95 dialabel("35.5" "36.0",12),textht*3)
96 dimension_(from T0 to T0+(T1.x,0),-8,"6.1" "5.9",textht*3)
97 dimension_(from S_dimen_.end to S_dimen_.end+(T2.x,0),-9,
98 "15.4" "15.6",textht*4)
99 line from E_dimen_.start to (T2,T1) chop 0 chop 1
100 dimension_(from S_dimen_.end to S_dimen_.end+(T3.x,0),-9,
101 "21.9" "22.1",textht*4)
102 line from E_dimen_.start to T3 chop 0 chop 1
103 dimension_(from S_dimen_.end to S_dimen_.end+(T4.x,0),-9,
104 "31.9" "32.1",textht*4)
105 line from E_dimen_.start to (T4,T3) chop 0 chop 1
106 dimension_(from S_dimen_.end to S_dimen_.end+(T5.x,0),-9,
107 "41.2" "41.4",textht*4)
108 line from E_dimen_.start to (T5,T4) chop 0 chop 1
109 line from S_dimen_.start to T0 chop 0 chop 1
110 dimension_(from (0,d7/2) right T6.x,8,"9.6" "9.4",3*textht)
111 line from E_dimen_.start to (T6.x,d4/2) chop 0 chop 1
112 ctrline(from (-3,0) to T5+(3,0),T5.x/2)
113 ctrline(from (-3,d6/2) right T1.x+6)
114 ctrline(from (-3,-d6/2) right T1.x+6)
115 dimension_(from T5-(0,d1/2) to T5+(0,d1/2),-14,
116 dialabel("20.13" "20.00",4*textht),textht*3)
117 dimension_(from T5-(0,d2/2) to T5+(0,d2/2),-35,
118 dialabel("31.8" "31.6",3*textht),textht*3)
119 arrow <- from (T5.x+6,d1/2) by (Rect_(20,75)) then right 6
120 Y14_frame(Y14_cir_,"0.06" wid 3*textht,"A","B") with .w at Here
121 Y14_frame("C") with .n at last [].se+(-6,-8)
122 thicklines_(1)
123 datumarrow(from last [].n up 8)
124 thinlines_
125 arrow <- from (T5.x+6,-d2/2) by (Rect_(10,-75)) then right 4
126 Y14_frame(Y14_cir_,"0.1" wid textht*2,"C") with .w at Here
127 arrow <- from ((T3.x+T4.x)/2,d3/2+adj) by (Rect_(30,75)) then right 4
128 "M42 X 1.5 - 6g" wid 9*textht ljust
129 Y14_frame(Y14_pos_,Y14_dia_;"0.1" wid textht*2;"(M)","C";"(M)") \
130 with .nw at last "".sw+(0,-2)
131 line from (T2.x,-T1.y) up 25 chop 1 chop 0
132 Y14_frame(Y14_par_,"0.06" wid 3*textht,"A") with .sw at Here
133 Y14_frame(Y14_sur_," 0.1 " wid 3*textht,"A") with .sw at last [].nw
134 arrow <- from (0,-d6/2+10) left 13
135 Y14_frame(Y14_fla_,"0.02" wid 4*textht) with .e at Here
136 Y14_frame("A") with .n at last [].s+(0,-6)
137 datumarrow(from last [].n up 6)
138 ]
139
140 Topview:[
141 C: circle diam d7
142 for i=0 to 7 do { circle diam d8 at C+(Rect_(d6/2,i/8*360)) }
143 C5: circle diam d5 at C
144 C4: circle diam d3+2*adj at C
145 C3: circle dashed diam d3 at C
146 C2: circle diam d2 at C
147 C1: circle diam d1 at C
148
149 thinlines_
150 dimension_(from C.w-(0,10) to C.e-(0,10),-C.rad-15,
151 dialabel("100" "99",textht*3),textht*5)
152 dimension_(from C5.w-(0,5) to C5.e-(0,5),-C.rad-5,
153 dialabel("57.2" "56.8",textht*4),textht*5)
154 arrow <-> from C+(Rect_(d6/2,-120)) to C+(Rect_(d6/2,60))
155 line from last arrow.end to C+(Rect_(d7/2+6,60)) then right 4
156 dialabel("86.2" "85.8",textht*4) with .w at Here+(1,0)
157 ctrline(from (C.x-(d6-d7/2),C.y) to (C.x+(d6-d7/2),C.y))
158 ctrline(from (C.x,C.y-d6/2+d8/2) to (C.x,C.y+d6/2-d8/2))
159 for_(0,315,45,`ctrarcr(C,d6/2,(m4x-22.5)*dtor_,(m4x+22.5)*dtor_)
160 ctrline(from C+(Rect_(d6-d7/2,m4x)) to C+(Rect_(d7/2,m4x))) ')
161 arcdimension_(from C+(0,d7/2) to C+(Rect_(d7/2,135)) with .c at C,
162 8,"8 X 45`'iflatex($^\circ$)" wid textht*3.5,15,1)
163 ifsvg("svg_deg" wid textht*2/3 with .w at last "".e)
164 move to C+(0,d6/2)
165 arrow <- from Here+(Rect_(8/2,75)) to Here+(Rect_(25,75)) then right_ 3
166 "8 X" wid 3*textht ljust
167 linethick_(1); [Y14_dia_] with .w at last "".e+(1,0)
168 "7.9 - 8.1" wid 8*textht ljust
169 Y14_frame(Y14_pos_,Y14_dia_;"0.14" wid 3*textht;"(M)","A","C") \
170 with .nw at 2nd last "".sw+(0,-2)
171
172 ] with .C at Section.Orig+(4.5*scale,0)
173
174
175 ifpostscript(,latexcommand(}%))
176 ifsvg(command "</g>")
177 .PE