-
Notifications
You must be signed in to change notification settings - Fork 0
/
DocumentKarta_elektroda_v1.CATScript
3041 lines (2375 loc) · 79.8 KB
/
DocumentKarta_elektroda_v1.CATScript
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
'********************************************************************
'**** Skrypt wersja ****
'**** ****
'**** Skrypt do Catii utworzony przez Jakuba Hawro, generuje xls ****
'********************************************************************
Dim Language As String
Language = "VBScript"
'=============== USER DEFINED VARIABLES ==================
'=========================================================
Dim kododkowki, sciezka, nazwa_pliku As String
Dim kododkowki1, kododkowki2, img_oprawka As String
Dim nazwaprogramu, punktyzerowe, komentarzyk, maszyna As String
Dim rodzajobr, autor, nr_magazynu(20) As String
dim oprawka(20), nazwanarzedzia(20), gage1(20), gage2(20), ConeDiameter1(20), Diameter2(20), ostrza(20), Plytki(20) As String
dim NominalDiameter(20), CornerRadius(20), CuttingLength(20), LenghtL(20), OverallLength(20), BodyDiameter(20), komentarznarzedzia(100), komentarz(100) As String
dim liczba, cyfrafor as byte
dim czas_numer_narzedzia, test, oprawka_narzedzie, najwieksze_narzedzie as integer
dim czas(100), czas_narzedzia(100), czas_calkowity as integer
dim narzedzie_nr(20), oprawka_nr(20), operacje as integer
Dim numer_narzedzia(100) As Long
Dim nazwa_odkuwki, numer_oprz, drazenie, opis_elektrody as String
Dim wym1, wym2, wym3, indeks, ilosc_programow as integer
Dim Tabtest()
liczba=1
najwieksze_narzedzie = 0
operacje = 1
ilosc_programow = 1 'lizcnik arkuszy
'Tworzenie karty globalnie, zmienne dostêpne dla wszystkich programów
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = true
Set objWorkbook = objExcel.Workbooks.Add()
'=========================================================
' Default tool list documentation directory
'=========================================================
dim DefaultHtmlAppliName As String
'================= SYSTEM VARIABLES =======================
dim EOL As String ' Fin de ligne pour les fichiers textes
dim CRLF As String
dim PathSeparator as string
dim FolderSeparator as string
'==========================================================
'=========================================================
' Default Part Operation folder name
'=========================================================
dim PartOperationFolderName As String
'======================
' Test cession flag
'======================
Dim IsaTest As Boolean
Dim StdComponentsDir As String
Dim DefaultDocTarget, HtmlDefaultDocDir, HtmlFilesPath, CATIAComponentPath, HtmlFilesRoot As String
Dim fso As FileSystem
Dim IgnoredParameters()
Dim NbIgnoredParameters As Integer
Dim TabOutils()
Dim MaxTabOutils As Integer
Sub CATMain()
'------------------------------------------------------------------
' test Macro Atelier
' creation Juillet2000 : (kbb)
' lecture d'un modele
'------------------------------------------------------------------
DefineSeparators 'Definition des separateurs dans les paths
dim EnvVar,BidVar as String
Dim AdlOdtTmp, AdlOdtTmpPath, AdlOdtOut, AdlOdtOutPath, Slash As String
EnvVar = CATIA.SystemService.Environ("ADL_ODT_IN")
CATIA.SystemService.Print "ADL_ODT_IN =" & EnvVar
if (len(EnvVar)<10) then
BidVar = EnvVar
else
BidVar = Mid(EnvVar,1,10)
end if
IsaTest = False
HtmlFilesRoot = CreateHtmlFilesRoot
If (Not IsaTest) Then
DefaultDocTarget = HtmlFilesRoot 'Pourrait etre initialise autrement
DefaultHtmlAppliName = "MachiningDocument"
HtmlDefaultDocDir = DefaultDocTarget & DefaultHtmlAppliName
HtmlFilesPath = InputBox("Machining document directory", "Define directory", HtmlDefaultDocDir)
Else
HtmlFilesPath = AdlOdtOutPath
End If
If (HtmlFilesPath = "") Then
If (Not IsaTest) Then
MsgBox "Dokument nie stworzony", 4096 '(vbSystemModal)
Else
CATIA.SystemService.Print "No machining document created"
End If
Exit Sub
End If
Dim RootActivityName As String
RootActivityName = "Process"
'=========================================================
' Default tool list documentation name
'=========================================================
Dim DefaultHTMLFileName As String
DefaultHTMLFileName = "MfgMachining-Document"
On Error Resume Next
CATDocument RootActivityName, DefaultHTMLFileName, HtmlFilesPath
If (IsaTest) Then
Document1.Close
CATIA.Quit
End If
End Sub
'---------------------------------------------------------------
' Initialisation des variables dependantes du systeme
' ---------------------------------------------------
'---------------------------------------------------------------
Sub CreateSystemVariables()
'Definition des parametres qui seront ignores lors de
'l'affichage du tableau d'une resource
NbIgnoredParameters = 3
ReDim IgnoredParameters(NbIgnoredParameters)
IgnoredParameters(1) = "MFG_CONE_DIAMETER_2"
IgnoredParameters(2) = "MFG_CONE_LENGTH"
IgnoredParameters(3) = "MFG_MACHINE_COMP"
EOL = Chr(10)
CRLF = Chr(13) & Chr(10)
PartOperationFolderName = "PartOperation" 'Do usuniêcia wraz ze wszystkim
StdComponentsDir = "Images"
MaxTabOutils = -1
End Sub
'---------------------------------------------------------------
' Initialisation de la variable HtmlFilesRoot
' -------------------------------------------
'---------------------------------------------------------------
Function CreateHtmlFilesRoot()
Dim result As String
result = GetPath("CATStartupPath", "Manufacturing")
If (result = "") Then result = GetPath("TEMP","")
If (result <> "") Then
If (Mid(result, Len(result), 1) <> "\" And Mid(result, Len(result), 1) <> "/") Then result = result & FolderSeparator
End If
CreateHtmlFilesRoot = PathCleaner(result)
End Function
' ------------------------------------------------------
' Correspondance Parameter -> valeur NLS
' ------------------------------------------------------
Function ToNLS(anObj, aParameterName)
Dim erreur As Integer
Dim NLSresult As String
On Error Resume Next
Err.Clear
NLSresult = anObj.GetAttributeNLSName(aParameterName)
erreur = Err.Number
If (erreur <> 0 Or NLSresult = "") Then NLSresult = aParameterName
ToNLS = NLSresult
End Function
' ------------------------------------------------------
' Copie d'un fichier
' Retourne : 0 -> pas d'erreur
' 1 -> source absent
' 2 -> destination existe et overwrite=False
' 3 -> autre erreur
' ------------------------------------------------------
Function FileCopy(source, destination, overwrite)
Dim erreur As Integer
Dim ReturnedVal As Integer
returned = 0
If (Not (fso.FileExists(source))) Then
ReturnedVal = 1
Else
If (fso.FileExists(destination) And (Not overwrite)) Then
ReturnedVal = 2
Else
On Error Resume Next
Err.Clear
fso.CopyFile source, destination, overwrite
erreur = Err.Number
If (erreur <> 0) Then ReturnedVal = 3
End If
End If
FileCopy = ReturnedVal
End Function
'----------------------------------------------
' Ajout d'une ligne dans un tableau 2 colonnes
' NOM_DU_PARAMETRE - VALEUR_DU_PARAMETRE
'---------------------------------------------- Parametry narzêdzi
Sub AddParameterToTable(anObj, aParam, aStream, AcceptComment)
Dim erreur As Integer
If (Not AcceptComment And aParam = "MFG_COMMENT") Then Exit Sub 'bardzo wa¿ne
Dim anAttribute As AnyObject
'liczba=liczba+1
On Error Resume Next
Err.Clear
Set anAttribute = anObj.getAttribute(aParam)
erreur = Err.Number
'ToNLS(anObj, aParam) & ToNLS(anObj, AttrVal)
dim nr_nazwanarzedzia, nr_gage1, nr_oprawka, nr_gage2, nr_ConeDiameter1, nr_Diameter2, nr_ostrza, nr_NominalDiameter, nr_CornerRadius, nr_CuttingLength, nr_LenghtL, nr_OverallLength, nr_BodyDiameter, nr_oprawka_nr, nr_narzedzie_nr, nr_nr_magazynu as integer
'if (przyrzad = "MFG_NAME") Then
'oprawka(1) = przyrzad'anObj.getAttribute(aParam).ValueAsString
'End if
'KONIEC
If (erreur <> 0) Then
Err.Clear
Set anAttribute = anObj.getAttribute(aParam & "_MODE")
erreur = Err.Number
If (erreur = 0) Then
AttrVal = anAttribute.ValueAsString
erreur = Err.Number
If (erreur = 0 And AttrVal <> "") Then
End If
End If
Err.Clear
Set anAttribute = anObj.getAttribute(aParam & "_VALUE")
erreur = Err.Number
If (erreur = 0) Then
AttrVal = anAttribute.ValueAsString
erreur = Err.Number
If (erreur = 0 And AttrVal <> "") Then
End If
End If
End If
End Sub
'--------------------------------------------------------------------
' Main Procedure
'--------------------------------------------------------------------
Sub CATDocument(RootActivityName, HtmlFilesName, FilesPath)
dim erreur As Integer
dim EnvVar,BidVar as String
if (PathSeparator="") then DefineSeparators 'Definition des separateurs dans les paths
EnvVar = CATIA.SystemService.Environ("ADL_ODT_IN")
CATIA.SystemService.Print "ADL_ODT_IN =" & EnvVar
if (len(EnvVar)<10) then
BidVar = EnvVar
else
BidVar = Mid(EnvVar,1,10)
end if
IsaTest = FALSE
Set fso = CATIA.FileSystem
CreateSystemVariables
HtmlFilesPath = FilesPath
sciezka = HtmlFilesPath
nazwa_pliku = HtmlFilesName
Dim DeleteDirPrompt As String
Dim L As Integer
L = Len(HtmlFilesPath)
If (Mid(HtmlFilesPath, L, 1) <> "\" And Mid(HtmlFilesPath, L, 1) <> "/") Then HtmlFilesPath = HtmlFilesPath & FolderSeparator
HtmlFilesPath = HtmlFilesPath '& HtmlFilesName
L = Len(HtmlFilesPath)
If (Mid(HtmlFilesPath, L, 1) = "\" Or Mid(HtmlFilesPath, L, 1) = "/") Then HtmlFilesPath = Mid(HtmlFilesPath, 1, L - 1)
On Error Resume Next
If (Not fso.FolderExists(HtmlFilesPath)) Then
Err.Clear
fso.CreateFolder (HtmlFilesPath)
erreur = Err.Number
If (erreur <> 0) Then
If (Not IsaTest) Then
MsgBox HtmlFilesPath & CRLF & CRLF & "B³¹d tworzenia folderu!", 4144 '(vbSystemModal+vbExclamation)
Else
CATIA.SystemService.Print HtmlFilesPath & " : Error creating folder"
End If
On Error GoTo 0
Err.Raise erreur
End If
End If
HtmlFilesPath = HtmlFilesPath & FolderSeparator
CATIAComponentPath = CreateHtmlFilesRoot & StdComponentsDir & FolderSeparator
'Dim OutIndex As String
'OutIndex = HtmlFilesName & ".html" 'jak zapisaæ kartê KT brane z Catii
MachiningDocument_CreateHtmlFile OutIndex, RootActivityName
End Sub
Sub MachiningDocument_CreateHtmlFile(OutIndex, RootActivityName)
'---------------------------------------------------------------
' Retrieve the active document
'---------------------------------------------------------------
Dim MfgDoc1 As Document
Set MfgDoc1 = CATIA.ActiveDocument
Dim ProgramList As MfgActivities
Dim ActivityList As MfgActivities
Dim NumberOfProgram As Integer
Dim NumberOfActivity As Integer
Dim i As Integer
Dim J As Integer
Dim K As Integer
Dim SetupName As String
Dim ProgramName As String
Dim ActivityName As String
Dim CurrentSetup As ManufacturingActivity
Dim CurrentProgram As ManufacturingActivity
Dim CurrentActivity As ManufacturingActivity
Dim CurrentTool As ManufacturingTool
Dim ActivityType As String
Dim CurrentAssembly As ManufacturingToolAssembly
Dim AssemblyNumber as Long
Dim childs As Activities
Dim child As Activity
Dim quantity As Integer
Dim aProcess As AnyObject
Dim ToolNumber As Long
Dim ToolName As Variant
Dim CurrAct As Integer
Dim erreur As Integer
Set aProcess = MfgDoc1.GetItem(RootActivityName)
Dim myWindow As window
Dim myViewer As Viewer
Dim myOldLayout As CatSpecsAndGeomWindowLayout
Dim WindowW, WindowH As Integer
On Error Resume Next
Err.Clear
'-----------------
' Scan the Process
'-----------------
quantity = 0
If (aProcess.IsSubTypeOf("PhysicalActivity")) Then
Set childs = aProcess.ChildrenActivities
quantity = childs.Count
If quantity <= 0 Then
Exit Sub
End If
Dim TabToolName()
Dim MaxToolNb As Integer
MaxToolNb = 0
'Redim TabToolName (MaxToolNb)
Dim PartOpeFolderName As String
If quantity > 2 Then 'Tworzy arkusze
For i = 1 To (quantity - 6) step 1
objWorkbook.Sheets.Add
Next
End if
For i = 1 To quantity
Set child = childs.Item(i)
If (child.IsSubTypeOf("ManufacturingSetup")) Then
For toolnb = 1 To MaxToolNb
TabToolName(toolnb) = ""
Next
CurrPONb = CurrPONb + 1
CurrAct = 0
Set CurrentSetup = child
CreatePartOperationSheet CurrentSetup, CurrPONb, MfgDoc1.Name
SetupName = CurrentSetup.Name
kododkowki = SetupName
kododkowki1 = Left(kododkowki,6)
kododkowki2 = Right(kododkowki,4)
On Error Resume Next
erreur = Err.Number
If (erreur <> 0) Then Err.Clear
'---------------------------------------------------------------
' Read the Programs of the current Setup
'---------------------------------------------------------------
Set ProgramList = CurrentSetup.Programs
NumberOfProgram = ProgramList.Count
For ProgNb = 1 To NumberOfProgram
ProgCuttingTime = 0
ProgTotalTime = 0
'For j = 0 to 100 step 1
' czas(j) = NULL
'Next
Set CurrentProgram = ProgramList.GetElement(ProgNb)
ProgramName = CurrentProgram.Name
nazwaprogramu = ProgramName
rodzajobr = CurrentProgram.Comment
czas_calkowity = 0
Erase czas
'---------------------------------------------------------------
' Read the Activities of the current Program
'---------------------------------------------------------------
Set ActivityList = CurrentProgram.Activities
NumberOfActivity = ActivityList.Count
On Error Resume Next
For ActNb = 1 To NumberOfActivity
CurrAct = CurrAct + 1
Set CurrentActivity = ActivityList.GetElement(ActNb)
ActivityName = CurrentActivity.Name
ActivityType = CurrentActivity.Type
If (ActivityType <> "ToolChange" AND ActivityType <> "ToolChangeLathe") Then
Dim currcor, ncorr, ncorrl, diam As Variant
Dim corrtype As String
Dim pAtt As Parameter
Err.Clear
Set pAtt = CurrentActivity.getAttribute("CompNumber")
erreur = Err.Number
If (erreur = 0) Then
ncorr = pAtt.Value
erreur = Err.Number
If (erreur = 0) Then
Set CurrentTool = CurrentActivity.Tool
ToolNumber = CurrentTool.ToolNumber
Dim NbCorr As Integer
NbCorr = CurrentTool.CorrectorCount
if(NbCorr>0) then
Dim aCorr As ManufacturingToolCorrector
Dim CorrNumber, CorrLengthNumber As Integer
Dim CorrDiameter As Variant
currcor = 0
Do
currcor = currcor + 1
Set aCorr = CurrentTool.GetCorrector(currcor)
CorrNumber = aCorr.Number
If (CorrNumber = ncorr) Then
corrtype = aCorr.Point
ncorrl = aCorr.LengthNumber
diam = aCorr.Diameter
ToolType = CurrentTool.ToolType
ToolName = CurrentTool.Name
MajTabOutils ToolNumber, ncorr, ncorrl, diam, corrtype, ToolType, ToolName
Exit Do
End If
If (currcor = NbCorr) Then Exit Do
Loop
End If
End If
End If
End If
CreateFicheOpe CurrentActivity, CurrPONb, CurrAct, MfgDoc1.Name, SetupName, ProgramName 'SKUPIÆ SIÊ TU!
'czas = 1+CurrAct
Err.Clear
aTime = CurrentActivity.MachiningTime
if(Err.Number=0) then ProgCuttingTime = ProgCuttingTime+aTime
Err.Clear
aTime = CurrentActivity.TotalTime
if(Err.Number=0) then ProgTotalTime = ProgTotalTime+aTime
'czas_calkowity=ProgTotalTime
Next
CreateToolList MfgDoc1.Name, CurrentSetup, CurrPONb
'(1) = ToHMS(ProgTotalTime)
komunikat
plikKT
Next
CompleteToolCompSheets CurrPONb, TabOutils, MaxTabOutils
Erase TabOutils
MaxTabOutils = -1
End If
liczba=1
najwieksze_narzedzie = 0
operacje = 1
Next
CreateToolAssocOpe childs
CreateAssemblyAssocOpe childs
End If
Dim OpenDocNow As Integer
Dim EndOfGenerationTxt As String
If (Not IsaTest) Then
dim theCATCommandPath as String
dim theHTMLBrowserCmd as String
theCATCommandPath = GetPath("CATCommandPath","")
if(FolderSeparator="\") then
theHTMLBrowserCmd = theCATCommandPath & "broURL.bat"
else
theHTMLBrowserCmd = theCATCommandPath & "broURL.sh"
end if
'EndOfGenerationTxt = "Karta technologiczna : KT.html" & CRLF & "Zapisana w: " & HtmlFilesPath & CRLF & "Otworzyæ dokument teraz?"
'EndOfGenerationTxt = EndOfGenerationTxt & CRLF & CRLF & "Jeli przegl¹darka siê nie otwiera, zawo³aj Hawranka "
'OpenDocNow = MsgBox(EndOfGenerationTxt, 4100) '(vbSystemModal+vbYesNo)
If (OpenDocNow = 6) Then '6->vbYes
Dim CmdLine As String
If (FolderSeparator = "\") Then
' Windows OSes only :
' Do a copy of broURL.bat to avoid the problem of
' space characters in the path.
Dim strTEMP As String
strTEMP = GetPath("TEMP","")
'MsgBox "strTEMP:" & strTEMP
Dim intRep As Integer
Dim strTarget As String
strTarget = strTEMP & "broURL.bat"
intRep = FileCopy(theHTMLBrowserCmd , strTarget, True)
If (intRep = 0) Then
' It seams to work.
' Let's replace the path.
theHTMLBrowserCmd = strTarget
End If
End If
CmdLine = theHTMLBrowserCmd & " " & HtmlFilesPath & "KT.html"
'MsgBox "CmdLine:" & CmdLine
On Error Resume Next
CATIA.SystemService.ExecuteBackgroundProcessus (CmdLine)
erreur = Err.Number
If (erreur <> 0) Then
MsgBox "Error while opening HTML editor", 4096 '(vbSystemModal)
end if
End If
Else
CATIA.SystemService.Print "Karta tech : " & OutIndex & " " & "Stworzona w: " & HtmlFilesPath
End If
'If nazwa_odkuwki = "" Then 'Monitoruje, czy u¿ytkownik wprowadzi³ ju¿ wczeniej dane
' komunikat
'End If
'plikKT 'Wywo³anie_tworzenia_karty
komunikat_koncowy()
'Clear_All_Files_And_SubFolders_In_Folder 'usuwanie_folderów
End Sub
'---------------------------------------------------------------
' Composant "Changement d'outil"
'---------------------------------------------------------------
Sub CreateToolChangeSum(anOpe, OpeStream, PONb, OpeNb)
Dim ImgName As String
Dim aTool As ManufacturingTool
Dim ToolNumber As Variant
Dim OpeType, OpeName, ToolName, ToolType As String
Dim ToolDiameter As Variant
Dim Attribut As Parameter
Dim erreur, AssemblyError As Integer
Dim AssemblyNumber As Long
Dim AssemblyType, AssemblyName As String
Dim CurrentAssembly As ManufacturingToolAssembly
OpeName = anOpe.Name
OpeType = anOpe.Type
Set aTool = anOpe.Tool
ToolNumber = aTool.ToolNumber
ToolName = aTool.Name
ToolType = aTool.ToolType 'typ narzêdzia
'czas_numer_narzedzia=ToolNumber
On Error Resume Next
set CurrentAssembly = NOTHING
AssemblyNumber = 0
Set CurrentAssembly = anOpe.ToolAssembly
Err.Clear
AssemblyNumber = CurrentAssembly.ToolNumber
AssemblyError = Err.Number
Err.Clear
If (AssemblyError = 0) Then
AssemblyType = CurrentAssembly.AssemblyType
Set Attribut = CurrentAssembly.getAttribute("MFG_NAME")
erreur = Err.Number
If (erreur = 0) Then AssemblyName = Attribut.Value
Err.Clear
If (AssemblyType = "MfgLatheToolAssembly") Then
Dim anInsert As ManufacturingInsert
Dim InsertName, InsertType As String
Err.Clear
Set anInsert = anAssembly.Insert
erreur = Err.Number
If (erreur = 0) Then
Set Attribut = anInsert.getAttribute("MFG_NAME")
erreur = Err.Number
If (erreur = 0) Then
InsertName = Attribut.Value
If (InsertName <> "") Then
InsertType = anInsert.InsertType
End If
End If
End If
End If
End If
End Sub
'---------------------------------------------------------------
' Composant "PPInstruction"
'---------------------------------------------------------------
Sub CreatePPInstructionSum(anOpe, OpeStream, PONb, OpeNb)
Dim OpeType, OpeName As String
OpeName = anOpe.Name
OpeType = anOpe.Type
Dim OpeImageName As String
OpeImageName = GetOperationImage(anOpe, PONb, TRUE)
End Sub
'---------------------------------------------------------------
' Composant "Coordinate System"
'---------------------------------------------------------------
Sub CreateCoordinateSystemSum(anOpe, OpeStream, PONb, OpeNb)
Dim OpeType, OpeName As String
OpeName = anOpe.Name
OpeType = anOpe.Type
Dim OpeImageName As String
OpeImageName = GetOperationImage(anOpe, PONb, TRUE)
End Sub
'---------------------------------------------------------------
' Composant "Rotation plateau"
'---------------------------------------------------------------
Sub CreateRotationSum(anOpe, OpeStream, PONb, OpeNb)
Dim OpeType, OpeName As String
Dim pRotAng As Parameter
Dim RotAng As Variant
OpeName = anOpe.Name
OpeType = anOpe.Type
Dim OpeImageName As String
OpeImageName = GetOperationImage(anOpe, PONb, TRUE)
Set pRotAng = anOpe.getAttribute("MFG_ROTARY_ANGLE")
RotAng = pRotAng.ValueAsString
End Sub
'---------------------------------------------------------------
' Composant "Cycle"
'---------------------------------------------------------------
Sub CreateCycleSum(anOpe, OpeStream, PONb, OpeNb)
Dim erreur As Integer
Dim OpeType, OpeName As String
Dim OpeImageName As String
OpeImageName = GetOperationImage(anOpe, PONb, TRUE)
OpeName = anOpe.Name
OpeType = anOpe.Type
Dim CurrentAssembly As ManufacturingToolAssembly
Dim aTool As ManufacturingTool
Dim AssemblyNumber, ToolNumber As Long
Dim AssemblyName, AssemblyType As String
Dim ToolName, ToolType As String
Set aTool = anOpe.Tool
ToolName = aTool.Name
ToolType = aTool.ToolType
On Error Resume Next
Err.Clear
Set CurrentAssembly = anOpe.ToolAssembly
AssemblyNumber = CurrentAssembly.ToolNumber
erreur = Err.Number
If (erreur = 0) Then
AssemblyType = CurrentAssembly.AssemblyType
Set Attribut = CurrentAssembly.getAttribute("MFG_NAME")
erreur = Err.Number
If (erreur = 0) Then AssemblyName = Attribut.Value
Err.Clear
If (AssemblyType = "MfgLatheToolAssembly") Then
Dim anInsert As ManufacturingInsert
Dim InsertName, InsertType As String
Err.Clear
Set anInsert = CurrentAssembly.Insert
erreur = Err.Number
If (erreur = 0) Then
Set Attribut = anInsert.getAttribute("MFG_NAME")
erreur = Err.Number
If (erreur = 0) Then
InsertName = Attribut.Value
If (InsertName <> "") Then
InsertType = anInsert.InsertType
End If
End If
End If
End If
Else
ToolNumber = aTool.ToolNumber
End If
End Sub
'**********************************************************
' Creation d'une fiche "cycle"
'**********************************************************
Sub CreateFicheOpe(anOpe, PONb, OpeNb, aProcessName, aPOName, aProgName) 'Niezbêdne do wywo³ania czasów
WriteOpeFileHeader anOpe, aProcessName, aPOName, PONb, aProgName, OpeStream
WriteOperationParameters anOpe, OpeStream
End Sub
Sub WriteOpeFileHeader(anOpe, aProcessName, aPOName, aPONumber, aProgName, OpeStream)
Dim erreur As Integer
OpeType = anOpe.Type
Dim OpeImageName As String
If (OpeType <> "ToolChange" AND OpeType <> "ToolChangeLathe") Then
OpeImageName = GetOperationImage(anOpe, aPONumber, FALSE)
Else
Dim CurrentAssembly As ManufacturingToolAssembly
Dim aTool As ManufacturingTool
Dim ImgName, AssemblyName As String
Dim AssemblyNumber As Long
Dim AssemblyError as Integer
Dim Attribut as Parameter
On Error Resume Next
set CurrentAssembly = NOTHING
AssemblyNumber = 0
Err.Clear
Set CurrentAssembly = anOpe.ToolAssembly
AssemblyNumber = CurrentAssembly.ToolNumber
'czas_numer_narzedzia = AssemblyNumber
'w razie jakby nie by³o oprawek
Dim ToolNumber As Variant
Set aTool = anOpe.Tool
ToolNumber = aTool.ToolNumber
'If AssemblyNumber = 0 Then
czas_numer_narzedzia=ToolNumber
'End If
AssemblyError = Err.Number
Err.Clear
ImgName = GetToolImage(aTool, aPONumber, False)
Dim DiameterId As String
If (aTool.ToolType = "MfgAPTTool") Then
DiameterId = "MFG_APT_DIAMETER"
Else
DiameterId = "MFG_NOMINAL_DIAM"
End If
Err.Clear
Set DiameterAttribut = aTool.getAttribute(DiameterId)
erreur = Err.Number
If (erreur = 0) Then
ToolDiameter = DiameterAttribut.ValueAsString
erreur = Err.Number
End If
End If
Dim OpeComment As String
OpeComment = anOpe.Description
End Sub
'---------------------------------------------------------------
' Ecriture des tableaux de parametres pour chaque type de cycle
'---------------------------------------------------------------
'CZASY!
Sub WriteOperationParameters(anOpe, OpeStream)
OpeType = anOpe.Type
Select Case OpeType
Case "ToolChange"
WriteToolChangeParameters anOpe, OpeStream
test = test +1 'iloæ_wywo³añ_narzêdzi
Case "ToolChangeLathe"
WriteToolChangeParameters anOpe, OpeStream
Case "TableHeadRotation"
WriteTableHeadRotationParameters anOpe, OpeStream
Case "CoordinateSystem"
WriteCoordinateSystemParameters anOpe, OpeStream
Case "PPInstruction"
WritePPInstructionParameters anOpe, OpeStream
Case Else
WriteCycleParameters anOpe, OpeStream
End Select
'test = test +1 iloæ_operacji+iloæ_wywo³añ narzêdzi
End Sub
Sub WriteCycleParameters(anOpe, OpeStream)
AddCycleMachiningTime anOpe, OpeStream
'test = test +1 iloæ_operacji
End Sub
Sub WriteToolChangeParameters(anOpe, OpeStream)
Dim erreur As Integer
Dim pPPInstr As Parameter
Dim PPInstr As String
PPInstr = ""
On Error Resume Next
Err.Clear
Set pPPInstr = anOpe.getAttribute("MFG_PPWORDS")
erreur = Err.Number
If (erreur = 0) Then
PPInstr = pPPInstr.Value
Else
Err.Clear
End If
End Sub
Sub WriteTableHeadRotationParameters(anOpe, OpeStream)
Dim erreur As Integer
Dim pPPInstr As Parameter
Dim PPInstr As String
PPInstr = ""
On Error Resume Next
Err.Clear
Set pPPInstr = anOpe.getAttribute("MFG_PPWORDS")
erreur = Err.Number
If (erreur = 0) Then
PPInstr = pPPInstr.Value
End If
'AddParameterToTable anOpe, "MFG_ROTARY_ANGLE", OpeStream, False
'AddParameterToTable anOpe, "MFG_ROT_DIR", OpeStream, False
'AddParameterToTable anOpe, "MFG_ROT_TYP", OpeStream, False
End Sub
Sub WriteCoordinateSystemParameters(anOpe, OpeStream)
Dim erreur As Integer
Dim pPPInstr As Parameter
Dim PPInstr As String