-
Notifications
You must be signed in to change notification settings - Fork 0
/
steamware.py
948 lines (562 loc) · 54.3 KB
/
steamware.py
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
#!/usr/bin/env python3
import os, sys
import shutil
import argparse
from loguru import logger
class STEAMWare:
""" This class builds digital representations of STEAMWare elements."""
def __init__(self, basis_unit, fit_padding, track_string, mass_type, export_name, export_directory): # Runs when object is initialized.
self.track_string = track_string # The string of configuration codes that are used to build the steamware element.
self.basis_unit = basis_unit # The initial basis unit that the steamware element is built on.
self.fit_padding = fit_padding # The initial fit padding that the system is built on.
self.mass_type = mass_type # The initial type of mass state that the system is in.
if mass_type is None: # If no mass type is given, the system defaults to "O" (Open).
mass_type = "O" # Default mass type is "O" (Open).
self.export_directory = export_directory # Directory where resources are delivered.
self.export_name = export_name # Name of the export file/directory.
self.steamware_element_directory = self.export_directory + "/" + self.export_name # The directory where the steamware element is stored.
if not os.path.exists(self.export_directory):
logger.info("Creating export directory : " + self.export_directory ) # Log export directory creation.
os.system("mkdir "+ self.export_directory) # Create export directory.
else: # If export directory already exists.
logger.info("Export directory : " + self.export_directory + " already exists." ) # Log export directory already exists.
if not os.path.exists(self.steamware_element_directory): # If steamware element directory does not exist.
logger.info("Creating steamware element directory : " + self.steamware_element_directory ) # Log steamware element directory creation.
os.system("mkdir "+ self.steamware_element_directory) # Create steamware element directory.
else: # If steamware element directory already exists.
logger.info("Steamware element directory : " + self.steamware_element_directory + " already exists." ) # Log steamware element directory already exists.
self.scad_file_name = export_directory + "/" + export_name + "/" + export_name +".scad" # The actual name of the scad file that is represented by the system code.
self.scad_file = open(self.scad_file_name, 'w+') # open file in append mode
os.system("cp -R "+os.path.dirname(__file__)+"/steamware.scad "+ self.steamware_element_directory) # On Linux, copies from relevent scad libraries into 'steamware element directory' to perfrom work and uses system codes and CONFIG CODES in particular to feed parametrization into. Libraries are intented to be removed after function has been fufilled.
self.scad_file.write('\n\n// STEAMWare Export Name: '+str(self.export_name)+'\n') # Write export name to scad file.
self.scad_file.write('// STEAMWare Export Directory: '+str(self.export_directory)+'\n') # Write export directory to scad file.
self.scad_file.write('// STEAMWare Track String Identity: '+str(self.track_string)+'\n\n') # Write track string identity to scad file.
self.scad_file.write('// Initial Basis Unit : '+str(self.basis_unit)+'\n') # Write basis unit to scad file.
self.scad_file.write('// Fit Padding : '+str(self.fit_padding)+'\n') # Write fit padding to scad file.
self.scad_file.write('// Initial Mass Type: '+str(self.mass_type)+'\n\n\n') # Write mass type to scad file.
self.scad_file.write('use <steamware.scad>;\n\n') # Write library usage. #TODO May need to be plugged in at the end.
self.block_coordinates_tracker = [ 0, 0, 0 ] # The coordinates of the block that is being tracked.
self.coupler_coordinates_tracker = [ 0, 0, 0 ] # The coordinates of the coupler that is being tracked.
self.coupler_orientation = [ 0, 0, 0 ] # The orientation of the coupler that is being tracked.1
self.delta_block_coordinates_tracker = [ 0, 0, 0 ] # The delta coordinates of the block that is being tracked.
self.delta_coupler_coordinates_tracker = [ 0, 0, 0 ] # The delta coordinates of the coupler that is being tracked.
if (self.mass_type == "O"): # If the mass type is "O" (Open).
self.scad_file.write('translate( [ 0, 0, 0 ] ) { optimized_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); }\n') # Write (Open) origin block to scad file.
if (self.mass_type == "F"): # If the mass type is "F" (Full/Filled).
self.scad_file.write('translate( [ 0, 0, 0 ] ) { solid_optimized_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); }\n') # Write (Filled/Full) origin block to scad file.
self.INSTRUCTION_SET = []
for i in list(self.track_string):
if i == "F": # If the mass type is "F" (Full/Filled).
self.mass_type = "F" # Set the mass type to "F" (Full/Filled).
if i =="O": # If the mass type is "O" (Open).
self.mass_type = "O" # Set the mass type to "O" (Open).
if i != "F" and i != "O": # If the mass type is not "F" (Full/Filled) or "O" (Open).
self.INSTRUCTION_SET.append([ i, self.mass_type ]) # This is where the instruction set is built.
for i in range(len(self.INSTRUCTION_SET)): # For each element in the instruction set ; track string identity.
INSTRUCTION = self.INSTRUCTION_SET[i] # Get the instruction.
if i != len(self.INSTRUCTION_SET)-1: # If not the last element.
NEXT_INSTRUCTION = self.INSTRUCTION_SET[i+1][0] # Get the next instruction.
else: # If the last element of the instruction.
NEXT_INSTRUCTION = None # If the last element.
if i == 0: # If the first element.
PREVIOUS_INSTRUCTION = None # If the first element.
else: # If not the first element.
PREVIOUS_INSTRUCTION = self.INSTRUCTION_SET[i-1][0] # Get the previous instruction.
self.transcribe_configuration(INSTRUCTION, NEXT_INSTRUCTION, PREVIOUS_INSTRUCTION) # Transcribe the configuration to the scad file.
self.scad_file.close() # Finish writing scad script.
def transcribe_configuration(self, INSTRUCTION, NEXT_INSTRUCTION, PREVIOUS_INSTRUCTION): # Transcribes the configuration to the scad file.
"""Transcribes the configuration to the scad file.
Args:
INSTRUCTION (str): Current track string instruction being processed and interpreted.
NEXT_INSTRUCTION (str): Next track string instruction being processed and interpreted.
PREVIOUS_INSTRUCTION (str): Previous track string instruction being processed and interpreted.
"""
self.previous_block_coordinates_tracker = self.block_coordinates_tracker
self.previous_coupler_coordinates_tracker = self.coupler_coordinates_tracker
self.mass_type = INSTRUCTION[1]
if (INSTRUCTION[0] =="A"):
if (PREVIOUS_INSTRUCTION == "G"):
pass
else:
if (NEXT_INSTRUCTION == "S"):
pass
if ((NEXT_INSTRUCTION in ["A", "B", "C", "X", "Y", "Z"] or PREVIOUS_INSTRUCTION in ["A", "B", "C", "X", "Y", "Z", "S"]) or (NEXT_INSTRUCTION == None and PREVIOUS_INSTRUCTION == None)):
self.coupler_orientation = [ 0, 0, 0 ]
self.coupler_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ -self.basis_unit/2, 0, 0 ])))
self.block_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ -self.basis_unit, 0, 0 ])))
bx = self.block_coordinates_tracker[0]
by = self.block_coordinates_tracker[1]
bz = self.block_coordinates_tracker[2]
cx = self.coupler_coordinates_tracker[0]
cy = self.coupler_coordinates_tracker[1]
cz = self.coupler_coordinates_tracker[2]
cox = self.coupler_orientation[0]
coy = self.coupler_orientation[1]
coz = self.coupler_orientation[2]
if (self.mass_type == "O"):
self.scad_file.write('translate( [ '+str(cx)+', '+str(cy)+', '+str(cz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { optimized_coupler( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { optimized_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); }\n')
if (self.mass_type == "F"):
self.scad_file.write('translate( [ '+str(cx)+', '+str(cy)+', '+str(cz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { solid_optimized_coupler( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { solid_optimized_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); }\n')
if (INSTRUCTION[0] =="B"):
if (PREVIOUS_INSTRUCTION == "G"):
pass
else:
if (NEXT_INSTRUCTION == "S"):
pass
if ((NEXT_INSTRUCTION in ["A", "B", "C", "X", "Y", "Z"] or PREVIOUS_INSTRUCTION in ["A", "B", "C", "X", "Y", "Z", "S"]) or (NEXT_INSTRUCTION == None and PREVIOUS_INSTRUCTION == None)):
self.coupler_orientation = [ 0, 0, -90]
self.coupler_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, -self.basis_unit/2, 0 ])))
self.block_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, -self.basis_unit, 0 ])))
bx = self.block_coordinates_tracker[0]
by = self.block_coordinates_tracker[1]
bz = self.block_coordinates_tracker[2]
cx = self.coupler_coordinates_tracker[0]
cy = self.coupler_coordinates_tracker[1]
cz = self.coupler_coordinates_tracker[2]
cox = self.coupler_orientation[0]
coy = self.coupler_orientation[1]
coz = self.coupler_orientation[2]
if (self.mass_type == "O"):
self.scad_file.write('translate( [ '+str(cx)+', '+str(cy)+', '+str(cz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { optimized_coupler( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { optimized_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); }\n')
if (self.mass_type == "F"):
self.scad_file.write('translate( [ '+str(cx)+', '+str(cy)+', '+str(cz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { solid_optimized_coupler( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { solid_optimized_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); }\n')
if (INSTRUCTION[0] =="C"):
if (PREVIOUS_INSTRUCTION == "G"):
pass
else:
if (NEXT_INSTRUCTION == "S"):
pass
if ((NEXT_INSTRUCTION in ["A", "B", "C", "X", "Y", "Z"] or PREVIOUS_INSTRUCTION in ["A", "B", "C", "X", "Y", "Z", "S"]) or (NEXT_INSTRUCTION == None and PREVIOUS_INSTRUCTION == None)):
self.coupler_orientation = [ 0, -90, 0]
self.coupler_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, 0, -self.basis_unit/2 ])))
self.block_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, 0, -self.basis_unit ])))
bx = self.block_coordinates_tracker[0]
by = self.block_coordinates_tracker[1]
bz = self.block_coordinates_tracker[2]
cx = self.coupler_coordinates_tracker[0]
cy = self.coupler_coordinates_tracker[1]
cz = self.coupler_coordinates_tracker[2]
cox = self.coupler_orientation[0]
coy = self.coupler_orientation[1]
coz = self.coupler_orientation[2]
if (self.mass_type == "O"):
self.scad_file.write('translate( [ '+str(cx)+', '+str(cy)+', '+str(cz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { optimized_coupler( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { optimized_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); }\n')
if (self.mass_type == "F"):
self.scad_file.write('translate( [ '+str(cx)+', '+str(cy)+', '+str(cz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { solid_optimized_coupler( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { solid_optimized_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); }\n')
if (INSTRUCTION[0] =="X"):
if (PREVIOUS_INSTRUCTION == "G"): # if (PREVIOUS_INSTRUCTION == "G" or (PREVIOUS_INSTRUCTION == "F" or PREVIOUS_INSTRUCTION == "O") and PREVIOUS_PREVIOUS_INSTRUCTION == "G"):
pass
else:
if (NEXT_INSTRUCTION == "S"):
pass
if ((NEXT_INSTRUCTION in ["A", "B", "C", "X", "Y", "Z"] or PREVIOUS_INSTRUCTION in ["A", "B", "C", "X", "Y", "Z", "S"]) or (NEXT_INSTRUCTION == None and PREVIOUS_INSTRUCTION == None)):
self.coupler_orientation = [ 0, 0, 0 ]
self.coupler_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ self.basis_unit/2, 0, 0 ])))
self.block_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ self.basis_unit, 0, 0 ])))
bx = self.block_coordinates_tracker[0]
by = self.block_coordinates_tracker[1]
bz = self.block_coordinates_tracker[2]
cx = self.coupler_coordinates_tracker[0]
cy = self.coupler_coordinates_tracker[1]
cz = self.coupler_coordinates_tracker[2]
cox = self.coupler_orientation[0]
coy = self.coupler_orientation[1]
coz = self.coupler_orientation[2]
if (self.mass_type == "O"):
self.scad_file.write('translate( [ '+str(cx)+', '+str(cy)+', '+str(cz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { optimized_coupler( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { optimized_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); }\n')
if (self.mass_type == "F"):
self.scad_file.write('translate( [ '+str(cx)+', '+str(cy)+', '+str(cz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { solid_optimized_coupler( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { solid_optimized_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); }\n')
if (INSTRUCTION[0] =="Y"):
if (PREVIOUS_INSTRUCTION == "G"):
pass
else:
if (NEXT_INSTRUCTION == "S"):
pass
if ((NEXT_INSTRUCTION in ["A", "B", "C", "X", "Y", "Z"] or PREVIOUS_INSTRUCTION in ["A", "B", "C", "X", "Y", "Z", "S"]) or (NEXT_INSTRUCTION == None and PREVIOUS_INSTRUCTION == None)):
self.coupler_orientation = [ 0, 0, 90]
self.coupler_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, self.basis_unit/2, 0 ])))
self.block_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, self.basis_unit, 0 ])))
bx = self.block_coordinates_tracker[0]
by = self.block_coordinates_tracker[1]
bz = self.block_coordinates_tracker[2]
cx = self.coupler_coordinates_tracker[0]
cy = self.coupler_coordinates_tracker[1]
cz = self.coupler_coordinates_tracker[2]
cox = self.coupler_orientation[0]
coy = self.coupler_orientation[1]
coz = self.coupler_orientation[2]
if (self.mass_type == "O"):
self.scad_file.write('translate( [ '+str(cx)+', '+str(cy)+', '+str(cz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { optimized_coupler( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { optimized_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); }\n')
if (self.mass_type == "F"):
self.scad_file.write('translate( [ '+str(cx)+', '+str(cy)+', '+str(cz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { solid_optimized_coupler( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { solid_optimized_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); }\n')
if (INSTRUCTION[0] =="Z"):
if (PREVIOUS_INSTRUCTION == "G"):
pass
else:
if (NEXT_INSTRUCTION == "S"):
pass
if ((NEXT_INSTRUCTION in ["A", "B", "C", "X", "Y", "Z"] or PREVIOUS_INSTRUCTION in ["A", "B", "C", "X", "Y", "Z", "S"]) or (NEXT_INSTRUCTION == None and PREVIOUS_INSTRUCTION == None)):
self.coupler_orientation = [ 0, 90, 0]
self.coupler_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, 0, self.basis_unit/2 ])))
self.block_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, 0, self.basis_unit ])))
bx = self.block_coordinates_tracker[0]
by = self.block_coordinates_tracker[1]
bz = self.block_coordinates_tracker[2]
cx = self.coupler_coordinates_tracker[0]
cy = self.coupler_coordinates_tracker[1]
cz = self.coupler_coordinates_tracker[2]
cox = self.coupler_orientation[0]
coy = self.coupler_orientation[1]
coz = self.coupler_orientation[2]
if (self.mass_type == "O"):
self.scad_file.write('translate( [ '+str(cx)+', '+str(cy)+', '+str(cz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { optimized_coupler( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { optimized_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); }\n')
if (self.mass_type == "F"):
self.scad_file.write('translate( [ '+str(cx)+', '+str(cy)+', '+str(cz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { solid_optimized_coupler( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { solid_optimized_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); }\n')
if (INSTRUCTION[0] == "G"):
if NEXT_INSTRUCTION == "A":
self.coupler_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ -self.basis_unit/2, 0, 0 ])))
self.block_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ -self.basis_unit, 0, 0 ])))
bx = self.block_coordinates_tracker[0]
by = self.block_coordinates_tracker[1]
bz = self.block_coordinates_tracker[2]
cx = self.coupler_coordinates_tracker[0]
cy = self.coupler_coordinates_tracker[1]
cz = self.coupler_coordinates_tracker[2]
cox = self.coupler_orientation[0]
coy = self.coupler_orientation[1]
coz = self.coupler_orientation[2]
if (self.mass_type == "O"):
self.scad_file.write('translate( [ '+str(cx)+', '+str(cy)+', '+str(cz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { optimized_coupler( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { transform_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
if (self.mass_type == "F"):
self.scad_file.write('translate( [ '+str(cx)+', '+str(cy)+', '+str(cz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { solid_optimized_coupler( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { solid_transform_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.coupler_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ -self.basis_unit/2, 0, 0 ])))
self.block_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ -self.basis_unit, 0, 0 ])))
self.basis_unit = self.basis_unit * 3
bx = self.block_coordinates_tracker[0]
by = self.block_coordinates_tracker[1]
bz = self.block_coordinates_tracker[2]
cx = self.coupler_coordinates_tracker[0]
cy = self.coupler_coordinates_tracker[1]
cz = self.coupler_coordinates_tracker[2]
cox = self.coupler_orientation[0]
coy = self.coupler_orientation[1]
coz = self.coupler_orientation[2]
if (self.mass_type == "O"):
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { optimized_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); }\n')
if (self.mass_type == "F"):
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { solid_optimized_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); }\n')
if NEXT_INSTRUCTION == "B":
self.coupler_orientation = [ 0, 0, -90]
self.coupler_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, -self.basis_unit/2, 0 ])))
self.block_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, -self.basis_unit, 0 ])))
bx = self.block_coordinates_tracker[0]
by = self.block_coordinates_tracker[1]
bz = self.block_coordinates_tracker[2]
cx = self.coupler_coordinates_tracker[0]
cy = self.coupler_coordinates_tracker[1]
cz = self.coupler_coordinates_tracker[2]
cox = self.coupler_orientation[0]
coy = self.coupler_orientation[1]
coz = self.coupler_orientation[2]
if (self.mass_type == "O"):
self.scad_file.write('translate( [ '+str(cx)+', '+str(cy)+', '+str(cz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { optimized_coupler( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { transform_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
if (self.mass_type == "F"):
self.scad_file.write('translate( [ '+str(cx)+', '+str(cy)+', '+str(cz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { solid_optimized_coupler( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { solid_transform_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.coupler_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, -self.basis_unit/2, 0 ])))
self.block_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, -self.basis_unit, 0 ])))
self.basis_unit = self.basis_unit * 3
bx = self.block_coordinates_tracker[0]
by = self.block_coordinates_tracker[1]
bz = self.block_coordinates_tracker[2]
cx = self.coupler_coordinates_tracker[0]
cy = self.coupler_coordinates_tracker[1]
cz = self.coupler_coordinates_tracker[2]
cox = self.coupler_orientation[0]
coy = self.coupler_orientation[1]
coz = self.coupler_orientation[2]
if (self.mass_type == "O"):
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { optimized_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); }\n')
if (self.mass_type == "F"):
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { solid_optimized_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); }\n')
if NEXT_INSTRUCTION == "C":
self.coupler_orientation = [ 0, -90, 0]
self.coupler_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, 0, -self.basis_unit/2 ])))
self.block_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, 0, -self.basis_unit ])))
bx = self.block_coordinates_tracker[0]
by = self.block_coordinates_tracker[1]
bz = self.block_coordinates_tracker[2]
cx = self.coupler_coordinates_tracker[0]
cy = self.coupler_coordinates_tracker[1]
cz = self.coupler_coordinates_tracker[2]
cox = self.coupler_orientation[0]
coy = self.coupler_orientation[1]
coz = self.coupler_orientation[2]
if (self.mass_type == "O"):
self.scad_file.write('translate( [ '+str(cx)+', '+str(cy)+', '+str(cz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { optimized_coupler( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { transform_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
if (self.mass_type == "F"):
self.scad_file.write('translate( [ '+str(cx)+', '+str(cy)+', '+str(cz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { solid_optimized_coupler( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { solid_transform_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.coupler_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, 0, -self.basis_unit/2 ])))
self.block_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, 0, -self.basis_unit ])))
self.basis_unit = self.basis_unit * 3
bx = self.block_coordinates_tracker[0]
by = self.block_coordinates_tracker[1]
bz = self.block_coordinates_tracker[2]
cx = self.coupler_coordinates_tracker[0]
cy = self.coupler_coordinates_tracker[1]
cz = self.coupler_coordinates_tracker[2]
cox = self.coupler_orientation[0]
coy = self.coupler_orientation[1]
coz = self.coupler_orientation[2]
if (self.mass_type == "O"):
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { optimized_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); }\n')
if (self.mass_type == "F"):
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { solid_optimized_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); }\n')
if NEXT_INSTRUCTION == "X":
self.coupler_orientation = [ 0, 0, 0 ]
self.coupler_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ self.basis_unit/2, 0, 0 ])))
self.block_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ self.basis_unit, 0, 0 ])))
bx = self.block_coordinates_tracker[0]
by = self.block_coordinates_tracker[1]
bz = self.block_coordinates_tracker[2]
cx = self.coupler_coordinates_tracker[0]
cy = self.coupler_coordinates_tracker[1]
cz = self.coupler_coordinates_tracker[2]
cox = self.coupler_orientation[0]
coy = self.coupler_orientation[1]
coz = self.coupler_orientation[2]
if (self.mass_type == "O"):
self.scad_file.write('translate( [ '+str(cx)+', '+str(cy)+', '+str(cz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { optimized_coupler( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { transform_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
if (self.mass_type == "F"):
self.scad_file.write('translate( [ '+str(cx)+', '+str(cy)+', '+str(cz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { solid_optimized_coupler( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { solid_transform_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.coupler_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ self.basis_unit/2, 0, 0 ])))
self.block_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ self.basis_unit, 0, 0 ])))
self.basis_unit = self.basis_unit * 3
bx = self.block_coordinates_tracker[0]
by = self.block_coordinates_tracker[1]
bz = self.block_coordinates_tracker[2]
cx = self.coupler_coordinates_tracker[0]
cy = self.coupler_coordinates_tracker[1]
cz = self.coupler_coordinates_tracker[2]
cox = self.coupler_orientation[0]
coy = self.coupler_orientation[1]
coz = self.coupler_orientation[2]
if (self.mass_type == "O"):
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { optimized_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); }\n')
if (self.mass_type == "F"):
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { solid_optimized_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); }\n')
if NEXT_INSTRUCTION == "Y":
self.coupler_orientation = [ 0, 0, 90 ]
self.coupler_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, self.basis_unit/2, 0 ])))
self.block_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, self.basis_unit, 0 ])))
bx = self.block_coordinates_tracker[0]
by = self.block_coordinates_tracker[1]
bz = self.block_coordinates_tracker[2]
cx = self.coupler_coordinates_tracker[0]
cy = self.coupler_coordinates_tracker[1]
cz = self.coupler_coordinates_tracker[2]
cox = self.coupler_orientation[0]
coy = self.coupler_orientation[1]
coz = self.coupler_orientation[2]
if (self.mass_type == "O"):
self.scad_file.write('translate( [ '+str(cx)+', '+str(cy)+', '+str(cz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { optimized_coupler( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { transform_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
if (self.mass_type == "F"):
self.scad_file.write('translate( [ '+str(cx)+', '+str(cy)+', '+str(cz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { solid_optimized_coupler( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { solid_transform_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.coupler_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, self.basis_unit/2, 0 ])))
self.block_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, self.basis_unit, 0 ])))
self.basis_unit = self.basis_unit * 3
bx = self.block_coordinates_tracker[0]
by = self.block_coordinates_tracker[1]
bz = self.block_coordinates_tracker[2]
cx = self.coupler_coordinates_tracker[0]
cy = self.coupler_coordinates_tracker[1]
cz = self.coupler_coordinates_tracker[2]
cox = self.coupler_orientation[0]
coy = self.coupler_orientation[1]
coz = self.coupler_orientation[2]
if (self.mass_type == "O"):
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { optimized_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); }\n')
if (self.mass_type == "F"):
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { solid_optimized_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); }\n')
if NEXT_INSTRUCTION == "Z":
self.coupler_orientation = [ 0, 90, 0]
self.coupler_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, 0, self.basis_unit/2 ])))
self.block_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, 0, self.basis_unit])))
bx = self.block_coordinates_tracker[0]
by = self.block_coordinates_tracker[1]
bz = self.block_coordinates_tracker[2]
cx = self.coupler_coordinates_tracker[0]
cy = self.coupler_coordinates_tracker[1]
cz = self.coupler_coordinates_tracker[2]
cox = self.coupler_orientation[0]
coy = self.coupler_orientation[1]
coz = self.coupler_orientation[2]
if (self.mass_type == "O"):
self.scad_file.write('translate( [ '+str(cx)+', '+str(cy)+', '+str(cz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { optimized_coupler( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { transform_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
if (self.mass_type == "F"):
self.scad_file.write('translate( [ '+str(cx)+', '+str(cy)+', '+str(cz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { solid_optimized_coupler( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { solid_transform_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.coupler_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, 0, self.basis_unit/2 ])))
self.block_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, 0, self.basis_unit])))
self.basis_unit = self.basis_unit * 3
bx = self.block_coordinates_tracker[0]
by = self.block_coordinates_tracker[1]
bz = self.block_coordinates_tracker[2]
cx = self.coupler_coordinates_tracker[0]
cy = self.coupler_coordinates_tracker[1]
cz = self.coupler_coordinates_tracker[2]
cox = self.coupler_orientation[0]
coy = self.coupler_orientation[1]
coz = self.coupler_orientation[2]
if (self.mass_type == "O"):
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { optimized_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); }\n')
if (self.mass_type == "F"):
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { solid_optimized_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); }\n')
if (INSTRUCTION[0] =="S"):
if NEXT_INSTRUCTION == "A":
self.coupler_orientation = [ 0, 0, 0]
self.basis_unit = self.basis_unit / 3
self.coupler_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ -self.basis_unit/2, 0, 0 ])))
self.block_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ -self.basis_unit, 0, 0 ])))
bx = self.block_coordinates_tracker[0]
by = self.block_coordinates_tracker[1]
bz = self.block_coordinates_tracker[2]
cx = self.coupler_coordinates_tracker[0]
cy = self.coupler_coordinates_tracker[1]
cz = self.coupler_coordinates_tracker[2]
cox = self.coupler_orientation[0]
coy = self.coupler_orientation[1]
coz = self.coupler_orientation[2]
if (self.mass_type == "O"):
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { transform_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
if (self.mass_type == "F"):
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { solid_transform_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
if NEXT_INSTRUCTION == "B":
self.coupler_orientation = [ 0, 0, -90]
self.basis_unit = self.basis_unit / 3
self.coupler_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, -self.basis_unit/2, 0 ])))
self.block_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, -self.basis_unit, 0 ])))
bx = self.block_coordinates_tracker[0]
by = self.block_coordinates_tracker[1]
bz = self.block_coordinates_tracker[2]
cx = self.coupler_coordinates_tracker[0]
cy = self.coupler_coordinates_tracker[1]
cz = self.coupler_coordinates_tracker[2]
cox = self.coupler_orientation[0]
coy = self.coupler_orientation[1]
coz = self.coupler_orientation[2]
if (self.mass_type == "O"):
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { transform_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
if (self.mass_type == "F"):
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { solid_transform_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
if NEXT_INSTRUCTION == "C":
self.coupler_orientation = [ 0, -90, 0]
self.basis_unit = self.basis_unit / 3
self.coupler_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, 0, -self.basis_unit/2 ])))
self.block_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, 0, -self.basis_unit ])))
bx = self.block_coordinates_tracker[0]
by = self.block_coordinates_tracker[1]
bz = self.block_coordinates_tracker[2]
cx = self.coupler_coordinates_tracker[0]
cy = self.coupler_coordinates_tracker[1]
cz = self.coupler_coordinates_tracker[2]
cox = self.coupler_orientation[0]
coy = self.coupler_orientation[1]
coz = self.coupler_orientation[2]
if (self.mass_type == "O"):
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { transform_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
if (self.mass_type == "F"):
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { solid_transform_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
if NEXT_INSTRUCTION == "X":
self.coupler_orientation = [ 0, 0, 0 ]
self.basis_unit = self.basis_unit / 3
self.coupler_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ self.basis_unit/2, 0, 0 ])))
self.block_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ self.basis_unit, 0, 0 ])))
bx = self.block_coordinates_tracker[0]
by = self.block_coordinates_tracker[1]
bz = self.block_coordinates_tracker[2]
cx = self.coupler_coordinates_tracker[0]
cy = self.coupler_coordinates_tracker[1]
cz = self.coupler_coordinates_tracker[2]
cox = self.coupler_orientation[0]
coy = self.coupler_orientation[1]
coz = self.coupler_orientation[2]
if (self.mass_type == "O"):
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { transform_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
if (self.mass_type == "F"):
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { solid_transform_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
if NEXT_INSTRUCTION == "Y":
self.coupler_orientation = [ 0, 0, 90 ]
self.basis_unit = self.basis_unit / 3
self.coupler_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, self.basis_unit/2, 0 ])))
self.block_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, self.basis_unit, 0 ])))
bx = self.block_coordinates_tracker[0]
by = self.block_coordinates_tracker[1]
bz = self.block_coordinates_tracker[2]
cx = self.coupler_coordinates_tracker[0]
cy = self.coupler_coordinates_tracker[1]
cz = self.coupler_coordinates_tracker[2]
cox = self.coupler_orientation[0]
coy = self.coupler_orientation[1]
coz = self.coupler_orientation[2]
if (self.mass_type == "O"):
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { transform_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
if (self.mass_type == "F"):
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { solid_transform_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
if NEXT_INSTRUCTION == "Z":
self.coupler_orientation = [ 0, 90, 0]
self.basis_unit = self.basis_unit / 3
self.coupler_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, 0, self.basis_unit/2 ])))
self.block_coordinates_tracker = list(map(sum, zip(self.block_coordinates_tracker,[ 0, 0, self.basis_unit ])))
bx = self.block_coordinates_tracker[0]
by = self.block_coordinates_tracker[1]
bz = self.block_coordinates_tracker[2]
cx = self.coupler_coordinates_tracker[0]
cy = self.coupler_coordinates_tracker[1]
cz = self.coupler_coordinates_tracker[2]
cox = self.coupler_orientation[0]
coy = self.coupler_orientation[1]
coz = self.coupler_orientation[2]
if (self.mass_type == "O"):
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { transform_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
if (self.mass_type == "F"):
self.scad_file.write('translate( [ '+str(bx)+', '+str(by)+', '+str(bz)+' ] ) { rotate ( [ '+str(cox)+', '+str(coy)+', '+str(coz)+' ] ) { solid_transform_block( '+str(self.basis_unit)+' , '+str(self.fit_padding)+' ); } }\n')
self.coupler_orientation = [ 0, 0, 0 ]
print(PREVIOUS_INSTRUCTION, INSTRUCTION, NEXT_INSTRUCTION, "----> "+str(self.block_coordinates_tracker))
if __name__ == "__main__":
""" Main Program """
parser = argparse.ArgumentParser() # Create Argument Parser Object
parser.add_argument("--en", "--export_name", help="Export Name", type=str) # Add the export name argument which is a string that descrribes the name of the file/directory to be exported.
parser.add_argument("--ed", "--export_directory", help="Export Directory", type=str) # Add the export directory argument which is a string that describes the directory where the file/directory will be exported.
parser.add_argument("--bu", "--basis_unit", help="Basis Unit", type=float) # Add the basis unit argument which is a float that describes the basis unit of the block.
parser.add_argument("--fp", "--fit_padding", help="Fit Padding", type=float) # Add the fit padding argument which is a float that describes the fit padding of the block.
parser.add_argument("--ts", "--track_string", help="Track String", type=str) # Add the track string argument which is a string that describes the track string of the block.
parser.add_argument("--mt", "--mass_type", help="Mass Type", type=str) # Add the mass type argument which is a string that describes the mass type of the initial block(s).
args = parser.parse_args() # Parse the arguments and store them in the args variable.
STEAMWare(args.bu, args.fp, args.ts, args.mt, args.en, args.ed) # Create a STEAMWare object with the basis unit, fit padding, track string, mass type, export name, and export directory arguments.
"""Examples:
# Powershell: python steamware.py --en "test" --ed "C:/Users/JohnDoe/Desktop" --bu 10 --fp 0.1 --mt "O" --ts "UABCD"
# Linux: python steamware.py --en "test" --ed "/home/JohnDoe/Desktop" --bu 10 --fp 0.1 --mt "O" --ts "UABCD"
"""