質問編集履歴
4
import編集
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
+
```ここに言語を入力
|
2
|
+
|
3
|
+
コード
|
4
|
+
|
1
|
-
### 前提・実現したいこと
|
5
|
+
```### 前提・実現したいこと
|
2
6
|
|
3
7
|
|
4
8
|
|
@@ -62,6 +66,8 @@
|
|
62
66
|
|
63
67
|
------------------------------------
|
64
68
|
|
69
|
+
```python
|
70
|
+
|
65
71
|
import sys
|
66
72
|
|
67
73
|
from logging import getLogger
|
@@ -76,6 +82,10 @@
|
|
76
82
|
|
77
83
|
import traceback
|
78
84
|
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
79
89
|
def concat(dxf_list) -> list:
|
80
90
|
|
81
91
|
return_dxf = list()
|
@@ -288,4 +298,6 @@
|
|
288
298
|
|
289
299
|
" add_arc(center=(XC, YC), radius=R, start=K1, end=K1 + KK, color=CO, line_type=LDOT)\n"
|
290
300
|
|
301
|
+
```
|
302
|
+
|
291
303
|
------------------------------
|
3
import追加2
test
CHANGED
File without changes
|
test
CHANGED
@@ -76,6 +76,216 @@
|
|
76
76
|
|
77
77
|
import traceback
|
78
78
|
|
79
|
-
|
79
|
+
def concat(dxf_list) -> list:
|
80
|
+
|
81
|
+
return_dxf = list()
|
82
|
+
|
83
|
+
dxf_body = list()
|
84
|
+
|
85
|
+
dxf_header = list()
|
86
|
+
|
87
|
+
dxf_footer = list()
|
88
|
+
|
89
|
+
for dxf in dxf_list:
|
90
|
+
|
91
|
+
for i in range(len(dxf)):
|
92
|
+
|
93
|
+
if dxf[i] == (2, "ENTITIES"):
|
94
|
+
|
95
|
+
dxf_header_end = i
|
96
|
+
|
97
|
+
elif dxf[i] == (0, "ENDSEC"):
|
98
|
+
|
99
|
+
dxf_footer_start = i
|
100
|
+
|
101
|
+
dxf_body.extend(dxf[dxf_header_end + 1:dxf_footer_start])
|
102
|
+
|
103
|
+
if len(dxf_header) == 0 or len(dxf_footer) == 0:
|
104
|
+
|
105
|
+
dxf_header = dxf[:dxf_header_end + 1]
|
106
|
+
|
107
|
+
dxf_footer = dxf[dxf_footer_start:]
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
return_dxf.extend(dxf_header)
|
112
|
+
|
113
|
+
return_dxf.extend(dxf_body)
|
114
|
+
|
115
|
+
return_dxf.extend(dxf_footer)
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
return return_dxf
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
def duplicate(dxf: list, x_move=0.0, y_move=0.0, rot_angle=0.0, mirror=False) -> list:
|
126
|
+
|
127
|
+
result_dxf = list()
|
128
|
+
|
129
|
+
theta = np.pi * rot_angle / 180
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
reverse = -1 if mirror else 1
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
cache = list()
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
for d in dxf:
|
142
|
+
|
143
|
+
if d[0] == 0:
|
144
|
+
|
145
|
+
for x_ix in range(len(cache)):
|
146
|
+
|
147
|
+
if cache[x_ix][0] // 10 == 1: # x座標なら
|
148
|
+
|
149
|
+
for y_ix in range(len(cache)): # y座標なら
|
150
|
+
|
151
|
+
if cache[y_ix][0] // 10 == 2 and cache[x_ix][0] % 10 == cache[y_ix][0] % 10:
|
152
|
+
|
153
|
+
break
|
154
|
+
|
155
|
+
x_dash = np.cos(theta) * cache[x_ix][1] * reverse - np.sin(theta) * cache[y_ix][1] + x_move
|
156
|
+
|
157
|
+
y_dash = np.sin(theta) * cache[x_ix][1] * reverse + np.cos(theta) * cache[y_ix][1] + y_move
|
158
|
+
|
159
|
+
cache[x_ix] = (cache[x_ix][0], x_dash)
|
160
|
+
|
161
|
+
cache[y_ix] = (cache[y_ix][0], y_dash)
|
162
|
+
|
163
|
+
elif cache[x_ix][0] // 10 == 5: # 角度なら
|
164
|
+
|
165
|
+
if cache[x_ix][0] % 10 == 0: # startなら
|
166
|
+
|
167
|
+
for y_ix in range(len(cache)): # endなら
|
168
|
+
|
169
|
+
if cache[y_ix][0] // 10 == 5 and cache[x_ix][0] % 10 == 1:
|
170
|
+
|
171
|
+
break
|
172
|
+
|
173
|
+
if not mirror:
|
174
|
+
|
175
|
+
start_dash = cache[x_ix][1] + rot_angle
|
176
|
+
|
177
|
+
end_dash = cache[y_ix][1] + rot_angle
|
178
|
+
|
179
|
+
else:
|
180
|
+
|
181
|
+
start_dash = 180 - cache[y_ix][1] + rot_angle
|
182
|
+
|
183
|
+
end_dash = 180 - cache[x_ix][1] + rot_angle
|
184
|
+
|
185
|
+
cache[x_ix] = (cache[x_ix][0], start_dash)
|
186
|
+
|
187
|
+
cache[y_ix] = (cache[y_ix][0], end_dash)
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
cache.append(d)
|
192
|
+
|
193
|
+
result_dxf.extend(cache)
|
194
|
+
|
195
|
+
cache = list()
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
else:
|
200
|
+
|
201
|
+
cache.append(d)
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
result_dxf.extend(cache)
|
206
|
+
|
207
|
+
return result_dxf
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
# x_dash = np.cos(theta) * x - np.sin(theta) * y + x_move
|
212
|
+
|
213
|
+
# y_dash = np.sin(theta) * x + np.cor(theta) * y + + y_move
|
214
|
+
|
215
|
+
# angle_dash = angle + rot_angle
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
def loader(dxf_maker_function: str, dimensional_line_maker_function: str, thickness: str, values: dict, created_data):
|
222
|
+
|
223
|
+
func_head = "from math import *\n" \
|
224
|
+
|
225
|
+
"dxf = list()\n" \
|
226
|
+
|
227
|
+
"def add_raw(group: int, value):\n" \
|
228
|
+
|
229
|
+
" dxf.append((group, value))\n" \
|
230
|
+
|
231
|
+
"def add_line(start: tuple, end: tuple, color, line_type):\n" \
|
232
|
+
|
233
|
+
" dxf.append((0, \"LINE\"))\n" \
|
234
|
+
|
235
|
+
" dxf.append((8, 0))\n" \
|
236
|
+
|
237
|
+
" dxf.append((6, line_type))\n" \
|
238
|
+
|
239
|
+
" dxf.append((62, color))\n" \
|
240
|
+
|
241
|
+
" dxf.append((10, start[0]))\n" \
|
242
|
+
|
243
|
+
" dxf.append((20, start[1]))\n" \
|
244
|
+
|
245
|
+
" dxf.append((11, end[0]))\n" \
|
246
|
+
|
247
|
+
" dxf.append((21, end[1]))\n" \
|
248
|
+
|
249
|
+
"def add_arc(center: tuple, radius: tuple, start, end, color, line_type):\n" \
|
250
|
+
|
251
|
+
" dxf.append((0, \"ARC\"))\n" \
|
252
|
+
|
253
|
+
" dxf.append((8, 0))\n" \
|
254
|
+
|
255
|
+
" dxf.append((6, line_type))\n" \
|
256
|
+
|
257
|
+
" dxf.append((62, color))\n" \
|
258
|
+
|
259
|
+
" dxf.append((10, center[0]))\n" \
|
260
|
+
|
261
|
+
" dxf.append((20, center[1]))\n" \
|
262
|
+
|
263
|
+
" dxf.append((30, 0.0))\n" \
|
264
|
+
|
265
|
+
" dxf.append((40, radius))\n" \
|
266
|
+
|
267
|
+
" dxf.append((50, start))\n" \
|
268
|
+
|
269
|
+
" dxf.append((51, end))\n" \
|
270
|
+
|
271
|
+
"def PW():\n" \
|
272
|
+
|
273
|
+
" global OV, OU, V, U\n" \
|
274
|
+
|
275
|
+
" OV, OU = V, U\n" \
|
276
|
+
|
277
|
+
"def DW():\n" \
|
278
|
+
|
279
|
+
" global OV, OU, V, U, CO, LDOT\n" \
|
280
|
+
|
281
|
+
" add_line(start=(OV, OU), end=(V, U), color=CO, line_type=LDOT)\n" \
|
282
|
+
|
283
|
+
" OV, OU = V, U\n" \
|
284
|
+
|
285
|
+
"def RR():\n" \
|
286
|
+
|
287
|
+
" global XC, YC, R, K1, KK, CO, LDOT\n" \
|
288
|
+
|
289
|
+
" add_arc(center=(XC, YC), radius=R, start=K1, end=K1 + KK, color=CO, line_type=LDOT)\n"
|
80
290
|
|
81
291
|
------------------------------
|
2
import追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -59,3 +59,23 @@
|
|
59
59
|
add_arc(center=(10, 20), radius=10, start=0, end=90 color=3, line_type="CONTINUOUS")
|
60
60
|
|
61
61
|
で0度から90度までで10Rが描画できます。
|
62
|
+
|
63
|
+
------------------------------------
|
64
|
+
|
65
|
+
import sys
|
66
|
+
|
67
|
+
from logging import getLogger
|
68
|
+
|
69
|
+
import numpy as np
|
70
|
+
|
71
|
+
from copy import deepcopy
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
logger = getLogger()
|
76
|
+
|
77
|
+
import traceback
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
------------------------------
|
1
補足の追加。
test
CHANGED
File without changes
|
test
CHANGED
@@ -50,4 +50,12 @@
|
|
50
50
|
|
51
51
|
|
52
52
|
|
53
|
+
Python3.5標準の組み込み関数,及びmathライブラリ内の関数。
|
54
|
+
|
53
55
|
add_とcolor=3, line_type="CONTINUOUS"は必要なようです。
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
add_arc(center=(10, 20), radius=10, start=0, end=90 color=3, line_type="CONTINUOUS")
|
60
|
+
|
61
|
+
で0度から90度までで10Rが描画できます。
|