-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRoughDonut.bas
1966 lines (1572 loc) · 64.1 KB
/
RoughDonut.bas
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
'This macro is used to create rough donut lathe programs
'Created 5/31/18 - Barrett Stolzman
'HELLO
Option Explicit
#Region "Variable Declarations"
Dim doc As FMDocument
Dim app As Application
Dim feature As FMFeature
Dim stock As FMStock
Dim partdoc As FMPartDoc
Dim config As FMConfiguration
Dim program_number As String
Dim part_number As String
Dim revision As String
Dim operation As String
Dim operation2 As String
Dim operation3 As String
Dim writer As String
Dim rc As Variant
'rgh stock dimensions
Dim od As Double
Dim id As Double
Dim oal As Double
Dim stock_od As Double
Dim stock_id As Double
Dim face_1st As Double
Dim face_2nd As Double
Dim face_doc As Double
Dim od_doc As Double
Dim id_doc As Double
Dim dlgmaterial As String
Dim dlgmachine As String
Dim optfeatures As Double
Dim chkforging As Double
Dim material As String
Dim trepan_od As Double
Dim trepan_id As Double
Dim trepan_depth As Double
Dim fin_allow As Double 'finish allowance on o.d. & i.d.
Dim turn_clearance As Double 'clearance for o.d. & face
Dim bore_clearance As Double 'clearance for bore
Dim bore_allow As Double
Dim bore_chfr As Double
'tools
Dim turnsfm As Double
Dim turnipr As Double
Dim boresfm As Double
Dim boreipr As Double
Dim groovesfm As Double
Dim grooveipr As Double
Dim toolrad1 As Double 'tool radius of turning tool
Dim turntool As String 'name of facing/turning tool
Dim toolrad2 As Double 'tool radius of boring bar
Dim boretool As String 'name of boring bar
Dim toolrad3 As Double 'tool radius for rough trepan tool
Dim trepantool As String 'name for rough trepan tool
Dim trepanwidth As Double 'width of trepan tool
'flags
Dim trepanFlag As Boolean
'constants
Const pi = Atn(1)*4
#End Region
'*********************************************************************************
'*-----------------------------------Subs----------------------------------------*
'*********************************************************************************
Sub Main
RoughDonut
End Sub
Private Sub AddIn_OnConnect(ByVal flags As FeatureCAM.tagFMAddInFlags)
Application.CommandBars.CreateButton("Utilities", "RoughDonut", eMBFID_Hammer1)
End Sub
Private Sub AddIn_OnDisConnect(ByVal flags As FeatureCAM.tagFMAddInFlags)
Application.CommandBars.DeleteButton("Utilities", "RoughDonut")
End Sub
Sub RoughDonut
If ApplicationCheck() Then
trepanFlag = False
dlgmaterial = "Select Material"
dlgmachine = "Select Machine"
face_1st = .1
face_2nd = .1
CreateDialogMachine 'call sub for machine selection
CreateDialogMaterial 'call sub for material selection
InitializeVars 'call initialize variable routine
CreateDialogDonut 'call main dimmension input form
If trepanFlag Then
CreateDialogTrepan
End If
InitializeDoc 'call initialize doc objects routine
CreateFeature 'call to create features
End If
End Sub
Private Sub CreateDialogMachine
Begin Dialog UserDialog 640,84,"Machine Selection" ' %GRID:10,7,1,1
CancelButton 440,28,10,7
PushButton 30,21,130,42,"5222",.PushButton1
PushButton 180,21,130,42,"5219",.PushButton2
PushButton 330,21,130,42,"5230",.PushButton3
PushButton 480,21,130,42,"5506",.PushButton4
End Dialog
Dim dlg As UserDialog
Dim rc As Integer
rc = Dialog( dlg)
If (rc = 0) Then
End
ElseIf rc = 1 Then
dlgmachine = "5222"
fin_allow = .05
ElseIf rc = 2 Then
dlgmachine = "5219"
fin_allow = .05
ElseIf rc = 3 Then
dlgmachine = "5230"
fin_allow = .1
ElseIf rc = 4 Then
dlgmachine = "5506"
fin_allow = .1
End If
End Sub
Private Sub CreateDialogMaterial
Begin Dialog UserDialog 620,84,"Material Selection" ' %GRID:10,7,1,1
CancelButton 580,28,10,7
PushButton 20,21,130,42,"1018 / Bronze",.PushButton1
PushButton 170,21,130,42,"4140",.PushButton2
PushButton 320,21,130,42,"HT Steel",.PushButton3
PushButton 470,21,130,42,"Copper",.PushButton4
End Dialog
Dim dlg As UserDialog
Dim rc As Integer
rc = Dialog(dlg)
If (rc = 0) Then
End
ElseIf rc = 1 Then
dlgmaterial = "1018 / Bronze"
ElseIf rc = 2 Then
dlgmaterial = "4140"
ElseIf rc = 3 Then
dlgmaterial = "HT Steel"
ElseIf rc = 4 Then
dlgmaterial = "Copper"
End If
End Sub
Private Sub CreateDialogDonut
Begin Dialog UserDialog 870,224,"Stock Dimensions & Feature Selection" ' %GRID:10,7,1,1
TextBox 140,14,70,21,.program_number
Text 10,21,120,14,"Program Number",.text1,1
TextBox 140,42,120,21,.part_number
Text 40,49,90,14,"Part Number",.text2,1
TextBox 140,70,70,21,.Revision
Text 20,77,110,14,"Revision Level",.text3,1
TextBox 140,98,35,21,.operation
TextBox 185,98,35,21,.operation2
TextBox 230,98,35,21,.operation3
Text 10,105,120,14,"Op. Number",.text4,1
TextBox 140,126,70,21,.writer
Text 40,133,90,14,"Entered By",.text5,1
TextBox 360,14,70,21,.od
Text 290,21,60,14,"O.D.",.text6,1
TextBox 360,42,70,21,.ID
Text 290,49,60,14,"I.D.",.text7,1
TextBox 360,70,70,21,.oal
Text 270,77,80,14,"Length",.text8,1
TextBox 360,98,70,21,.stock_od
Text 270,105,80,14,"Stock O.D.",.text9,1
TextBox 360,126,70,21,.stock_id
Text 270,133,80,14,"Stock I.D.",.text10,1
TextBox 590,14,70,21,.face_1st
Text 450,21,130,14,"Face Stock 1st Side",.Text11,1
TextBox 590,42,70,21,.face_2nd
Text 440,49,140,14,"Face Stock 2nd Side",.Text12,1
TextBox 590,70,70,21,.face_doc
Text 470,77,110,14,"Face DOC",.text13,1
TextBox 590,98,70,21,.od_doc
Text 460,105,120,14,"O.D. DOC",.text14,1
TextBox 590,126,70,21,.id_doc
Text 470,133,110,14,"Bore DOC",.text15,1
Text 670,133,140,14,"Stock Is Forged Ring",.text25,1
GroupBox 690,7,160,63,"Bore Features",.GroupBox1
GroupBox 690,84,160,35,"Other Features",.GroupBox2
Text 700,21,110,14,"Standard Bore",.text22,1
Text 700,35,110,14,"Tight Tol. Bore",.text23,1
Text 700,49,110,14,"Eccentric Bore",.text24,1
Text 700,98,110,14,"Trepan",.text26,1
OptionGroup .optfeatures
OptionButton 820,21,20,14,"",.optstandardbore
OptionButton 820,35,20,14,"",.opttightbore
OptionButton 820,49,20,14,"",.opteccbore
OptionButton 820,98,20,14,"",.opttrepan
CheckBox 820,133,14,14,"chkforging",.chkforging
PushButton 690,161,160,21,dlgmaterial,.dlgmaterial
PushButton 690,189,160,21,dlgmachine,.dlgmachine
OKButton 290,182,120,28
CancelButton 450,182,120,28
End Dialog
ShowDialogP:
'Dialog dlg
Dim dlg As UserDialog
dlg.program_number = CStr(program_number)
dlg.part_number = CStr(part_number)
dlg.Revision = CStr(revision)
dlg.operation = CStr(operation)
dlg.operation2 = CStr(operation2)
dlg.operation3 = CStr(operation3)
dlg.writer = CStr(writer)
dlg.od = CStr(od)
dlg.ID = CStr(id)
dlg.oal = CStr(oal)
dlg.stock_od = CStr(stock_od)
dlg.stock_id = CStr(stock_id)
dlg.face_1st = CStr(face_1st)
dlg.face_2nd = CStr(face_2nd)
dlg.face_doc = CStr(face_doc)
dlg.od_doc = CStr(od_doc)
dlg.id_doc = CStr(id_doc)
dlg.optfeatures = CStr(optfeatures)
dlg.chkforging = CStr(chkforging)
rc = Dialog( dlg)
If (rc = 0) Then
End
ElseIf rc = 1 Then
program_number = CStr(dlg.program_number)
part_number = CStr(dlg.part_number)
revision = CStr(dlg.Revision)
operation = CStr(dlg.operation)
operation2 = CStr(dlg.operation2)
operation3 = CStr(dlg.operation3)
writer = CStr(dlg.writer)
od = CDbl(dlg.od)
id = CDbl(dlg.ID)
oal = CDbl(dlg.oal)
stock_od = CDbl(dlg.stock_od)
stock_id = CDbl(dlg.stock_id)
face_1st = CDbl(dlg.face_1st)
face_2nd = CDbl(dlg.face_2nd)
face_doc = CDbl(dlg.face_doc)
od_doc = CDbl(dlg.od_doc)
id_doc = CDbl(dlg.id_doc)
optfeatures = CDbl(dlg.optfeatures)
chkforging = CDbl(dlg.chkforging)
CreateDialogMaterial
End
ElseIf rc = 2 Then
program_number = CStr(dlg.program_number)
part_number = CStr(dlg.part_number)
revision = CStr(dlg.Revision)
operation = CStr(dlg.operation)
operation2 = CStr(dlg.operation2)
operation3 = CStr(dlg.operation3)
writer = CStr(dlg.writer)
od = CDbl(dlg.od)
id = CDbl(dlg.ID)
oal = CDbl(dlg.oal)
stock_od = CDbl(dlg.stock_od)
stock_id = CDbl(dlg.stock_id)
face_1st = CDbl(dlg.face_1st)
face_2nd = CDbl(dlg.face_2nd)
face_doc = CDbl(dlg.face_doc)
od_doc = CDbl(dlg.od_doc)
id_doc = CDbl(dlg.id_doc)
optfeatures = CDbl(dlg.optfeatures)
chkforging = CDbl(dlg.chkforging)
CreateDialogMachine
End
ElseIf( rc = -1) Then
program_number = CStr(dlg.program_number)
part_number = CStr(dlg.part_number)
revision = CStr(dlg.Revision)
operation = CStr(dlg.operation)
operation2 = CStr(dlg.operation2)
operation3 = CStr(dlg.operation3)
writer = CStr(dlg.writer)
od = CDbl(dlg.od)
id = CDbl(dlg.ID)
oal = CDbl(dlg.oal)
stock_od = CDbl(dlg.stock_od)
stock_id = CDbl(dlg.stock_id)
face_1st = CDbl(dlg.face_1st)
face_2nd = CDbl(dlg.face_2nd)
face_doc = CDbl(dlg.face_doc)
od_doc = CDbl(dlg.od_doc)
id_doc = CDbl(dlg.id_doc)
optfeatures = CDbl(dlg.optfeatures)
chkforging = CDbl(dlg.chkforging)
If ValidInputDonut = False Then
GoTo ShowDialogP
End If
If optfeatures = 3 Then
trepanFlag = True
End If
End If
End Sub
Private Sub CreateDialogTrepan
'trepan_od = od-.25
'trepan_id = id+.25
Begin Dialog UserDialog 580,119,"Trepan Dimensions" ' %GRID:10,7,1,1
TextBox 110,14,70,21,.trepan_od
TextBox 290,14,70,21,.trepan_id
TextBox 480,14,70,21,.trepan_depth
Text 10,21,90,14,"Trepan O.D.",.text16,1
Text 200,21,80,14,"Trepan I.D.",.text17,1
Text 380,21,90,14,"Trepan Depth",.text18,1
OKButton 150,70,120,28
CancelButton 310,70,120,28
End Dialog
ShowDialogTrepan:
'Dialog dlg
Dim dlg As UserDialog
dlg.trepan_od = CStr(trepan_od)
dlg.trepan_id = CStr(trepan_id)
dlg.trepan_depth = CStr(trepan_depth)
rc = Dialog( dlg)
If (rc = 0) Then
End
ElseIf( rc = -1) Then
trepan_od = CDbl(dlg.trepan_od)
trepan_id = CDbl(dlg.trepan_id)
trepan_depth = CDbl(dlg.trepan_depth)
If ValidInputTrepan = False Then
GoTo ShowDialogTrepan
End If
End If
End Sub
Private Sub CreateTrepan
'geometry for trepan
Dim ODLine, backLine, IDLine, UhhLine As FMLine
Set ODLine = doc.Geometry.AddLine2Points(trepan_od/2,0,0,trepan_od/2,0,-trepan_depth)
Set backLine = doc.Geometry.AddLine2Points(trepan_od/2,0,-trepan_depth,trepan_id/2,0,-trepan_depth)
Set IDLine = doc.Geometry.AddLine2Points(trepan_id/2,0,-trepan_depth,trepan_id/2,0,0)
'trepan features
If trepan_od > 4.999 And trepan_od/2-trepan_id/2-(trepan_depth/Tan(28*pi/180))-.1-Sin(45*pi/180)*(.1+toolrad2-Sin(45*pi/180)*(toolrad2))+toolrad2>.8 Then
Set UhhLine = doc.Geometry.AddLine2Points(trepan_od/2,0,0,trepan_od/2-trepan_depth/(Tan(28*pi/180)),0,-trepan_depth)
toolrad3 = .046
If dlgmachine = "5230" Then
trepantool = "DDJNR (trepan)"
Else
trepantool = "DDJNL (trepan)"
End If
Dim trepandoc
If dlgmaterial = "Copper" Then
trepandoc = .05
Else
trepandoc = .12
End If
'rough trepan
Dim rghCurveL As FMCurvePtList
Dim rghCurve As FMCurve
Set rghCurveL = doc.CreateCurvePtList
rghCurveL.AddPt(trepan_od/2,0,0)
rghCurveL.AddPt(trepan_od/2-trepan_depth/(Tan(28*pi/180)),0,-trepan_depth)
rghCurveL.AddPt(trepan_id/2,0,-trepan_depth)
rghCurveL.AddPt(trepan_id/2,0,0)
Set rghCurve = rghCurveL.AddCurveFromPtList(False)
Dim rghTurn As FMTurn
Set rghTurn = doc.Features.AddTurn(rghCurve,,,)
rghTurn.SetAttribute(eAID_DoFinish,,False,False,)
rghTurn.SetAttribute(eAID_TurnCycleType,,1,False,)
rghTurn.Operations(1).SetAttribute(eAID_TurnRoughDOC,,trepandoc,False,)
rghTurn.Operations(1).SetAttribute(eAID_MaxZBound,,-oal,False,)
rghTurn.Operations(1).SetAttribute(eAID_TurnFinishXAllow,,.03,False,)
rghTurn.Operations(1).SetAttribute(eAID_TurnFinishZAllow,,.03,False,)
rghTurn.Operations(1).SetAttribute(eAID_SkipWallPass,,True,False,)
rghTurn.Operations(1).SetAttribute(eAID_TurnRoughEngageWindrawAtRapid,,False,False,)
'rghTurn.Operations(1).SetAttribute(eAID_TurnRapidFeedRate,,.009,False,)
rghTurn.Operations(1).OverrideSpeed(turnsfm,)
rghTurn.Operations(1).OverrideFeed(.012,)
rghTurn.Operations(1).OverrideTool(trepantool,)
rghTurn.Name = "rough_trepan"
'finish trepan bottom
Dim bottomStartpt, bottomEndpt As String
bottomStartpt = "pt(" & trepan_od/2-Sin(28*pi/180)*(toolrad3)+Cos(28*pi/180)*(.1+toolrad3) & ",0," & Cos(28*pi/180)*(toolrad3)+Sin(28*pi/180)*(.1+toolrad3)+(.1+toolrad3) &")"
bottomEndpt = "pt(" & trepan_id/2+.03+toolrad3+Sin(45*pi/180)*(.1+toolrad3) & ",0," & Cos(45*pi/180)*(.1+toolrad3*2) &")"
Dim bottomCurveL As FMCurvePtList
Dim bottomCurve As FMCurve
Set bottomCurveL = doc.CreateCurvePtList
bottomCurveL.AddPt(trepan_od/2,0,0)
bottomCurveL.AddPt(trepan_od/2-trepan_depth/(Tan(28*pi/180)),0,-trepan_depth)
bottomCurveL.AddPt(trepan_id/2+.03,0,-trepan_depth)
bottomCurveL.AddPt(trepan_id/2+.03,0,-trepan_depth+.05)
Set bottomCurve = bottomCurveL.AddCurveFromPtList(False)
Dim bottomTurn As FMTurn
Set bottomTurn = doc.Features.AddTurn(bottomCurve,,,)
bottomTurn.SetAttribute(eAID_DoRough,,False,False,)
bottomTurn.SetAttribute(eAID_TurnCycleType,,1,False,)
bottomTurn.Operations(1).OverrideSpeed(turnsfm,)
bottomTurn.Operations(1).OverrideFeed(.012,)
bottomTurn.Operations(1).SetAttribute(eAID_TurnStartPt,,bottomStartpt,False,)
bottomTurn.Operations(1).SetAttribute(eAID_TurnEndPt,,bottomEndpt,False,)
bottomTurn.Operations(1).OverrideTool(trepantool,)
bottomTurn.Name = "fin_trepan_bottom"
'finish hub dia
Dim hubStartpt, hubEndpt As String
hubStartpt = "pt(" & trepan_id/2+toolrad3-.02-Sin(45*pi/180)*(.1)-toolrad3 & ",0," & Cos(45*pi/180)*(.1+toolrad3*2) &")"
hubEndpt = "pt(" & trepan_id/2+.09+toolrad3+Sin(45*pi/180)*(.1+toolrad3) & ",0," & Cos(45*pi/180)*(.1+toolrad3*2) &")"
Dim hubCurveL As FMCurvePtList
Dim hubCurve As FMCurve
Set hubCurveL = doc.CreateCurvePtList
hubCurveL.AddPt(trepan_id/2-.02,0,0)
hubCurveL.AddPt(trepan_id/2,0,-.02)
hubCurveL.AddPt(trepan_id/2,0,-trepan_depth)
hubCurveL.AddPt(trepan_id/2+.09,0,-trepan_depth)
Set hubCurve = hubCurveL.AddCurveFromPtList(False)
Dim hubTurn As FMTurn
Set hubTurn = doc.Features.AddTurn(hubCurve,,,)
hubTurn.SetAttribute(eAID_DoRough,,False,False,)
hubTurn.Operations(1).OverrideSpeed(turnsfm,)
hubTurn.Operations(1).OverrideFeed(.012,)
hubTurn.Operations(1).SetAttribute(eAID_TurnStartPt,,hubStartpt,False,)
hubTurn.Operations(1).SetAttribute(eAID_TurnEndPt,,hubEndpt,False,)
hubTurn.Operations(1).OverrideTool(trepantool,)
hubTurn.Name = "fin_hub_dia"
'rough match trepan
Dim rghMatchEndpt
rghMatchEndpt = "pt(" & trepan_od/2-.03-toolrad2-Sin(45*pi/180)*.025 & ",0," & -trepan_depth+.03+toolrad2+Cos(45*pi/180)*.025 &")"
Dim rghMatchCurveL As FMCurvePtList
Dim rghMatchCurve As FMCurve
Set rghMatchCurveL = doc.CreateCurvePtList
rghMatchCurveL.AddPt(trepan_od/2,0,0)
rghMatchCurveL.AddPt(trepan_od/2,0,-trepan_depth)
rghMatchCurveL.AddPt(trepan_od/2-trepan_depth/(Tan(28*pi/180)),0,-trepan_depth)
Set rghMatchCurve = rghMatchCurveL.AddCurveFromPtList(False)
Dim rghMatchBore As FMBore
Set rghMatchBore = doc.Features.AddBore(rghMatchCurve,UhhLine,,)
rghMatchBore.SetAttribute(eAID_DoFinish,,False,False,)
rghMatchBore.Operations(1).SetAttribute(eAID_TurnRoughDOC,,trepandoc,False,)
rghMatchBore.Operations(1).SetAttribute(eAID_MinXBound,,trepan_od/2-trepan_depth/(Tan(28*pi/180)),False,)
rghMatchBore.Operations(1).SetAttribute(eAID_TurnFinishXAllow,,.03,False,)
rghMatchBore.Operations(1).SetAttribute(eAID_TurnFinishZAllow,,.03,False,)
rghMatchBore.Operations(1).SetAttribute(eAID_SkipWallPass,,True,False,)
rghMatchBore.Operations(1).SetAttribute(eAID_TurnRoughEngageWindrawAtRapid,,True,False,)
rghMatchBore.Operations(1).SetAttribute(eAID_TurnEndPt,,rghMatchEndpt,False,)
rghMatchBore.Operations(1).OverrideSpeed(boresfm,)
rghMatchBore.Operations(1).OverrideFeed(.012,)
rghMatchBore.Operations(1).OverrideTool(boretool,)
rghMatchBore.Name = "rough_rghMatch_trepan"
'finish match trepan
Dim finMatchStartpt, finMatchEndpt As String
finMatchStartpt = "pt(" & trepan_od/2-trepan_depth/(Tan(28*pi/180))-.1-Sin(45*pi/180)*(.1+toolrad2-Sin(45*pi/180)*(toolrad2)) & ",0," & toolrad2-.05+Cos(45*pi/180)*(.1+toolrad2-Cos(45*pi/180)*(toolrad2)) &")"
finMatchEndpt = "pt(" & trepan_od/2-.03-toolrad2-Sin(45*pi/180)*(toolrad2+.1) & ",0," & trepan_depth-.05+Cos(45*pi/180)*(.1+toolrad3*2) &")"
Dim finMatchCurveL As FMCurvePtList
Dim finMatchCurve As FMCurve
Set finMatchCurveL = doc.CreateCurvePtList
finMatchCurveL.AddPt(trepan_od/2-.03,0,-trepan_depth + .05)
finMatchCurveL.AddPt(trepan_od/2-.03,0,-trepan_depth)
finMatchCurveL.AddPt(trepan_od/2-trepan_depth/(Tan(28*pi/180))-.1,0,-trepan_depth)
Set finMatchCurve = finMatchCurveL.AddCurveFromPtList(False)
Dim finMatchBore As FMBore
Set finMatchBore = doc.Features.AddBore(finMatchCurve,,,)
finMatchBore.SetAttribute(eAID_DoRough,,False,False,)
finMatchBore.SetAttribute(eAID_TurnCycleType,,1,False,) 'change cycle from bore to face
finMatchBore.SetAttribute(eAID_TurnReverseFinish,,True,,) 'change feed direction from negative to positive
finMatchBore.Operations(1).SetAttribute(eAID_TurnEngageAng,,45,False,)
finMatchBore.Operations(1).SetAttribute(eAID_TurnStartPt,,finMatchStartpt,False,)
finMatchBore.Operations(1).SetAttribute(eAID_TurnEndPt,,finMatchEndpt,False,)
finMatchBore.Operations(1).OverrideSpeed(boresfm,)
finMatchBore.Operations(1).OverrideFeed(.012,)
finMatchBore.Operations(1).OverrideTool(boretool,)
finMatchBore.Name = "fin_match_trepan"
'finish outer trepan dia
Dim finOuterStartpt, finOuterEndpt
finOuterStartpt = "pt(" & trepan_od/2+.02+Sin(45*pi/180)*(.1) & ",0," & Cos(45*pi/180)*(.1+toolrad2*2) &")"
finOuterEndpt = "pt(" & trepan_od/2-.09-Sin(45*pi/180)*(toolrad2+.1) & ",0," & Cos(45*pi/180)*(.1+toolrad2*2) &")"
Dim finOuterCurveL As FMCurvePtList
Dim finOuterCurve As FMCurve
Set finOuterCurveL = doc.CreateCurvePtList
finOuterCurveL.AddPt(trepan_od/2+.02,0,0)
finOuterCurveL.AddPt(trepan_od/2,0,-.02)
finOuterCurveL.AddPt(trepan_od/2,0,-trepan_depth)
finOuterCurveL.AddPt(trepan_od/2-.09,0,-trepan_depth)
Set finOuterCurve = finOuterCurveL.AddCurveFromPtList(False)
Dim finBore As FMBore
Set finBore = doc.Features.AddBore(finOuterCurve,,,)
finBore.SetAttribute(eAID_DoRough,,False,False,)
finBore.Operations(1).SetAttribute(eAID_TurnStartPt,,finOuterStartpt,False,)
finBore.Operations(1).SetAttribute(eAID_TurnEndPt,,finOuterEndpt,False,)
finBore.Operations(1).OverrideSpeed(boresfm,)
finBore.Operations(1).OverrideFeed(.012,)
finBore.Operations(1).OverrideTool(boretool,)
finBore.Name = "fin_outer_trepan_dia"
Else
toolrad3 = .03
trepantool = ".250 w (.03 tnr) M/Cr Face"
trepanwidth = .25
'rough trepan
Dim rghEndpt As String
rghEndpt = "pt(" & trepan_id/2+.05+toolrad3 & ",0," & .1+toolrad3 &")"
Dim curveL As FMCurvePtList
Dim curve As FMCurve
Set curveL = doc.CreateCurvePtList
curveL.AddPt(trepan_od/2,0,0)
curveL.AddPt(trepan_od/2,0,-trepan_depth)
curveL.AddPt(trepan_id/2,0,-trepan_depth)
curveL.AddPt(trepan_id/2,0,0)
Set curve = curveL.AddCurveFromPtList(False)
Dim rghGroove As FMTurnGroove
Set rghGroove = doc.Features.AddProfileTurnGroove(rghCurve,,eGO_Face,,)
rghGroove.SetAttribute(eAID_DoFinish,,False,False,)
rghGroove.Operations(1).SetAttribute(eAID_TurnFinishXAllow,,.05,False,)
rghGroove.Operations(1).SetAttribute(eAID_TurnFinishZAllow,,.01,False,)
rghGroove.Operations(1).SetAttribute(eAID_TurnGrvRoughDOC,,5,,)
rghGroove.Operations(1).OverrideTool(trepantool,)
rghGroove.Operations(1).SetAttribute(eAID_TurnEndPt,,rghEndpt,False,)
rghGroove.Name = "rough_trepan"
'finish trepan
Dim finStartpt, finEndpt As String
finStartpt = "pt(" & trepan_id/2-.02+Sin(45*pi/180)*toolrad3 & ",0," & .1+toolrad3 &")"
finEndpt = "pt(" & trepan_id/2+.02+toolrad3 & ",0," & .1+toolrad3 &")"
Dim finCurveL As FMCurvePtList
Dim finCurve As FMCurve
Set finCurveL = doc.CreateCurvePtList
finCurveL.AddPt(trepan_od/2+.02,0,0)
finCurveL.AddPt(trepan_od/2,0,-.02)
finCurveL.AddPt(trepan_od/2,0,-trepan_depth)
finCurveL.AddPt(trepan_id/2,0,-trepan_depth)
finCurveL.AddPt(trepan_id/2,0,-.02)
finCurveL.AddPt(trepan_id/2-.02,0,0)
Set finCurve = finCurveL.AddCurveFromPtList(False)
Dim finGroove As FMTurnGroove
Set finGroove = doc.Features.AddProfileTurnGroove(finCurve,,eGO_Face,,)
finGroove.SetAttribute(eAID_DoRough,,False,False,)
finGroove.Operations(1).SetAttribute(eAID_TurnFinishLiftoffDist,,.02,,)
finGroove.Operations(1).OverrideSpeed(groovesfm,)
finGroove.Operations(1).OverrideFeed(grooveipr,)
finGroove.Operations(1).OverrideTool(trepantool,)
finGroove.Operations(1).SetAttribute(eAID_TurnStartPt,,finStartpt,False,)
finGroove.Operations(1).SetAttribute(eAID_TurnEndPt,,finEndpt,False,)
finGroove.Name = "finish_trepan"
End If
End Sub
Private Sub InitializeVars
If dlgmachine = "5222" Then
toolrad1 = .046
turntool = "CNMG 433"
If dlgmaterial = "Copper" Then
face_doc =.05
od_doc = .1
id_doc = .1
turnsfm = 1000
turnipr = .012
boresfm = 1000
boreipr = .012
groovesfm = 400
grooveipr = .004
ElseIf dlgmaterial = "HT Steel" Then
face_doc =.05
od_doc = .15
id_doc = .15
turnsfm = 350
turnipr = .012
boresfm = 350
boreipr = .012
groovesfm = 250
grooveipr = .004
Else
face_doc =.05
od_doc = .15
id_doc = .15
turnsfm = 600
turnipr = .012
boresfm = 600
boreipr = .012
groovesfm = 400
grooveipr = .004
End If
ElseIf dlgmachine = "5219" Then
toolrad1 = .046
turntool = "CNMG 433"
If dlgmaterial = "Copper" Then
face_doc =.05
od_doc = .1
id_doc = .1
turnsfm = 1000
turnipr = .012
boresfm = 1000
boreipr = .012
groovesfm = 400
grooveipr = .004
ElseIf dlgmaterial = "HT Steel" Then
face_doc =.05
od_doc = .18
id_doc = .18
turnsfm = 350
turnipr = .012
boresfm = 350
boreipr = .012
groovesfm = 250
grooveipr = .004
Else
face_doc =.05
od_doc = .18
id_doc = .18
turnsfm = 600
turnipr = .015
boresfm = 600
boreipr = .012
groovesfm = 400
grooveipr = .004
End If
ElseIf dlgmachine = "5230" Then
toolrad1 = .046
turntool = "CNMG 433"
If dlgmaterial = "Copper" Then
face_doc =.08
od_doc = .09
id_doc = .08
turnsfm = 1200
turnipr = .012
boresfm = 1200
boreipr = .012
groovesfm = 600
grooveipr = .004
ElseIf dlgmaterial = "HT Steel" Then
face_doc =.1
od_doc = .2
id_doc = .18
turnsfm = 350
turnipr = .015
boresfm = 350
boreipr = .015
groovesfm = 300
grooveipr = .003
ElseIf dlgmaterial = "4140" Then
face_doc =.1
od_doc = .2
id_doc = .18
turnsfm = 600
turnipr = .015
boresfm = 600
boreipr = .015
groovesfm = 400
grooveipr = .004
Else
face_doc =.1
od_doc = .2
id_doc = .18
turnsfm = 600
turnipr = .015
boresfm = 500
boreipr = .015
groovesfm = 500
grooveipr = .004
End If
ElseIf dlgmachine = "5506" Then
toolrad1 = .046
turntool = "CNMG 543"
toolrad2 = .046
boretool = "CNMG 543 Bore"
If dlgmaterial = "Copper" Then
face_doc =.08
od_doc = .09
id_doc = .08
turnsfm = 1200
turnipr = .012
boresfm = 1200
boreipr = .012
groovesfm = 600
grooveipr = .004
ElseIf dlgmaterial = "HT Steel" Then
face_doc =.15
od_doc = .15
id_doc = .15
turnsfm = 350
turnipr = .015
boresfm = 350
boreipr = .015
groovesfm = 300
grooveipr = .003
ElseIf dlgmaterial = "4140" Then
face_doc =.15
od_doc = .15
id_doc = .15
turnsfm = 500
turnipr = .015
boresfm = 500
boreipr = .015
groovesfm = 400
grooveipr = .004
Else
face_doc =.15
od_doc = .15
id_doc = .15
turnsfm = 600
turnipr = .018
boresfm = 600
boreipr = .018
groovesfm = 400
grooveipr = .004
End If
End If
If stock_id<3 Then
toolrad2 = .031
boretool = "BB-CNMG 432"
ElseIf optfeatures = 3 Then
toolrad2 = .031
boretool = "BB-CNMG 432"
Else
toolrad2 = .046
boretool = "BB-CNMG 433"
End If
If optfeatures = 1 Then
bore_allow = .015
Else
bore_allow = 0
End If
If optfeatures = 2 Then
bore_chfr = .08
Else
bore_chfr = .02
End If
End Sub
Private Sub InitializeDoc
Set app = ActiveDocument.Application
Set doc = Application.Documents.AddFM(eST_Turning,True)
Set doc = Application.ActiveDocument
Set stock = doc.Stock
doc.SetAttribute(eAID_TurnMinToolChange,,0,,)
'set config files, tool crib, and post options for each material and machine
If dlgmachine = "5219" And dlgmaterial = "1018 / Bronze" Then
app.SetTurnPostOptions( "\\ant-fs-01\departments\mfg-eng\cnc\FEATURECAM\5219\5219.cnc" )
doc.ActiveToolCrib = "5214"
app.SetTurnPostOptions(,10,5,30,10,2000)
Set config = Application.Configurations.Item("5214-1018")
If Not config Is Nothing Then
Application.Configurations.Item( doc.Name ).CopyConfiguration( config.Name )
Else
Application.Configurations.Import("\\ant-fs-01\departments\mfg-eng\cnc\FEATURECAM\5214\5214.cdb")
Application.Configurations.Item( doc.Name ).CopyConfiguration( config.Name )
MsgBox "Configuration file for 5214 has been copied to local directory"
End If
stock.Material = "5214-1018"
ElseIf dlgmachine = "5219" And dlgmaterial = "4140" Then
app.SetTurnPostOptions( "\\ant-fs-01\departments\mfg-eng\cnc\FEATURECAM\5219\5219.cnc" )
doc.ActiveToolCrib = "5214"
app.SetTurnPostOptions(,10,5,30,10,2000)
Set config = Application.Configurations.Item("5214-4140")
If Not config Is Nothing Then
Application.Configurations.Item( doc.Name ).CopyConfiguration( config.Name )
Else
Application.Configurations.Import("\\ant-fs-01\departments\mfg-eng\cnc\FEATURECAM\5214\5214.cdb")
Application.Configurations.Item( doc.Name ).CopyConfiguration( config.Name )
MsgBox "Configuration file for 5214 has been copied to local directory"
End If
stock.Material = "5214-4140"
ElseIf dlgmachine = "5219" And dlgmaterial = "HT Steel" Then
app.SetTurnPostOptions( "\\ant-fs-01\departments\mfg-eng\cnc\FEATURECAM\5219\5219.cnc" )
doc.ActiveToolCrib = "5214"
app.SetTurnPostOptions(,10,5,30,10,2000)
Set config = Application.Configurations.Item("5214-32-38RC")
If Not config Is Nothing Then
Application.Configurations.Item( doc.Name ).CopyConfiguration( config.Name )
Else
Application.Configurations.Import("\\ant-fs-01\departments\mfg-eng\cnc\FEATURECAM\5214\5214.cdb")
Application.Configurations.Item( doc.Name ).CopyConfiguration( config.Name )
MsgBox "Configuration file for 5214 has been copied to local directory"
End If
stock.Material = "5214-32-38RC"
ElseIf dlgmachine = "5219" And dlgmaterial = "Copper" Then
app.SetTurnPostOptions( "\\ant-fs-01\departments\mfg-eng\cnc\FEATURECAM\5219\5219.cnc" )
doc.ActiveToolCrib = "5214"
app.SetTurnPostOptions(,10,5,30,10,2000)
Set config = Application.Configurations.Item("5214-COP")
If Not config Is Nothing Then
Application.Configurations.Item( doc.Name ).CopyConfiguration( config.Name )
Else
Application.Configurations.Import("\\ant-fs-01\departments\mfg-eng\cnc\FEATURECAM\5214\5214.cdb")
Application.Configurations.Item( doc.Name ).CopyConfiguration( config.Name )
MsgBox "Configuration file for 5214 has been copied to local directory"
End If
stock.Material = "5214-COP"
ElseIf dlgmachine = "5222" And dlgmaterial = "1018 / Bronze" Then
app.SetTurnPostOptions( "\\ant-fs-01\departments\mfg-eng\cnc\FEATURECAM\5222\5222.cnc" )
doc.ActiveToolCrib = "5222"
app.SetTurnPostOptions(,10,5,30,10,2500)
Set config = Application.Configurations.Item("5222-1018")
If Not config Is Nothing Then
Application.Configurations.Item( doc.Name ).CopyConfiguration( config.Name )
Else
Application.Configurations.Import("\\ant-fs-01\departments\mfg-eng\cnc\FEATURECAM\5222\5222.cdb")
Application.Configurations.Item( doc.Name ).CopyConfiguration( config.Name )
MsgBox "Configuration file for 5222 has been copied to local directory"
End If
stock.Material = "5222-1018"
ElseIf dlgmachine = "5222" And dlgmaterial = "4140" Then
app.SetTurnPostOptions( "\\ant-fs-01\departments\mfg-eng\cnc\FEATURECAM\5222\5222.cnc" )
doc.ActiveToolCrib = "5222"
app.SetTurnPostOptions(,10,5,30,10,2500)
Set config = Application.Configurations.Item("5222-4140")
If Not config Is Nothing Then
Application.Configurations.Item( doc.Name ).CopyConfiguration( config.Name )
Else
Application.Configurations.Import("\\ant-fs-01\departments\mfg-eng\cnc\FEATURECAM\5222\5222.cdb")
Application.Configurations.Item( doc.Name ).CopyConfiguration( config.Name )
MsgBox "Configuration file for 5222 has been copied to local directory"
End If
stock.Material = "5222-4140"
ElseIf dlgmachine = "5222" And dlgmaterial = "HT Steel" Then
app.SetTurnPostOptions( "\\ant-fs-01\departments\mfg-eng\cnc\FEATURECAM\5222\5222.cnc" )
doc.ActiveToolCrib = "5222"
app.SetTurnPostOptions(,10,5,30,10,2500)
Set config = Application.Configurations.Item("5222-32-38RC")
If Not config Is Nothing Then
Application.Configurations.Item( doc.Name ).CopyConfiguration( config.Name )
Else
Application.Configurations.Import("\\ant-fs-01\departments\mfg-eng\cnc\FEATURECAM\5222\5222.cdb")
Application.Configurations.Item( doc.Name ).CopyConfiguration( config.Name )
MsgBox "Configuration file for 5222 has been copied to local directory"
End If
stock.Material = "5222-32-38RC"
ElseIf dlgmachine = "5222" And dlgmaterial = "Copper" Then
app.SetTurnPostOptions( "\\ant-fs-01\departments\mfg-eng\cnc\FEATURECAM\5222\5222.cnc" )
doc.ActiveToolCrib = "5222"
app.SetTurnPostOptions(,10,5,30,10,2500)
Set config = Application.Configurations.Item("5222-COP")
If Not config Is Nothing Then
Application.Configurations.Item( doc.Name ).CopyConfiguration( config.Name )
Else
Application.Configurations.Import("\\ant-fs-01\departments\mfg-eng\cnc\FEATURECAM\5222\5222.cdb")
Application.Configurations.Item( doc.Name ).CopyConfiguration( config.Name )
MsgBox "Configuration file for 5222 has been copied to local directory"
End If
stock.Material = "5222-COP"
ElseIf dlgmachine = "5230" And dlgmaterial = "1018 / Bronze" Then
app.SetTurnPostOptions( "\\ant-fs-01\departments\mfg-eng\cnc\FEATURECAM\5230\5230.cnc" )
doc.ActiveToolCrib = "5230"
app.SetTurnPostOptions(,10,5,32,10,350)