· 8 years ago · Feb 19, 2018, 10:54 AM
1
2
3
4Option Explicit
5Dim DrwDocument As DrawingDocument
6Dim DrwSheets As DrawingSheets
7Dim DrwSheet 'As DrawingSheet - Necessary for the reorder script
8Dim DrwView As DrawingView
9Dim DrwTexts As DrawingTexts
10Dim Selection 'As selection
11Dim Fact As Factory2D
12Dim Line As Line2D
13Dim GeomElems
14Dim Text As DrawingText
15Dim ChosenSize As String
16Dim ChosenTol As String
17
18Dim whichSheet As String
19Dim whichView As String
20Dim displayFormat As String
21
22Dim Height As Double 'Paper Height
23Dim Width As Double 'Paper Width
24Dim sheetformat As CatPaperSize 'Sheet format as integer value
25
26Dim Ypos As Double
27
28Dim AddDotRevision As Boolean
29Dim RevBlockText As String
30
31Dim Description As String
32Dim TitleDrwName As String
33
34Dim NumbRevLines As Double
35
36Dim CurrentTolSetting As String
37Dim SelectedToleranceSetting As String
38
39Dim RevisionModification As Boolean
40
41Dim NumberOfGenerativeViews As Integer
42
43Dim ProductDrawn As Product
44Dim ProductDrawnMass As Product
45
46Dim FormInitialisation As Boolean
47
48Dim ReadProcessBoxAndNotes As Boolean
49Dim ReadNotes As Boolean
50Dim ReadLayup As Boolean
51
52Dim InfoGeneral As Boolean
53Dim InfoRevision As Boolean
54Dim InfoMass As Boolean
55
56Dim PointedDocIsPVR As Boolean
57
58Dim RevisionCanBeAdded As Boolean
59Dim FirstViewCanBeUpdated As Boolean
60Dim MassCanBeUpdated As Boolean
61Dim CheckersInitialsFound As Boolean
62
63Dim SpinButtonChange As Boolean
64Dim ActiveSheetNumber As Integer
65
66Dim MassManualCanBeAdded As Boolean
67
68Dim CheckersInitialsFile As String
69
70Dim CapturedRevisions() As Variant
71
72Dim DrawnInitialsAreOk As Boolean
73Dim CheckersInitialsAreOk As Boolean
74Dim PhoneNumberIsOk As Boolean
75
76Dim CalculateProductMass As Boolean
77
78Dim BoundingBoxTableExists As Boolean
79Dim WetSurfaceAreaExists As Boolean
80
81Dim TextBoxCheckersInitialsIsBeingChanged As Boolean
82
83Dim DrawingBorderCurrentVersion As String
84
85Const DrawingBorderNewVersion = "02"
86
87Const RevisionBlockHeight = 5
88Const RevisionBlockColumn0 = 0
89Const RevisionBlockColumn1 = 11
90Const RevisionBlockColumn2 = 138.5
91Const RevisionBlockColumn3 = 150.5
92Const RevisionBlockColumn4 = 162.5
93Const RevisionBlockColumn5 = 180
94
95Const FormHeightSmall = 548
96Const FormHeightLarge = 590
97
98
99Private Sub CommandChangeRefToVer01_Click()
100 On Error Resume Next
101 Dim MyReferenceText As DrawingText
102 InitBackgroundView
103 Set MyReferenceText = DrwTexts.GetItem("Reference_02")
104 MyReferenceText.Name = "Reference_HRFTEST"
105 'Update the Drawing Border Form to display the drawing border version
106 DrawingBorderCurrentVersion = "01"
107 UpdateDrawingBorderExistVersion (DrawingBorderCurrentVersion)
108End Sub
109
110Private Sub UserForm_Initialize()
111 Dim EnvV5UserSettingsDir As String
112
113 'This flag is used to prevent the CommandsControlsEnabledState and CreateOrModifyModeCheck scripts running multiple times on start-up
114 FormInitialisation = True
115
116 'Required for 64Bit to be able to update whats behind the screen
117 CATIA.RefreshDisplay = True
118
119 '#### V5R24 #### ProgressBarDrawingBorder.Visible = False
120 CalculateProductMass = False
121
122 CheckersInitialsFile = CATIA.SystemService.Environ("CATUserSettingPath") & "\DrawingBorderCheckersInitials.txt"
123
124 Dim PLMScriptsDir As String
125 PLMScriptsDir = CATIA.SystemService.Environ("PLMScriptsDir")
126 Dim PLMEnvironment As String
127 PLMEnvironment = CATIA.SystemService.Environ("PLMEnvironment")
128
129 TitleDrwName = PLMScriptsDir & "\Environment\" & PLMEnvironment & "\AppsData\Drawing\"
130
131 'Check to see if the drawing is active
132 CheckDrawingIsActive
133 'Read the checkers Initials that the user last typed in
134 ReadCheckerInitials
135 'Set the main objects, Drawing, sheets, activesheet
136 InitialiseObjects
137 'Check the sheets that are on the drawing and update the spin button accordingly
138 UpdateSheetInfoAndGenerativeViews
139 'Extract the user information
140 ExtractUserInfo
141
142 FormInitialisation = False
143 'Enable/disable commands/controls dependent upon whether
144 'a drawing border exists and contains Generative View/s
145 CommandsControlsEnabledState
146End Sub
147Private Sub EnableRevisionModAdd()
148 CheckRevisionDescription
149 CommandDescriptionCancel.Enabled = True
150End Sub
151Private Sub ReadCheckerInitials()
152 Dim X As String
153
154 'Check the file is found
155 If checkFileExists(CheckersInitialsFile) Then
156 CheckerGood
157
158 Open CheckersInitialsFile For Input Access Read As 1
159 Line Input #1, X
160 TextBoxCheckersInitials.Text = X
161 'Close file
162 Close 1
163 Else
164 CheckerWarning
165 End If
166End Sub
167Private Sub TextBoxCheckersInitials_Change()
168 'Need to do this as the changing the text to upper case causes a change as well
169 'This prevents the code below running twice
170 If TextBoxCheckersInitialsIsBeingChanged = False Then
171 TextBoxCheckersInitialsIsBeingChanged = True
172 TextBoxCheckersInitials.Text = UCase(TextBoxCheckersInitials.Text)
173
174 If FormInitialisation = False Then
175 DisableMainDrawingFormCommands
176 End If
177
178 ResetInformationGeneral
179 'Make sure the user puts in at least 2 characters
180 If Len(TextBoxCheckersInitials) > 1 Then
181 CheckerGood
182 WriteCheckersInitials
183 Else
184 'Warn User it must be 3 characters
185 CheckerWarning
186 End If
187 If FormInitialisation = False Then
188 CommandsControlsEnabledState
189 TextBoxCheckersInitials.SetFocus
190 End If
191 TextBoxCheckersInitialsIsBeingChanged = False
192 End If
193End Sub
194Private Sub CheckerWarning()
195 CheckersInitialsAreOk = False
196 'Warn User it must be 3 characters
197 TextBoxCheckersInitials.BackColor = &HC0C0FF
198 CheckersInitialsFound = False
199End Sub
200Private Sub CheckerGood()
201 CheckersInitialsAreOk = True
202 'Warn User it must be 3 characters
203 TextBoxCheckersInitials.BackColor = &HC0FFFF
204 CheckersInitialsFound = True
205End Sub
206Private Sub WriteCheckersInitials()
207 'Writes a file to a specified directory
208
209 Dim objFSO As Object
210 Dim objTextStream
211
212 Set objFSO = CreateObject("Scripting.FileSystemObject")
213 On Error Resume Next
214 Set objTextStream = objFSO.OpenTextFile(CheckersInitialsFile, 2, True)
215 If Err.Number <> 0 Then
216 TextBoxInfoGeneral ("Cannot write the Process Department file which stores the default department for the user to the following directory:" & vbCrLf & _
217 CheckersInitialsFile)
218 End If
219 'Write Notes Department
220 objTextStream.WriteLine (TextBoxCheckersInitials.Text)
221
222 objTextStream.Close
223 On Error GoTo 0
224 Set objFSO = Nothing
225End Sub
226Private Sub ExtractUserInfo()
227 Dim Arr As Variant
228
229 PhoneNumberIsOk = True
230 DrawnInitialsAreOk = True
231
232 'Extract info from LDAP, arr(0) = Initials, arr(1) = telephone, arr(2) = e-mail, arr(3) = First Name, arr(4) = Surname
233 Arr = Split(getUserInfo(CATIA.SystemService.Environ("username")), "|")
234
235 TextBoxDate.Text = CATmyDateTimeFormat(Date)
236 TextBoxRevisionDrawnInitials.Text = Arr(0)
237 TextBoxPhoneNumber.Text = Arr(1)
238 TextBoxEmail.Text = Arr(2)
239 TextBoxDrawn.Text = UCase(Left(Arr(3), 1)) & " " & UCase(Arr(4))
240
241 CheckDrawnInitialsAreOk
242 CheckPhoneNumberIsOk
243End Sub
244Private Sub CheckDrawnInitialsAreOk()
245 'If No initials defined
246 If Len(TextBoxRevisionDrawnInitials.Text) = 0 Then
247 TextBoxRevisionDrawnInitials.BackColor = &HC0C0FF
248 DrawnInitialsAreOk = False
249 End If
250End Sub
251Private Sub CheckPhoneNumberIsOk()
252 'Check the Telephone extension
253 If TextBoxPhoneNumber.Text = "" Then
254 TextBoxPhoneNumber.BackColor = &HC0C0FF
255 PhoneNumberIsOk = False
256 End If
257End Sub
258Private Sub MultiPageDrawingBorderCommands_Change()
259 CommandDummyForFocus.SetFocus
260End Sub
261Private Sub MultiPageInfo_Click(ByVal Index As Long)
262 ChangeDrawingBorderTabsDisplay
263End Sub
264Private Sub ChangeDrawingBorderTabsDisplay()
265 If FormInitialisation = False Then
266 'Activate Corresponding page containing controls - e.g. Border (Auto) & Revisions
267 If MultiPageInfo.Value = 0 Or MultiPageInfo.Value = 2 Then
268 MultiPageDrawingBorderCommands.Value = 0
269 ElseIf MultiPageInfo.Value = 1 Then
270 MultiPageDrawingBorderCommands.Value = 3
271 End If
272
273 CommandDummyForFocus.SetFocus
274 End If
275End Sub
276Private Sub CheckForGenerativeViews()
277 Dim i As Integer
278
279 ComboBoxProductDrawnView.Clear
280 ComboBoxProductDrawnViewMass.Clear
281
282 NumberOfGenerativeViews = 0
283
284 'Set the part, product or scene from which to extract the various parameters
285 'Search for views with a generative link, once found check the relationship
286 'Start at i = 2 as we have the main & background view
287 i = 2
288
289 While (i < DrwSheet.Views.Count)
290 i = i + 1
291 If (DrwSheet.Views.Item(i).IsGenerative = 1) Then
292 NumberOfGenerativeViews = NumberOfGenerativeViews + 1
293 ComboBoxProductDrawnView.AddItem "[" & i & "] " & DrwSheet.Views.Item(i).Name
294 ComboBoxProductDrawnViewMass.AddItem "[" & i & "] " & DrwSheet.Views.Item(i).Name
295 End If
296 Wend
297
298 FrameGenerativeViewDoc.Caption = "Generative views controlling the pointed documents (" & NumberOfGenerativeViews & ")"
299
300 If NumberOfGenerativeViews > 0 Then
301 'Select the first generative view
302 ComboBoxProductDrawnView.ListIndex = 0
303 ComboBoxProductDrawnViewMass.ListIndex = 0
304 Else
305 TextBoxInfoGeneral ("There is no generative view (view with a link to a part, product or scene) on your drawing" _
306 & " - Please add a generative view")
307 End If
308
309End Sub
310Private Sub UpdateSheetInfoAndGenerativeViews()
311 Dim i As Integer
312 For i = 1 To DrwSheets.Count
313 If DrwSheets.Item(i).Name = DrwSheets.ActiveSheet.Name Then
314 ActiveSheetNumber = i
315 ChangeActiveSheet
316 Exit For
317 End If
318 Next
319End Sub
320Private Sub CommandSpinLeft_Click()
321 'Flag to prevent disabled of commands happening twice
322 SpinButtonChange = True
323
324 If FormInitialisation = False Then
325 DisableMainDrawingFormCommands
326 End If
327
328 ActiveSheetNumber = ActiveSheetNumber - 1
329 ChangeActiveSheet
330
331 If FormInitialisation = False Then
332 CommandsControlsEnabledState
333 End If
334
335 'Flag to prevent disabled of commands happening twice
336 SpinButtonChange = False
337End Sub
338Private Sub CommandSpinRight_Click()
339 'Flag to prevent disabled of commands happening twice
340 SpinButtonChange = True
341
342 If FormInitialisation = False Then
343 DisableMainDrawingFormCommands
344 End If
345 ActiveSheetNumber = ActiveSheetNumber + 1
346 ChangeActiveSheet
347
348 If FormInitialisation = False Then
349 CommandsControlsEnabledState
350 End If
351
352 'Flag to prevent disabled of commands happening twice
353 SpinButtonChange = False
354End Sub
355Private Sub ChangeActiveSheet()
356 '#### V5R24 #### ProgressBarDrawingBorder.Value = 10
357 FormInitialState
358 '#### V5R24 #### ProgressBarDrawingBorder.Value = 15
359 ResetProperties
360 DrwSheets.Item(ActiveSheetNumber).Activate
361 '#### V5R24 #### ProgressBarDrawingBorder.Value = 20
362 InitMainView
363 UpdateSheetLabel
364 'Obtain the current sheet properties
365 CurrentSheetProperties
366 '#### V5R24 #### ProgressBarDrawingBorder.Value = 30
367 'Check if the drawing border exists
368 If CheckDrawingBorderExists = True Then
369 CheckBoxDrawingBorderExists.Value = True
370 Else
371 'If no border is found then
372 RevisionsValuesNoDrawing
373 End If
374
375 'Update the Drawing Border Form to display the drawing border version
376 UpdateDrawingBorderExistVersion (DrawingBorderCurrentVersion)
377
378
379 '#### V5R24 #### ProgressBarDrawingBorder.Value = 40
380 'Check if it's the drawing sheet is a provisional Revision, Initial Revision or addional Revision
381 FindCurrentRevision
382 '#### V5R24 #### ProgressBarDrawingBorder.Value = 50
383 'Check the views that the drawing is looking at.
384 CheckForGenerativeViews
385 '#### V5R24 #### ProgressBarDrawingBorder.Value = 55
386 'Check to see if the user used an independent mass view
387 CheckForIndependentMassView
388 '#### V5R24 #### ProgressBarDrawingBorder.Value = 60
389 'Check for a process box, notes & layup
390 CheckForProcessBoxAndNotes
391 '#### V5R24 #### ProgressBarDrawingBorder.Value = 65
392' CheckForNotes
393 '#### V5R24 #### ProgressBarDrawingBorder.Value = 70
394 CheckForLayup
395 '#### V5R24 #### ProgressBarDrawingBorder.Value = 80
396 'Make the Tolerance the same as the existing drawing border
397
398 CheckBoundingBoxTableExists
399 CheckWetSurfaceAreaExists
400
401 SetTolTableAndPageSize
402 '#### V5R24 #### ProgressBarDrawingBorder.Value = 85
403
404 InitMainView
405 'Activate the original drawing - necessary to update the display
406 DrwSheet.Activate
407
408End Sub
409Private Sub UpdateDrawingBorderExistVersion(DrawingBorderVersion As String)
410 'Indication on the drawing border form of which drawing Border Version we have on our drawing
411 'The original drawing Border reference name was "Reference_HRF_Titleblock"
412 'Later Versions reference name are "Reference_V02" where V02 is the version
413 If DrawingBorderVersion = "" Then
414 LabelTitleBlockVersion.Caption = ""
415 Else
416 LabelTitleBlockVersion.Caption = "(" & DrawingBorderVersion & ")"
417 End If
418End Sub
419Private Sub FormInitialState()
420 '#### Initial State of Form ####
421 RevisionCanBeAdded = True
422 FirstViewCanBeUpdated = True
423 MassCanBeUpdated = True
424 CommandProductDrawnDesignMode.Visible = False
425 ResetInformationGeneral
426 ResetInformationMass
427 ResetInformationRevision
428 'Hide input box for up-issue
429 FrameReleaseDescription.Visible = False
430 'Re-size form to only show necessary bits
431 FormDraftDrawingBorder.Height = FormHeightSmall
432 'Place the dummy control used to take the focus off the page
433 CommandDummyForFocus.Top = 600
434End Sub
435Private Sub ResetProperties()
436 'Main attributes
437 TextBoxProductDrawnPartNumber.Text = ""
438 TextBoxProductDrawnSymOppPartNumber.Text = ""
439 TextBoxProductDrawnDescription.Text = ""
440 TextBoxService.Text = ""
441 TextBoxClassification.Text = ""
442
443 'Material Attributes
444 TextBoxMaterial.Text = ""
445 TextBoxHeatTreatment.Text = ""
446 TextBoxFinishProtection.Text = ""
447End Sub
448Private Sub UpdateSheetLabel()
449 LabelSheets.Caption = "Sheet " & ActiveSheetNumber & " of " & DrwSheets.Count
450End Sub
451Private Sub TextBoxInfoGeneral(Info As String)
452 If TextBoxInformationGeneral.Text = "" Then
453 TextBoxInformationGeneral.Text = Info
454 Else
455 TextBoxInformationGeneral.Text = Info & vbCrLf & vbCrLf & TextBoxInformationGeneral.Text
456 End If
457
458 TextBoxInformationGeneral.BackColor = &HC0C0FF
459 InfoGeneral = True
460End Sub
461Private Sub TextBoxInfoRevision(Info As String)
462 If TextBoxInformationRevision.Text = "" Then
463 TextBoxInformationRevision.Text = Info
464 Else
465 TextBoxInformationRevision.Text = Info & vbCrLf & vbCrLf & TextBoxInformationRevision.Text
466 End If
467
468 '&HC0C0FF
469
470 Dim WarningColour As Long
471
472 If PointedDocIsPVR = True Then
473 WarningColour = &HC0C0FF 'Red
474 Else
475 WarningColour = &HFFC0C0 'Purple
476 End If
477
478 TextBoxInformationRevision.BackColor = WarningColour
479 TextBoxProductDrawnVersion.BackColor = WarningColour
480 TextBoxNextRevisionTextMajor.BackColor = WarningColour
481 InfoRevision = True
482End Sub
483Private Sub TextBoxInfoMass(Info As String)
484 If TextBoxInformationMass.Text = "" Then
485 TextBoxInformationMass.Text = Info
486 Else
487 TextBoxInformationMass.Text = Info & vbCrLf & vbCrLf & TextBoxInformationMass.Text
488 End If
489
490 TextBoxProductDrawnCalcMass.BackColor = &HC0E0FF 'Orange
491 TextBoxInformationMass.BackColor = &HC0E0FF 'Orange
492 InfoMass = True
493End Sub
494Private Sub ResetInformationGeneral()
495 TextBoxInformationGeneral.Text = ""
496 TextBoxInformationGeneral.BackColor = &HE0E0E0
497 InfoGeneral = False
498End Sub
499Private Sub ResetInformationRevision()
500 TextBoxInformationRevision.Text = ""
501 TextBoxInformationRevision.BackColor = &HE0E0E0
502 TextBoxNextRevisionTextMajor.BackColor = &HE0E0E0
503 TextBoxProductDrawnVersion.BackColor = &HE0E0E0
504 InfoRevision = False
505End Sub
506Private Sub ResetInformationMass()
507 TextBoxInformationMass.Text = ""
508 TextBoxInformationMass.BackColor = &HE0E0E0
509 InfoMass = False
510End Sub
511Private Sub ResetMassAndDensity()
512 TextBoxProductDrawnCalcMass.Value = ""
513 TextBoxProductDrawnMassDensity.Value = ""
514End Sub
515Private Sub CheckInformationTabs()
516 Dim InformationToShow As Boolean
517 InformationToShow = False
518 'General Ino
519 If InfoGeneral = True Then
520 InformationToShow = True
521 MultiPageInfo.Pages.Item(0).Visible = True
522 Else
523 MultiPageInfo.Pages.Item(0).Visible = False
524 End If
525 'Revisions
526 If InfoRevision = True Then
527 InformationToShow = True
528 MultiPageInfo.Pages.Item(1).Visible = True
529 Else
530 MultiPageInfo.Pages.Item(1).Visible = False
531 End If
532 'Mass
533 If InfoMass = True Then
534 InformationToShow = True
535 MultiPageInfo.Pages.Item(2).Visible = True
536 Else
537 MultiPageInfo.Pages.Item(2).Visible = False
538 End If
539
540 If InformationToShow = True Then
541 MultiPageInfo.Visible = True
542 Else
543 MultiPageInfo.Visible = False
544 End If
545
546 'We want to make sure the General page is the page that is shown if there is any info.
547 If InfoGeneral = True Then
548 MultiPageInfo.Value = 0
549 'If there are multiple items in the General info display that are longer than the textbox, we use the setfocu to show the scroll bar
550 If InfoGeneral = True Then
551 TextBoxInformationGeneral.SetFocus
552 TextBoxInformationGeneral.SelStart = 0
553 End If
554 'Next we want to make the Revisions information shown
555 ElseIf InfoRevision = True Then
556 MultiPageInfo.Value = 1
557 'If there are multiple items in the General info display that are longer than the textbox, we use the setfocu to show the scroll bar
558 If InfoRevision = True Then
559 TextBoxInformationRevision.SetFocus
560 TextBoxInformationRevision.SelStart = 0
561 End If
562 ElseIf InfoMass = True Then
563 MultiPageInfo.Value = 2
564 'If there are multiple items in the General info display that are longer than the textbox, we use the setfocu to show the scroll bar
565 If InfoMass = True Then
566 TextBoxInformationMass.SetFocus
567 TextBoxInformationMass.SelStart = 0
568 End If
569 End If
570
571 FormDraftDrawingBorder.Repaint
572
573End Sub
574Private Sub ChangeMassBackgroundNormal()
575 TextBoxProductDrawnCalcMass.BackColor = &HE0E0E0
576End Sub
577Private Sub ChangeDensityBackgroundWarning()
578 TextBoxProductDrawnMassDensity.BackColor = &HC0E0FF 'Orange
579End Sub
580Private Sub ChangeDensityBackgroundNormal()
581 TextBoxProductDrawnMassDensity.BackColor = &HE0E0E0
582End Sub
583Private Function CheckDrawingBorderExists() As Boolean
584 CheckDrawingBorderExists = False
585 '-------------------------------------------------------------------------------
586 'How to check that the called macro is the right one
587 '-------------------------------------------------------------------------------
588 Dim NbTexts As Integer
589 Dim i As Integer
590 Dim Text 'As String
591
592 'First Check the background view
593 InitBackgroundView
594
595 NbTexts = DrwTexts.Count
596 i = 0
597
598 DrawingBorderCurrentVersion = ""
599 While (CheckDrawingBorderExists = False And i < NbTexts)
600 i = i + 1
601 Set Text = DrwTexts.Item(i)
602 If (Left(Text.Name, 10) = "Reference_") Then
603 CheckDrawingBorderExists = True
604 'Check if the Reference suffix is numeric, if it is then we can assume this is it's version
605 'The original drawing Border reference name was "Reference_HRF_Titleblock"
606 'Later Versions reference name are "Reference_V02"
607 DrawingBorderCurrentVersion = Right(Text.Name, 2)
608 If IsNumeric(DrawingBorderCurrentVersion) = False Then
609 DrawingBorderCurrentVersion = "01"
610 End If
611 Exit Function
612 End If
613 Wend
614
615 'Now check the Main View (legacy drawings used to get the reference text placed on the Main View)
616 InitMainView
617
618 NbTexts = DrwTexts.Count
619 i = 0
620 While (CheckDrawingBorderExists = False And i < NbTexts)
621 i = i + 1
622 Set Text = DrwTexts.Item(i)
623 If (Left(Text.Name, 10) = "Reference_") Then
624 CheckDrawingBorderExists = True
625 Exit Function
626 End If
627 Wend
628End Function
629Private Sub CheckForIndependentMassView()
630 Dim IndependentMassViewName As String
631 IndependentMassViewName = ""
632 '-------------------------------------------------------------------------------
633 'How to check that the called macro is the right one
634 '-------------------------------------------------------------------------------
635 Dim NbTexts As Integer
636 Dim i As Integer
637 Dim Text 'As String
638
639 'First Check the background view
640 InitBackgroundView
641
642 NbTexts = DrwTexts.Count
643 i = 0
644 While (IndependentMassViewName = "" And i < NbTexts)
645 i = i + 1
646 Set Text = DrwTexts.Item(i)
647 If Left(Text.Name, 22) = "Independent_Mass_View_" Then
648 IndependentMassViewName = Right(Text.Name, Len(Text.Name) - 22)
649 TextBoxInfoMass ("Please note that the last time the mass was updated, it was taken from an 'independent mass view' called '" & IndependentMassViewName & "'. The selection of the independent mass view cannot be automated, please select this option manually if you want to continue with an independent mass view.")
650 Exit Sub
651 End If
652 Wend
653End Sub
654Sub CheckForProcessBoxAndNotes()
655 '-------------------------------------------------------------------------------
656 'How to check if the process box has already been created
657 '-------------------------------------------------------------------------------
658 Dim i As Integer
659 ReadProcessBoxAndNotes = False
660' InitBackgroundView
661
662
663 'Check if there are any processes in the process box and the process and notes tag
664 i = 0
665 While (ReadProcessBoxAndNotes = False And i < DrwTexts.Count)
666 i = i + 1
667 'Check for Processes, Notes, ProcessBoxAndNotesTag
668 If (Left(DrwTexts.Item(i).Name, 17) = "Process_Box_Text_") Or (Left(DrwTexts.Item(i).Name, 26) = "DrawingAutoGeneratedText_v") Then
669 ReadProcessBoxAndNotes = True
670 End If
671 Wend
672
673 'Now check the main view for old style notes
674 InitMainView
675 i = 0
676 While (ReadProcessBoxAndNotes = False And i < DrwTexts.Count)
677 i = i + 1
678 If (Left(DrwTexts.Item(i).Name, 18) = "DrawingBorderNotes") Then
679 ReadProcessBoxAndNotes = True
680 End If
681 Wend
682
683 'Now check the main view for Notes View
684 i = 0
685
686 Dim DrwViews As DrawingViews
687 Set DrwViews = DrwSheet.Views
688
689 While (ReadProcessBoxAndNotes = False And i < DrwViews.Count)
690 i = i + 1
691 If (Left(DrwViews.Item(i).Name, 10) = "NOTES VIEW") Then
692 ReadProcessBoxAndNotes = True
693 End If
694 Wend
695
696
697 If ReadProcessBoxAndNotes = True Then
698 ChangeProcessBoxAndNotes2Modify
699 Else
700 ChangeProcessBoxAndNotes2Create
701 End If
702
703 CommandDummyForFocus.SetFocus
704End Sub
705Sub CheckForLayup()
706 '-------------------------------------------------------------------------------
707 'How to check if the notes are already created
708 '-------------------------------------------------------------------------------
709 Dim i As Integer
710 ReadLayup = False
711 InitMainView
712
713 While (ReadLayup = False And i < DrwTexts.Count)
714 i = i + 1
715 If (DrwTexts.Item(i).Name = "LayupNotes") Then
716 ReadLayup = True
717 End If
718 Wend
719
720 If ReadLayup = True Then
721 ChangeLayup2Modify
722 Else
723 ChangeLayup2Create
724 End If
725
726 CommandDummyForFocus.SetFocus
727End Sub
728Private Sub CheckBoundingBoxTableExists()
729
730 '-------------------------------------------------------------------------------
731 'How to check if the BoundingBox Table is already on the drawing
732 '-------------------------------------------------------------------------------
733 Dim i As Integer
734 BoundingBoxTableExists = False
735 InitBackgroundView
736 Dim DrwTables As DrawingTables
737' Dim DrwTable As DrawingTable
738 Set DrwTables = DrwView.Tables
739
740 While (BoundingBoxTableExists = False And i < DrwTables.Count)
741 i = i + 1
742 If (DrwTables.Item(i).Name = "Bounding Box and Production Info") Then
743 BoundingBoxTableExists = True
744 End If
745 Wend
746
747End Sub
748Private Sub CheckWetSurfaceAreaExists()
749
750 '-------------------------------------------------------------------------------
751 'How to check if the BoundingBox Table is already on the drawing
752 '-------------------------------------------------------------------------------
753 Dim i As Integer
754 WetSurfaceAreaExists = False
755 InitBackgroundView
756 Dim DrwTables As DrawingTables
757' Dim DrwTable As DrawingTable
758 Set DrwTables = DrwView.Tables
759
760 While (WetSurfaceAreaExists = False And i < DrwTables.Count)
761 i = i + 1
762 If (DrwTables.Item(i).Name = "Wet Surface Area") Then
763 WetSurfaceAreaExists = True
764 End If
765 Wend
766
767End Sub
768Private Sub ChangeProcessBoxAndNotes2Create()
769 CommandProcessAndNotesEditor.Caption = " Create "
770 ReadProcessBoxAndNotes = False
771End Sub
772Private Sub ChangeLayup2Create()
773 CommandLayup.Caption = " Create "
774 ReadLayup = False
775End Sub
776Private Sub ChangeProcessBoxAndNotes2Modify()
777 CommandProcessAndNotesEditor.Caption = " Modify "
778 ReadProcessBoxAndNotes = True
779End Sub
780Private Sub ChangeLayup2Modify()
781 CommandLayup.Caption = " Modify "
782 ReadLayup = True
783End Sub
784Public Sub CommandsControlsEnabledState()
785
786 '#### V5R24 #### ProgressBarDrawingBorder.Value = 90
787
788 CreateOrModifyModeCheck
789
790 '#### V5R24 #### ProgressBarDrawingBorder.Value = 95
791
792 '###########################
793 'Generative Views Frame
794 '###########################
795
796 'enable commands dependent upon whether there are any generative views
797 If NumberOfGenerativeViews = 0 Then
798 CheckBoxIndependentMassGenerativeView.Enabled = False
799
800 ComboBoxProductDrawnView.Enabled = False
801 ComboBoxProductDrawnView.BackColor = &HE0E0E0
802 TextBoxProductDrawnType.Enabled = False
803 TextBoxProductDrawnOrigPartNumber.Enabled = False
804
805 TextBoxProductDrawnVersion.Enabled = False
806 TextBoxProductDrawnCalcMass.Enabled = False
807 TextBoxProductDrawnMassDensity.Enabled = False
808
809 TextBoxProductDrawnLinkedGeom.Visible = False
810 LabelProductDrawnLinkedGeom.Visible = False
811
812 CommandProductDrawnDesignMode.Enabled = False
813 CheckBoxOnlyMainBody.Enabled = False
814
815 'Disable the drop down menu if there is only one generative view available.
816 ElseIf NumberOfGenerativeViews = 1 Then
817 ComboBoxProductDrawnView.Enabled = False
818 ComboBoxProductDrawnView.BackColor = &HC0FFFF
819 TextBoxProductDrawnOrigPartNumber.Enabled = True
820 TextBoxProductDrawnType.Enabled = True
821 TextBoxProductDrawnVersion.Enabled = True
822 CheckBoxIndependentMassGenerativeView.Enabled = False
823 CheckBoxOnlyMainBody.Enabled = True
824 Else
825 ComboBoxProductDrawnView.Enabled = True
826 ComboBoxProductDrawnView.BackColor = &HC0FFFF
827 TextBoxProductDrawnOrigPartNumber.Enabled = True
828 TextBoxProductDrawnType.Enabled = True
829 TextBoxProductDrawnVersion.Enabled = True
830 CheckBoxIndependentMassGenerativeView.Enabled = True
831 CheckBoxOnlyMainBody.Enabled = True
832 End If
833 GenerativeViewMassFormEnabledState
834
835 '###########################
836 'Drawing Border Tabs
837 '###########################
838
839 If CheckBoxDrawingBorderExists.Value = True Then
840
841 'Drawing Update (Auto) commands
842 If NumberOfGenerativeViews > 0 Then
843 CommandUpdateFields.Enabled = True
844 CommandUpdateFields2.Enabled = True
845 If FirstViewCanBeUpdated = True Then
846 CheckBoxUpdateFirstView.Enabled = True
847 CheckBoxUpdateFirstView2.Enabled = True
848 Else
849 CheckBoxUpdateFirstView.Enabled = False
850 CheckBoxUpdateFirstView2.Enabled = False
851 End If
852 If MassCanBeUpdated = True Then
853 CheckBoxUpdateMass.Enabled = True
854 CheckBoxUpdateMass2.Enabled = True
855 Else
856 CheckBoxUpdateMass.Enabled = False
857 CheckBoxUpdateMass2.Enabled = False
858 End If
859 Else
860 CommandUpdateFields.Enabled = False
861 CommandUpdateFields2.Enabled = False
862 CheckBoxUpdateFirstView.Enabled = False
863 CheckBoxUpdateFirstView2.Enabled = False
864 CheckBoxUpdateMass.Enabled = False
865 CheckBoxUpdateMass2.Enabled = False
866 End If
867
868 CommandDeleteDrawingBorder.Enabled = True
869
870 CommandReplaceLogo.Enabled = True
871
872 'Only allow the update of the drawing border if it's not the latest version
873 If DrawingBorderCurrentVersion <> "" And DrawingBorderCurrentVersion <> DrawingBorderNewVersion Then
874 CommandUpdateBorder.Enabled = True
875 Else
876 CommandUpdateBorder.Enabled = False
877 End If
878
879 If CheckersInitialsFound = True Then
880 CommandRevisionBlockCheckedInitials.Enabled = True
881 Else
882 CommandRevisionBlockCheckedInitials.Enabled = False
883 End If
884
885 If CheckBoxProvisionalRevision.Value = True Then
886 CommandMajorRelease.Enabled = False
887 CommandDotRelease.Enabled = False
888
889 If DrawnInitialsAreOk = False Or PhoneNumberIsOk = False Or CheckersInitialsAreOk = False Then
890 CommandInitialRelease.Enabled = False
891 Else
892 CommandInitialRelease.Enabled = True
893 End If
894 CommandRevisionMod.Enabled = False
895 CommandRevisionBlockCheckedInitials.Enabled = False
896 CommandRevisionsLastDelete.Enabled = False
897 CommandRevisionsDelete.Enabled = False
898 Else
899 If DrawnInitialsAreOk = False Or CheckersInitialsAreOk = False Then
900 CommandMajorRelease.Enabled = False
901 CommandDotRelease.Enabled = False
902 Else
903 CommandMajorRelease.Enabled = True
904 CommandDotRelease.Enabled = True
905 End If
906
907 CommandInitialRelease.Enabled = False
908 CommandRevisionsLastDelete.Enabled = True
909 If CheckBoxInitialRevision.Value = True Then
910 CommandRevisionMod.Enabled = False
911 'CommandRevisionsLastDelete.Enabled = False
912 CommandRevisionsDelete.Enabled = False
913 Else
914 CommandRevisionMod.Enabled = True
915 'CommandRevisionsLastDelete.Enabled = True
916 If DrawnInitialsAreOk = False Or PhoneNumberIsOk = False Then
917 CommandRevisionsDelete.Enabled = False
918 Else
919 CommandRevisionsDelete.Enabled = True
920 End If
921 End If
922 End If
923
924 'Drawing Update (Manual) commands
925 CommandUpdateFieldManual.Enabled = True
926 'Check if Mass to be added
927 If MassManualCanBeAdded = True Then
928 CommandMass.Enabled = True
929 Else
930 CommandMass.Enabled = False
931 End If
932 TextBoxMass.Enabled = True
933 CommandManual.Enabled = True
934 Else
935
936 'Drawing Update (Auto) commands
937 CommandUpdateFields.Enabled = False
938 CommandUpdateFields2.Enabled = False
939 CheckBoxUpdateFirstView.Enabled = False
940 CheckBoxUpdateFirstView2.Enabled = False
941 CheckBoxUpdateMass.Enabled = False
942 CheckBoxUpdateMass2.Enabled = False
943
944 CommandMajorRelease.Enabled = False
945 CommandDotRelease.Enabled = False
946 CommandDeleteDrawingBorder.Enabled = False
947
948 CommandInitialRelease.Enabled = False
949 CommandRevisionMod.Enabled = False
950 CommandRevisionBlockCheckedInitials.Enabled = False
951 CommandRevisionsLastDelete.Enabled = False
952 CommandRevisionsDelete.Enabled = False
953
954 CommandReplaceLogo.Enabled = False
955 CommandUpdateBorder.Enabled = False
956
957 'Drawing Update (Manual) commands
958 CommandUpdateFieldManual.Enabled = False
959 CommandMass.Enabled = False
960 TextBoxMass.Enabled = False
961 CommandManual.Enabled = False
962 End If
963
964 'Commands below should be enabled after any command has run
965 'Information
966 CommandProductDrawnDesignMode.Enabled = True
967
968 'Drawing Update (Auto) commands
969 OptionButton_A3.Enabled = True
970 OptionButton_A2.Enabled = True
971 OptionButton_A1.Enabled = True
972 OptionButton_A0.Enabled = True
973 OptionButtonTolStandard.Enabled = True
974 OptionButtonTolComposite.Enabled = True
975 OptionButtonTolFabrications.Enabled = True
976 OptionButtonTolCastings.Enabled = True
977 OptionButtonTolWiring.Enabled = True
978 OptionButtonTolPattern.Enabled = True
979 OptionButtonTolAdditiveLayerManufacture.Enabled = True
980 'This has been disabled to prevent new drawings using this option
981 'but has been left in place to make sure the script can cope with existing drawings
982 'OptionButtonTolNone.Enabled = True
983
984 TextBoxCheckersInitials.Enabled = True
985
986 CheckProcessBoxAndNotesState
987' CheckNotesState
988 CheckLayupState
989
990 CommandCancel.Enabled = True
991
992 'Revision Mod/Add
993 CommandDescriptionModify.Enabled = True
994 CommandDescriptionCancel.Enabled = True
995
996 'Revisions
997 If DrwSheets.Count > 1 Then
998 CommandRevisionCopyFirstSheet.Enabled = True
999 If DrawnInitialsAreOk = False Then
1000 CommandRevisionsReferToFirstSheet.Enabled = False
1001 CommandRevisionsReferToFirstSheetWithOneRev.Enabled = False
1002 Else
1003 CommandRevisionsReferToFirstSheet.Enabled = True
1004 CommandRevisionsReferToFirstSheetWithOneRev.Enabled = True
1005 End If
1006 Else
1007 CommandRevisionCopyFirstSheet.Enabled = False
1008 CommandRevisionsReferToFirstSheet.Enabled = False
1009 CommandRevisionsReferToFirstSheetWithOneRev.Enabled = False
1010 End If
1011
1012 'Necessary to allow the form to re-display before allowing another selection
1013 '#### V5R24 #### Sleep 500
1014
1015 'The following commands need to be last to prevent them from being select while other commands are being activated
1016 'Generative Views Frame
1017 If ActiveSheetNumber = 1 Then
1018 CommandSpinLeft.Enabled = False
1019 Else
1020 CommandSpinLeft.Enabled = True
1021 End If
1022
1023 If ActiveSheetNumber = DrwSheets.Count Then
1024 CommandSpinRight.Enabled = False
1025 Else
1026 CommandSpinRight.Enabled = True
1027 End If
1028 '#### V5R24 #### ProgressBarDrawingBorder.Value = 100
1029 '#### V5R24 #### ProgressBarDrawingBorder.Visible = False
1030
1031 CheckBoundingBoxEnabledState
1032 CheckWetSurfaceAreaEnabledState
1033
1034 FrameGenerativeViewDoc.Enabled = True
1035 'FrameInformation.Enabled = True
1036 FrameDrawingBorder.Enabled = True
1037End Sub
1038Private Sub CheckBoundingBoxEnabledState()
1039 'Check if the Parameters View is pointing at a part and the drawing does not already have a bounding box table on it.
1040
1041 If TextBoxProductDrawnType.Text = "Part" And BoundingBoxTableExists = False Then
1042 CommandBoundingBox.Enabled = True
1043 Else
1044 CommandBoundingBox.Enabled = False
1045 End If
1046End Sub
1047Private Sub CheckWetSurfaceAreaEnabledState()
1048 'Check if the Parameters View is pointing at a part and the drawing does not already have a Wet Surface Area table on it.
1049
1050 If TextBoxProductDrawnType.Text = "Part" And WetSurfaceAreaExists = False Then
1051 CommandWetSurfaceArea.Enabled = True
1052 Else
1053 CommandWetSurfaceArea.Enabled = False
1054 End If
1055End Sub
1056Private Sub CheckProcessBoxAndNotesState()
1057 CommandProcessAndNotesEditor.Enabled = True
1058 If ReadProcessBoxAndNotes = True Then
1059 CommandDeleteProcessesAndNotes.Enabled = True
1060 Else
1061 CommandDeleteProcessesAndNotes.Enabled = False
1062 End If
1063
1064 CommandDummyForFocus.SetFocus
1065End Sub
1066Private Sub CheckLayupState()
1067 CommandLayup.Enabled = True
1068 If ReadLayup = True Then
1069 CommandLayupDelete.Enabled = True
1070 Else
1071 CommandLayupDelete.Enabled = False
1072 End If
1073
1074 CommandDummyForFocus.SetFocus
1075End Sub
1076Private Sub CheckAttributes()
1077
1078 'TextBoxRevisionDrawnInitials
1079 ' Create > ModifyInitialText > UpdateDrawingBorderFields > TextBoxRevisionDrawnInitials
1080 ' CommandInitialRelease > UpdateDrawingBorderFields > TextBoxRevisionDrawnInitials
1081 ' CommandMajorRelease > CommandDescriptionModify_Click > AddRevisionBlock > CATRevisionBlock > CATRevisionBlockText
1082 ' CommandDotRelease > CommandDescriptionModify_Click > AddRevisionBlock > CATRevisionBlock > CATRevisionBlockText
1083 ' CommandRevisionsDelete > ResetProvisionalAndDrawnAndCheck > UpdateDrawingBorderFields > TextBoxRevisionDrawnInitials
1084 ' CommandRevisionsReferToFirstSheet_Click > AddRevisionsReferringtoFirstPage > AddRevisionBlockFromFirstSheet > CATRevisionBlockText
1085
1086 'TextBoxCheckersInitials
1087 ' CommandMajorRelease > CommandDescriptionModify_Click > AddRevisionBlock > CATRevisionBlock > CATRevisionBlockText
1088 ' CommandDotRelease > CommandDescriptionModify_Click > AddRevisionBlock > CATRevisionBlock > CATRevisionBlockText
1089 ' CommandInitialRelease > RevisionBlockCheckedInitials
1090 ' CommandRevisionBlockCheckedInitials > RevisionBlockCheckedInitials
1091
1092 'TextBoxPhoneNumber
1093 ' Create > ModifyInitialText > UpdateDrawingBorderFields > TextBoxPhoneNumber
1094 ' CommandInitialRelease > UpdateDrawingBorderFields > TextBoxPhoneNumber
1095 ' CommandRevisionsDelete > ResetProvisionalAndDrawnAndCheck > UpdateDrawingBorderFields > TextBoxPhoneNumber
1096
1097 If CheckersInitialsAreOk = False Then
1098 TextBoxInfoGeneral ("'Checker' initials below must be either 2 or 3 characters, please enter the initials below - These will be remebered. The following commands will be disabled until the initials are entered: " & vbCrLf & _
1099 "Revision, Dot Revision, Initial Revision, Checker Mod")
1100 End If
1101
1102 If DrawnInitialsAreOk = False Then
1103 TextBoxInfoGeneral ("[" & TextBoxDrawn.Text & "] does not have any initials defined in active directory, this will disable the following commands:" & vbCrLf & _
1104 "[Drawn Initials; Create, Initial Release, Major/Minor Revision, Delete All Revisions, Revisions Refer To 1st Sheet] - Please raise a CAD support call indicating your initials (3 Characters).")
1105 End If
1106
1107 If PhoneNumberIsOk = False Then
1108 TextBoxInfoGeneral ("[" & TextBoxDrawn.Text & "] does not have a Phone Number defined in active directory, this will disable the following commands:" & vbCrLf & _
1109 "[Phone Number; Create, Initial Release, Delete All Revisions] - Please raise a CAD support call indicating your phone number.")
1110 End If
1111
1112End Sub
1113Private Sub CreateOrModifyModeCheck()
1114 'check whether a drawing border exists already in the sheet
1115 'If it does mode = modify, otherwise mode is new
1116
1117 If CheckBoxDrawingBorderExists.Value = True Then
1118 'Change the caption on the create/modify button to modify
1119 CommandCreateDrawingBorder.Caption = " Modify "
1120
1121 'Check to make sure you are not resizing to the same size
1122 CheckSizeOption
1123
1124 'Make the create/modify inactive dependent upon selection of sheet size
1125 'Make the create/modify inactive dependent upon selection of the tolerance
1126 'If the user hasn't selected a tolerance then disbale the Create button.
1127 If SelectedToleranceSetting = "" Then
1128 TextBoxInfoGeneral ("You must choose a Tolerance option to enable the Modify button")
1129 CommandCreateDrawingBorder.Enabled = False
1130 Else
1131 If displayFormat = ChosenSize And CurrentTolSetting = SelectedToleranceSetting Then
1132 CommandCreateDrawingBorder.Enabled = False
1133 Else
1134 CommandCreateDrawingBorder.Enabled = True
1135 End If
1136 End If
1137 Else
1138 'Change the caption on the create/modify button to create
1139 CommandCreateDrawingBorder.Caption = " Create "
1140 'If the user hasn't selected a tolerance then disbale the Create button.
1141 If SelectedToleranceSetting = "" Then
1142 TextBoxInfoGeneral ("You must choose a Tolerance option to enable the Create button")
1143 CommandCreateDrawingBorder.Enabled = False
1144 Else
1145 If DrawnInitialsAreOk = False Or PhoneNumberIsOk = False Then
1146 CommandCreateDrawingBorder.Enabled = False
1147 Else
1148 CommandCreateDrawingBorder.Enabled = True
1149 End If
1150 End If
1151 End If
1152
1153 CheckAttributes
1154
1155 If FormInitialisation = False Then
1156 CheckInformationTabs
1157 End If
1158
1159
1160 'Once we have added the revisions information, we reset it so that we don't keep seeing it on other commands
1161 'We only want to see it when selecting the revisions commands
1162 'ResetInformationRevision
1163 'RevisionCanBeAdded = True
1164 InfoRevision = False
1165End Sub
1166Private Sub DisableMainDrawingFormCommands()
1167
1168 FrameGenerativeViewDoc.Enabled = False
1169 'FrameInformation.Enabled = False
1170 FrameDrawingBorder.Enabled = False
1171
1172 MultiPageInfo.Visible = False
1173
1174 'Icons found in Drawing Border Frame
1175
1176 '#### V5R24 #### ProgressBarDrawingBorder.Visible = True
1177 '#### V5R24 #### ProgressBarDrawingBorder.Value = 1
1178 FormDraftDrawingBorder.Repaint
1179
1180 '###########################
1181 'Generative Views Frame
1182 '###########################
1183 CommandSpinLeft.Enabled = False
1184 CommandSpinRight.Enabled = False
1185
1186 ComboBoxProductDrawnView.Enabled = False
1187 ComboBoxProductDrawnViewMass.Enabled = False
1188
1189 CommandProductDrawnDesignMode.Enabled = False
1190 CheckBoxOnlyMainBody.Enabled = False
1191 CheckBoxIndependentMassGenerativeView.Enabled = False
1192
1193 '###########################
1194 'Drawing Border Tabs
1195 '###########################
1196
1197 'Drawing Update (Auto) commands
1198 CommandUpdateFields.Enabled = False
1199 CommandUpdateFields2.Enabled = False
1200 CheckBoxUpdateFirstView.Enabled = False
1201 CheckBoxUpdateFirstView2.Enabled = False
1202 CheckBoxUpdateMass.Enabled = False
1203 CheckBoxUpdateMass2.Enabled = False
1204
1205 CommandMajorRelease.Enabled = False
1206 CommandDotRelease.Enabled = False
1207
1208 CommandInitialRelease.Enabled = False
1209 CommandRevisionMod.Enabled = False
1210 CommandRevisionBlockCheckedInitials.Enabled = False
1211 TextBoxCheckersInitials.Enabled = False
1212 CommandRevisionsLastDelete.Enabled = False
1213 CommandRevisionsDelete.Enabled = False
1214
1215' CommandProcessBox.Enabled = False
1216 CommandProcessAndNotesEditor.Enabled = False
1217 CommandDeleteProcessesAndNotes.Enabled = False
1218' CommandProcessBoxDelete.Enabled = False
1219' CommandNotes.Enabled = False
1220' CommandNotesDelete.Enabled = False
1221 CommandLayup.Enabled = False
1222 CommandLayupDelete.Enabled = False
1223
1224 CommandReplaceLogo.Enabled = False
1225 CommandUpdateBorder.Enabled = False
1226 CommandDeleteDrawingBorder.Enabled = False
1227
1228 OptionButton_A3.Enabled = False
1229 OptionButton_A2.Enabled = False
1230 OptionButton_A1.Enabled = False
1231 OptionButton_A0.Enabled = False
1232 OptionButtonTolStandard.Enabled = False
1233 OptionButtonTolComposite.Enabled = False
1234 OptionButtonTolFabrications.Enabled = False
1235 OptionButtonTolCastings.Enabled = False
1236 OptionButtonTolWiring.Enabled = False
1237 OptionButtonTolPattern.Enabled = False
1238 OptionButtonTolAdditiveLayerManufacture.Enabled = False
1239 OptionButtonTolNone.Enabled = False
1240
1241 CommandCreateDrawingBorder.Enabled = False
1242 CommandCancel.Enabled = False
1243
1244 'Part Data attributes
1245 CommandBoundingBox.Enabled = False
1246 CommandWetSurfaceArea.Enabled = False
1247
1248 'Revision Mod/Add
1249 CommandDescriptionModify.Enabled = False
1250 CommandDescriptionCancel.Enabled = False
1251
1252 'Drawing Commands (Manual)
1253 CommandUpdateFieldManual.Enabled = False
1254 CommandMass.Enabled = False
1255 TextBoxMass.Enabled = False
1256 CommandManual.Enabled = False
1257
1258 'Revisions
1259 CommandRevisionCopyFirstSheet.Enabled = False
1260 CommandRevisionsReferToFirstSheet.Enabled = False
1261 CommandRevisionsReferToFirstSheetWithOneRev.Enabled = False
1262End Sub
1263Private Sub CheckBoxIndependentMassGenerativeView_Click()
1264 ResetInformationGeneral
1265 DisableMainDrawingFormCommands
1266 If CheckBoxIndependentMassGenerativeView.Value = False Then
1267 ComboBoxProductDrawnViewMass.Text = ComboBoxProductDrawnView.Text
1268 End If
1269 CommandsControlsEnabledState
1270End Sub
1271Private Sub GenerativeViewMassFormEnabledState()
1272 If CheckBoxIndependentMassGenerativeView.Value = False Then
1273 MassCommandControlsDisabled
1274 Else
1275 MassCommandControlsEnabled
1276 End If
1277 CommandCancel.Enabled = True
1278End Sub
1279Private Sub ComboBoxProductDrawnView_Change()
1280 'Take into account the clearing of the list
1281 If ComboBoxProductDrawnView.ListCount <> 0 Then
1282 If FormInitialisation = False And SpinButtonChange = False Then
1283 DisableMainDrawingFormCommands
1284 End If
1285 'Only process the view change after the initial views have been added to the combo box
1286 ResetInformationGeneral
1287 ResetInformationRevision
1288 ExtractPointedDocumentInfo (ExtractViewID)
1289 'Check if it is possible to add a revision (dependent upon version of generative linked doc)
1290 'CheckRevisionCanbeAdded
1291 CheckFirstViewCanBeUpdated
1292 If CheckBoxIndependentMassGenerativeView.Value = False Then
1293 ComboBoxProductDrawnViewMass.Text = ComboBoxProductDrawnView.Text
1294 Else
1295 CommandsControlsEnabledState
1296 End If
1297 If FormInitialisation = False And SpinButtonChange = False Then
1298 ActivateParametersTab
1299 End If
1300 End If
1301End Sub
1302Private Sub ActivateParametersTab()
1303 MultiPageDrawingBorderCommands.Value = 2
1304End Sub
1305Private Sub ComboBoxProductDrawnViewMass_Change()
1306 'Take into account the clearing of the list
1307 If ComboBoxProductDrawnViewMass.ListCount <> 0 Then
1308 If FormInitialisation = False And SpinButtonChange = False Then
1309 DisableMainDrawingFormCommands
1310 End If
1311 '##### Calculate the mass #####
1312 ResetInformationMass
1313 'ResetInformationGeneral
1314 ChangeMassBackgroundNormal
1315 FormDraftDrawingBorder.Repaint
1316 ProductDrawnMassDoc
1317 'Only process the commands state once the form has been initiated
1318 If FormInitialisation = False And SpinButtonChange = False Then
1319 CommandsControlsEnabledState
1320 ActivateParametersTab
1321 End If
1322 End If
1323End Sub
1324Private Function ExtractViewID()
1325 Dim SelectedView As String
1326 SelectedView = ComboBoxProductDrawnView.Text
1327 ExtractViewID = Mid(SelectedView, 2, InStr(SelectedView, "]") - 2)
1328End Function
1329Private Function ExtractIndependentMassViewID()
1330 Dim SelectedView As String
1331 SelectedView = ComboBoxProductDrawnViewMass.Text
1332 ExtractIndependentMassViewID = Right(SelectedView, Len(SelectedView) - InStr(SelectedView, "]") - 1)
1333End Function
1334Private Sub ExtractPointedDocumentInfo(SelectedViewID As Integer)
1335
1336 Dim LinkValidViewName As String
1337 Dim LinkValidViewGeometry As String
1338 LinkValidViewName = ""
1339 LinkValidViewGeometry = ""
1340 PointedDocIsPVR = False
1341
1342 'Hide the Linked Geometry forms as they will not be needed now.
1343 TextBoxProductDrawnLinkedGeom.Visible = False
1344 LabelProductDrawnLinkedGeom.Visible = False
1345
1346 '################################################
1347 'First check what the generative view is pointing at
1348 '################################################
1349
1350 On Error Resume Next
1351 If DrwSheet.Views.Item(SelectedViewID).GenerativeBehavior.Document.Parent.Name = "Scenes" Then
1352 'If there is an error, it means the view is pointing at a PRC.
1353 If Err.Number <> 0 Then
1354 TextBoxInfoGeneral ("You have a generative view that is linked to a PRC. " & _
1355 "Before the drawing border information can be updated you must:" & vbCrLf & _
1356 "Load the PDM Context of this drawing (data associated with the drawing), " & _
1357 "Select the drawing part number in the top left window, " & _
1358 " Right hand mouse button > select Load PDM Conext")
1359
1360 TextBoxProductDrawnType.Text = "PRC"
1361 TextBoxProductDrawnOrigPartNumber.Text = ""
1362 Set ProductDrawn = Nothing
1363 Exit Sub
1364 End If
1365
1366 Set ProductDrawn = DrwSheet.Views.Item(SelectedViewID).GenerativeBehavior.Document.Parent.Parent
1367 ElseIf DrwSheet.Views.Item(SelectedViewID).GenerativeBehavior.Document.Parent.Name = "Bodies" Then
1368 Set ProductDrawn = DrwSheet.Views.Item(SelectedViewID).GenerativeBehavior.Document.Parent.Parent.Parent.Product
1369 ElseIf DrwSheet.Views.Item(SelectedViewID).GenerativeBehavior.Document.Parent.Name = "HybridBodies" Then
1370 Set ProductDrawn = DrwSheet.Views.Item(SelectedViewID).GenerativeBehavior.Document.Parent.Parent.Parent.Product
1371 Else
1372 Set ProductDrawn = DrwSheet.Views.Item(SelectedViewID).GenerativeBehavior.Document
1373 End If
1374
1375 'Check if the product that is being pointed at is Nothing
1376 'If it is nothing then there is other geometry being pointed at
1377 If ProductDrawn Is Nothing Then
1378 LinkValidViewName = DrwSheet.Views.Item(SelectedViewID).Name
1379 LinkValidViewGeometry = DrwSheet.Views.Item(SelectedViewID).GenerativeBehavior.Document.Name
1380
1381 TextBoxInfoGeneral ("There is a view (" & LinkValidViewName & ") with a link on the drawing. However, the part number cannot be extracted " _
1382 & "because you have created the view and selected geometry (" & LinkValidViewGeometry & ") in the tree before selecting a plane to define the view orienation. " _
1383 & "Please re-create the view without selecting any geometrical sets or bodies in the tree before selecting the view plane orientation.")
1384
1385 TextBoxProductDrawnLinkedGeom.Visible = True
1386 LabelProductDrawnLinkedGeom.Visible = True
1387 TextBoxProductDrawnLinkedGeom.Text = LinkValidViewGeometry
1388 Exit Sub
1389 End If
1390
1391 '###### Fill in form with pointed doc that is found ######
1392
1393 TextBoxProductDrawnDescription.Text = ProductDrawn.DescriptionRef
1394 TextBoxProductDrawnVersion = ProductDrawn.Revision
1395
1396 Dim ProductDrawnType As String
1397 ProductDrawnType = TypeName(ProductDrawn.ReferenceProduct.Parent)
1398
1399 If ProductDrawnType = "ProductDocument" Then
1400 If InStr(ProductDrawn.Parent.Name, "_PVR_") > 0 Then
1401 PointedDocIsPVR = True
1402 End If
1403 TextBoxProductDrawnType.Text = "Product"
1404 ElseIf ProductDrawnType = "PartDocument" Then
1405 TextBoxProductDrawnType.Text = "Part"
1406 Else
1407 TextBoxProductDrawnType.Text = "Unknown"
1408 End If
1409
1410 '##### Op-Hand Part No #####
1411 TextBoxProductDrawnSymOppPartNumber.Text = ProductDrawn.ReferenceProduct.UserRefProperties.GetItem("Op-Hand Part No").Value
1412 If TextBoxProductDrawnSymOppPartNumber.Text = "" Then
1413 TextBoxProductDrawnSymOppPartNumber.Text = "N/A"
1414 Else
1415 'Check for _CA, _TA etc..
1416 If Mid(TextBoxProductDrawnSymOppPartNumber.Text, Len(TextBoxProductDrawnSymOppPartNumber.Text) - 2, 1) = "_" Then
1417 TextBoxProductDrawnSymOppPartNumber.Text = Left(TextBoxProductDrawnSymOppPartNumber.Text, Len(TextBoxProductDrawnSymOppPartNumber.Text) - 3)
1418 Else
1419 TextBoxProductDrawnSymOppPartNumber.Text = TextBoxProductDrawnSymOppPartNumber.Text
1420 End If
1421 End If
1422
1423 '##### Lifed Part #####
1424 TextBoxClassification.Text = ProductDrawn.ReferenceProduct.UserRefProperties.GetItem("Lifed Part").Value
1425 If TextBoxClassification.Text = "" Then
1426 TextBoxClassification.Text = "-"
1427 End If
1428
1429 '##### Serviceable Part #####
1430 TextBoxService.Text = ProductDrawn.ReferenceProduct.UserRefProperties.GetItem("Serviceable Part").Value
1431 If TextBoxService.Text = "" Then
1432 TextBoxService.Text = "-"
1433 End If
1434
1435 On Error GoTo 0
1436
1437 '################################################
1438 'Now check if the part number needs modifying
1439 '################################################
1440
1441 'Fill in the original part number
1442 If PointedDocIsPVR = True Then
1443 TextBoxProductDrawnOrigPartNumber.Text = ProductDrawn.PartNumber & " (PVR)"
1444 Else
1445 TextBoxProductDrawnOrigPartNumber.Text = ProductDrawn.PartNumber
1446 End If
1447
1448 InitBackgroundView
1449
1450 'Update Part Number
1451
1452 'Perform a check on the part number
1453 If Right(ProductDrawn.PartNumber, 3) = "PRC" Then
1454 TextBoxInfoGeneral ("You have created a view of an assembly that is linked to a PRC. " & _
1455 "Please delete your view and re-create the view. This can have the following undesirable effects: " & vbCrLf & _
1456 "Border (Auto) > Update will not display the number (it is now taken from the PRC), " & _
1457 "Opening of additional parts/products from other areas of the PRC will appear in your drawing. " & vbCrLf & _
1458 "When creating views of an assembly from a PRC you must: " & _
1459 "Select desired view (e.g. Front View), Select assy from the CATIA structure, " & _
1460 "Select the geom/plane to infer the direction of the view." & _
1461 " To Edit your view: " & _
1462 "View > RHM > (Front) View Object > Modify Links. " & _
1463 "Ok to warning. Select assy that has PRC within it." & _
1464 "Drawing - Add all in the link mod dialogue. " & _
1465 "Remove PRC link from pointed Elem.")
1466
1467 TextBoxProductDrawnType.Text = "PRC"
1468 Exit Sub
1469 'Check if part number is a CA, TA etc....
1470 ElseIf Mid(ProductDrawn.PartNumber, Len(ProductDrawn.PartNumber) - 2, 1) = "_" Then
1471 TextBoxProductDrawnPartNumber.Text = Left(ProductDrawn.PartNumber, Len(ProductDrawn.PartNumber) - 3)
1472 TextBoxInfoGeneral ("You have created a view of an assembly that is either a _CA, _TA etc..." & vbCrLf & _
1473 "The _## portion has been removed (See generative View Tab)")
1474 Else
1475 TextBoxProductDrawnPartNumber.Text = ProductDrawn.PartNumber
1476 End If
1477
1478 '###################################################################
1479
1480 'Update Material, Spec, Heat Treatment and Finish/Protection (Replace delimiter with a carriage return)
1481 'Also need to check that the part has materials on it
1482 'Set the Check for material parameters to assume they exist
1483 Dim CheckMaterialParameter As Boolean
1484 CheckMaterialParameter = True
1485
1486 'On error allows for parts without any material attributes applied
1487 On Error Resume Next
1488 TextBoxMaterial.Text = Replace(ProductDrawn.ReferenceProduct.UserRefProperties.Item("Material Specification").ValueAsString, "|", vbCrLf)
1489 TextBoxHeatTreatment.Text = Replace(ProductDrawn.ReferenceProduct.UserRefProperties.Item("Heat Treatment").ValueAsString, "|", vbCrLf)
1490 TextBoxFinishProtection.Text = Replace(ProductDrawn.ReferenceProduct.UserRefProperties.Item("Finish/Protection").ValueAsString, "|", vbCrLf)
1491
1492 'If there are no values - default to a dash
1493 If TextBoxMaterial.Text = "" Then
1494 TextBoxMaterial.Text = "-"
1495 End If
1496 If TextBoxHeatTreatment.Text = "" Then
1497 TextBoxHeatTreatment.Text = "-"
1498 End If
1499 If TextBoxFinishProtection.Text = "" Then
1500 TextBoxFinishProtection.Text = "-"
1501 End If
1502
1503 On Error GoTo 0
1504
1505End Sub
1506Private Sub CheckBoxOnlyMainBody_Click()
1507 DisableMainDrawingFormCommands
1508 ResetInformationGeneral
1509 ResetInformationMass
1510 ProductDrawnMassDoc
1511 CommandsControlsEnabledState
1512End Sub
1513Private Sub MassCommandControlsEnabled()
1514 ComboBoxProductDrawnViewMass.Visible = True
1515 ComboBoxProductDrawnViewMass.Enabled = True
1516 ComboBoxProductDrawnViewMass.BackColor = &HC0FFFF
1517 LabelProductDrawnViewMass.Visible = True
1518 LabelProductDrawnOrigPartNumberMass.Visible = True
1519 TextBoxProductDrawnOrigPartNumberMass.Visible = True
1520 LabelProductDrawnMassType.Visible = True
1521 TextBoxProductDrawnMassType.Visible = True
1522 LabelProductDrawnVersionMass.Visible = True
1523 TextBoxProductDrawnMassVersion.Visible = True
1524End Sub
1525Private Sub MassCommandControlsDisabled()
1526 ComboBoxProductDrawnViewMass.Visible = False
1527 ComboBoxProductDrawnViewMass.BackColor = &HE0E0E0
1528 LabelProductDrawnViewMass.Visible = False
1529 LabelProductDrawnOrigPartNumberMass.Visible = False
1530 TextBoxProductDrawnOrigPartNumberMass.Visible = False
1531 LabelProductDrawnMassType.Visible = False
1532 TextBoxProductDrawnMassType.Visible = False
1533 LabelProductDrawnVersionMass.Visible = False
1534 TextBoxProductDrawnMassVersion.Visible = False
1535End Sub
1536Private Sub ProductDrawnMassDoc()
1537 If CheckBoxIndependentMassGenerativeView.Value = False Then
1538 Set ProductDrawnMass = ProductDrawn
1539 Else
1540 '###### Fill in form with pointed doc that is found ######
1541 Dim SelectedViewText As String
1542 Dim SelectedViewID As Integer
1543 SelectedViewText = ComboBoxProductDrawnViewMass.Text
1544 SelectedViewID = (Mid(SelectedViewText, 2, InStr(SelectedViewText, "]") - 2))
1545
1546 '################################################
1547 'First check what the generative view is pointing at
1548 '################################################
1549 On Error Resume Next
1550 If DrwSheet.Views.Item(SelectedViewID).GenerativeBehavior.Document.Parent.Name = "Scenes" Then
1551 If Err.Number <> 0 Then
1552 TextBoxInfoGeneral ("You have a generative view that is linked to a PRC. " & _
1553 "Before the drawing border information can be updated you must:" & vbCrLf & _
1554 "Load the PDM Context of this drawing (data associated with the drawing), " & _
1555 "Select the drawing part number in the top left window, " & _
1556 " Right hand mouse button > select Load PDM Conext")
1557
1558 TextBoxProductDrawnMassType.Text = "PRC"
1559 TextBoxProductDrawnOrigPartNumberMass.Text = ""
1560 Set ProductDrawnMass = Nothing
1561
1562 CommandsControlsEnabledState
1563 Exit Sub
1564 End If
1565
1566 Set ProductDrawnMass = DrwSheet.Views.Item(SelectedViewID).GenerativeBehavior.Document.Parent.Parent
1567 ElseIf DrwSheet.Views.Item(SelectedViewID).GenerativeBehavior.Document.Parent.Name = "Bodies" Then
1568 Set ProductDrawnMass = DrwSheet.Views.Item(SelectedViewID).GenerativeBehavior.Document.Parent.Parent.Parent.Product
1569 ElseIf DrwSheet.Views.Item(SelectedViewID).GenerativeBehavior.Document.Parent.Name = "HybridBodies" Then
1570 Set ProductDrawnMass = DrwSheet.Views.Item(SelectedViewID).GenerativeBehavior.Document.Parent.Parent.Parent.Product
1571 Else
1572 Set ProductDrawnMass = DrwSheet.Views.Item(SelectedViewID).GenerativeBehavior.Document
1573 End If
1574 End If
1575
1576 Dim PointedMassDocIsPVR As Boolean
1577 PointedMassDocIsPVR = False
1578
1579 'If the ProductDrawn was a PRC then the ProductDrawn will not have been set
1580 If ProductDrawnMass Is Nothing Then
1581 ResetMassAndDensity
1582 DissableUpdateMass
1583 CommandProductDrawnDesignMode.Visible = False
1584 CheckBoxOnlyMainBody.Visible = False
1585 Else
1586
1587 'Calculate the type of object
1588 If Right(ProductDrawnMass.PartNumber, 3) = "PRC" Then
1589 TextBoxProductDrawnMassType.Text = "PRC"
1590 CheckBoxOnlyMainBody.Visible = False
1591 CommandProductDrawnDesignMode.Visible = True
1592 Else
1593 Dim ProductDrawnType As String
1594 ProductDrawnType = TypeName(ProductDrawnMass.ReferenceProduct.Parent)
1595
1596 If ProductDrawnType = "ProductDocument" Then
1597 TextBoxProductDrawnMassType.Text = "Product"
1598 CheckBoxOnlyMainBody.Visible = False
1599 CommandProductDrawnDesignMode.Visible = True
1600 If InStr(ProductDrawnMass.Parent.Name, "_PVR_") > 0 Then
1601 PointedMassDocIsPVR = True
1602 End If
1603 ElseIf ProductDrawnType = "PartDocument" Then
1604 TextBoxProductDrawnMassType.Text = "Part"
1605 CheckBoxOnlyMainBody.Visible = True
1606 CommandProductDrawnDesignMode.Visible = False
1607 Else
1608 TextBoxProductDrawnMassType.Text = "Unknown"
1609 CheckBoxOnlyMainBody.Visible = False
1610 CommandProductDrawnDesignMode.Visible = False
1611 End If
1612 End If
1613
1614 'Fill in the original part number
1615 If PointedMassDocIsPVR = True Then
1616 TextBoxProductDrawnOrigPartNumberMass.Value = ProductDrawnMass.PartNumber & " (PVR)"
1617 Else
1618 TextBoxProductDrawnOrigPartNumberMass.Value = ProductDrawnMass.PartNumber
1619 End If
1620 TextBoxProductDrawnMassVersion.Value = ProductDrawnMass.Revision
1621
1622 If TextBoxProductDrawnMassType.Text = "Product" And CalculateProductMass = False Then
1623 DissableUpdateMass
1624 TextBoxProductDrawnCalcMass.Text = ""
1625 TextBoxInfoMass ("The mass of the product has not been calculated as this can take a long time and the product must be in design mode for the calculation to be correct. " & _
1626 "If you want the mass to be calculated, please select the update button next to the mass value. " & _
1627 "This will convert the product to design mode (which can take a long time dependent upon the number of children and their size. " & _
1628 "Alternatively you can use the 'Border (Manual)' tab to enter the mass manually. " & vbCrLf & _
1629 "Please note the mass calculation is dependent upon the product's properties which is not possible through automation: " & vbCrLf & _
1630 " Open the product in it's own window and using your right hand mouse button select: Properties > Mechanical > make sure 'only main bodies' is checked.")
1631 Else
1632 CalculateProductDrawnMass
1633 End If
1634 End If
1635End Sub
1636Private Sub CalculateProductDrawnMass()
1637
1638 '########### Mass ##########
1639 TextBoxProductDrawnCalcMass.Value = Round(ExtractMass(ProductDrawnMass), 1)
1640
1641 'Perform a series of checks on the mass
1642 'Display Message dependent upon wheather the mass is 0
1643 If TextBoxProductDrawnCalcMass = 0 Then
1644 DissableUpdateMass
1645
1646 If TextBoxProductDrawnMassType.Text = "Part" Then
1647 'Check density of the part
1648 If ProductDrawnMass.Parent.Part.Density = 1000 Then
1649 TextBoxInfoMass ("The Density for the generative view pointed part (" & TextBoxProductDrawnOrigPartNumberMass & ") has been found to be 1000Kg_m3, this indicates that no Material has been applied" & vbCrLf & _
1650 "The Mass will not be updated. You may want to consider applying a material and then re-running the drawing border script")
1651 Else
1652 TextBoxInfoMass ("The mass for the generative view pointed part (" & TextBoxProductDrawnOrigPartNumberMass & ") has been calculated to be 0 gm and will not be updated. This can happen if:" & vbCrLf & _
1653 " - You do not have the part open in it's own window (necessary if the 'Only main body' option is set to false)" & vbCrLf & _
1654 " - If you do have the part open and you do have geometry in one of the bodies, you may want to check that the body containing geometry is set as what is known as the 'part body'. " & vbCrLf & _
1655 " You can do this by selecting the body and using the contextual menu - select the 'Change Part Body' option. Please rememeber to re-point your publication if you do this")
1656 End If
1657 ElseIf TextBoxProductDrawnMassType.Text = "Product" Then
1658 TextBoxInfoMass ("The mass for the generative view pointed product (" & TextBoxProductDrawnOrigPartNumberMass & ") has been calculated to be 0 gm and will not be updated." & vbCrLf & _
1659 "The most likely reason for this is because the Product (PVR) is not open in it's own window which is necessary for the mass to be calculated." & vbCrLf & _
1660 "Please open the Product in its own window making sure it's in design mode and run the drawing script again.")
1661 ElseIf TextBoxProductDrawnMassType.Text = "PRC" Then
1662 TextBoxInfoMass ("The mass for the generative view pointed PRC (" & TextBoxProductDrawnOrigPartNumberMass & ") has been calculated to be 0 gm and will not be updated." & vbCrLf & _
1663 "The most likely reason for this is because the PRC has not had any of it's children opened in a window which is necessary for the mass to be calculated." & vbCrLf & _
1664 "Please open the PRC children in a window making sure the children are in design mode and run the drawing script again.")
1665 End If
1666 CommandProductDrawnDesignMode.Visible = False
1667 Else
1668 ChangeMassBackgroundNormal
1669 EnableUpdateMass
1670
1671 If TextBoxProductDrawnMassType.Text = "Product" Or TextBoxProductDrawnMassType.Text = "PRC" Then
1672 TextBoxInfoMass ("The mass has been taken from the product's (" & TextBoxProductDrawnOrigPartNumberMass & ") children. Some parts may include multiple bodies that you do not want to include in the mass calculation." & vbCrLf & _
1673 "This is dependent upon the product's properties and is not possible through automation: " & vbCrLf & _
1674 " Open the product in it's own window and using your right hand mouse button select: Properties > Mechanical > make sure 'only main bodies' is checked." & vbCrLf & _
1675 "You will need to check the mass is correct and may need to manually update the mass using the 'Border (Manual)' Tab > Mass option if you do not feel the mass is correct.")
1676 ElseIf TextBoxProductDrawnMassType.Text = "Part" Then
1677 'Nothing here for now
1678 End If
1679 End If
1680
1681
1682
1683End Sub
1684Private Sub EnableUpdateMass()
1685 'Enable the update of the Mass
1686 CheckBoxUpdateMass.Value = True
1687 CheckBoxUpdateMass2.Value = True
1688 MassCanBeUpdated = True
1689End Sub
1690Private Sub DissableUpdateMass()
1691 'Disable the update of the Mass
1692 CheckBoxUpdateMass.Value = False
1693 CheckBoxUpdateMass2.Value = False
1694 MassCanBeUpdated = False
1695End Sub
1696Private Sub CommandProductDrawnDesignMode_Click()
1697 DisableMainDrawingFormCommands
1698 '#### V5R24 #### ProgressBarDrawingBorder.Value = 25
1699
1700 CalculateProductMass = True
1701 ProductDrawnMass.ApplyWorkMode DESIGN_MODE
1702 '#### V5R24 #### ProgressBarDrawingBorder.Value = 50
1703 ResetInformationMass
1704 ResetInformationGeneral
1705 ProductDrawnMassDoc
1706 '#### V5R24 #### ProgressBarDrawingBorder.Value = 75
1707 CalculateProductMass = False
1708
1709 CommandsControlsEnabledState
1710End Sub
1711Function ExtractMass(MyProduct As Product) As Double
1712
1713 Dim ActiveDoc As Document
1714 Dim MyDoc As Document
1715 Dim MyPart As Part
1716 Dim MyReference As Reference
1717 Dim TheSPAWorkbench As Workbench
1718 Dim TheMeasurable As Measurable
1719 Dim MyVolume As Double
1720 Dim MyInertia 'As Inertia
1721 Dim MyDensity As Double
1722 Dim MyMass As Double
1723
1724 'Need to rememeber the active drawing document so we can re-activate later
1725 Set ActiveDoc = CATIA.ActiveDocument
1726 'Check whether the pointed document is a product or a part
1727 If TypeName(MyProduct.ReferenceProduct.Parent) = "ProductDocument" Then
1728 ExtractMass = Round(MyProduct.Analyze.Mass * 1000, 1)
1729 TextBoxProductDrawnMassDensity.Value = ""
1730 TextBoxProductDrawnMassDensity.Visible = False
1731 LabelProductDrawnMassDensity.Visible = False
1732 Else
1733 TextBoxProductDrawnMassDensity.Visible = True
1734 LabelProductDrawnMassDensity.Visible = True
1735 On Error Resume Next
1736 Set MyDoc = MyProduct.Parent
1737 'If we get an error - the user has pointed the view at an instance of the part - Link is to the instance within a PRC.
1738 If Err.Number <> 0 Then
1739 Set MyDoc = MyProduct.ReferenceProduct.Parent
1740 Set MyPart = MyProduct.ReferenceProduct.Parent.Part
1741 Else
1742 Set MyPart = MyProduct.Parent.Part
1743 End If
1744
1745 On Error GoTo 0
1746
1747 'Calculate the Density
1748 MyDensity = MyPart.Density
1749 TextBoxProductDrawnMassDensity.Value = MyDensity
1750
1751 'If no material has been applied then the Density is defaulted to 1000Kg_m3
1752 'We only want to calculate the density if there is a Material applied
1753
1754 If MyDensity = 1000 Then
1755 ChangeDensityBackgroundWarning
1756 MyMass = 0
1757 Else
1758 ChangeDensityBackgroundNormal
1759 If CheckBoxOnlyMainBody.Value = True Then
1760 'If the user wants to calculate the mass of only the main body (default option)
1761 'Pick up the main part body - assumption is that it's the 1st one
1762 Set MyReference = MyPart.CreateReferenceFromObject(MyPart.MainBody)
1763 'Set referenceObject = "GetReference"
1764 Set TheSPAWorkbench = MyDoc.GetWorkbench("SPAWorkbench")
1765 Set TheMeasurable = TheSPAWorkbench.GetMeasurable(MyReference)
1766
1767 On Error Resume Next
1768 'Multiply by a 1000 to get correct units
1769 MyVolume = TheMeasurable.Volume * 1000
1770 If Err.Number <> 0 Then
1771 'Cannot extract the measureble on the partbody - assume no geometry
1772 ExtractMass = 0
1773 Else
1774 MyMass = MyDensity * MyVolume
1775
1776 'MsgBox "Mass= " & MyMass & "g" & vbCrLf & "Volume= " & MyVolume
1777 ExtractMass = MyMass
1778 End If
1779 On Error GoTo 0
1780 Else
1781 ExtractMass = Round(MyProduct.Analyze.Mass * 1000, 1)
1782 End If
1783 End If
1784 End If
1785End Function
1786Private Sub CommandProcessAndNotesEditor_Click()
1787
1788 ResetInformationGeneral
1789 FormDraftDrawingBorder.Hide
1790
1791 'e.g. \\cad-server\data\Scripts\V5\R24\Environment\Production\Apps\ProcessBoxAndNotesEditor\ProcessBoxAndNotesEditor.App.exe
1792 'PLMScriptsDir=\\cad-server\data\Scripts\V5\R24
1793 'PLMEnvironment=Production
1794
1795 Dim PLMScriptsDir As String
1796 PLMScriptsDir = CATIA.SystemService.Environ("PLMScriptsDir")
1797 Dim PLMEnvironment As String
1798 PLMEnvironment = CATIA.SystemService.Environ("PLMEnvironment")
1799
1800 Dim ExeToRun As String
1801 ExeToRun = PLMScriptsDir & "\Environment\" & PLMEnvironment & "\Apps\ProcessBoxAndNotesEditor\ProcessBoxAndNotesEditor.App.exe"
1802
1803 CATIA.SystemService.ExecuteBackgroundProcessus (ExeToRun)
1804 End
1805
1806End Sub
1807Private Sub CommandDeleteProcessesAndNotes_Click()
1808 DisableMainDrawingFormCommands
1809 ResetInformationGeneral
1810 DrawingProcessBoxDelete
1811 DrawingNotesDelete ' This is the old style notes
1812 DrawingNotesViewDelete ' This is the new style notes
1813 DrawingProcessBoxAndNotesTagDelete
1814 '#### V5R24 #### ProgressBarDrawingBorder.Value = 30
1815 ChangeProcessBoxAndNotes2Create
1816 '#### V5R24 #### ProgressBarDrawingBorder.Value = 70
1817 CommandsControlsEnabledState
1818End Sub
1819Private Sub CommandLayup_Click()
1820 ResetInformationGeneral
1821 FormDraftDrawingBorder.Hide
1822
1823 'e.g. \\cad-server\data\Scripts\V5\R24\Environment\Production\Apps\BoundingBoxAndWetSurfaceAreaUpdater\BoundingBoxAndWetSurfaceAreaUpdater.exe
1824 'PLMScriptsDir=\\cad-server\data\Scripts\V5\R24
1825 'PLMEnvironment=Production
1826
1827 Dim PLMScriptsDir As String
1828 PLMScriptsDir = CATIA.SystemService.Environ("PLMScriptsDir")
1829 Dim PLMEnvironment As String
1830 PLMEnvironment = CATIA.SystemService.Environ("PLMEnvironment")
1831
1832 Dim CompositeLayupExe As String
1833 CompositeLayupExe = PLMScriptsDir & "\Environment\" & PLMEnvironment & "\Apps\CompositeLayup\CompositeLayup.exe"
1834
1835 CATIA.SystemService.ExecuteBackgroundProcessus (CompositeLayupExe)
1836 End
1837 '#### V5R24 #### FormDraftLayup.Show
1838End Sub
1839Private Sub CommandLayupDelete_Click()
1840 DisableMainDrawingFormCommands
1841 DrawingLayupDelete
1842 '#### V5R24 #### ProgressBarDrawingBorder.Value = 30
1843 ChangeLayup2Create
1844 '#### V5R24 #### ProgressBarDrawingBorder.Value = 70
1845 CommandsControlsEnabledState
1846End Sub
1847Private Sub CommandReplaceLogo_Click()
1848 DisableMainDrawingFormCommands
1849 ResetInformationGeneral
1850
1851 'Delete All the logos
1852 InitBackgroundView
1853 DeleteLogoAndCompanySpecificInfo
1854 'For each sheet open the corresponding sheet size template and copy the logo
1855 Dim i As Integer
1856 For i = 1 To DrwSheets.Count
1857 Set DrwSheet = DrwSheets.Item(i)
1858 DrwSheet.Activate
1859 InitBackgroundView
1860
1861 'Need to replace the @hondaracingf1.com with @mercedes-gp.com
1862 'Need to replace the @BrawnGP.com with @mercedes-gp.com
1863 DrwTexts.GetItem("TitleBlock_Text_Email").Text = Replace(DrwTexts.GetItem("TitleBlock_Text_Email").Text, "hondaracingf1.com", "mercedes-gp.com")
1864 DrwTexts.GetItem("TitleBlock_Text_Email").Text = Replace(DrwTexts.GetItem("TitleBlock_Text_Email").Text, "brawngp.com", "mercedes-gp.com")
1865
1866 CurrentSheetProperties
1867 ImportDrawingBorderLogo (TitleDrwName & displayFormat & ".CATDrawing")
1868 Next
1869 'Now activate the 1st page
1870 Set DrwSheet = DrwSheets.Item(1)
1871 DrwSheet.Activate
1872 CommandsControlsEnabledState
1873End Sub
1874Private Sub CommandUpdateBorder_Click()
1875 DisableMainDrawingFormCommands
1876 ResetInformationGeneral
1877
1878 'Delete All the logos
1879 InitBackgroundView
1880 DeleteTolerancingTablesAndDrawingStandardIAndDrawingStandardTextAndReference
1881
1882 If OptionButtonTolStandard.Value = True Then
1883 ChosenTol = "ToleranceTableStandard"
1884 ElseIf OptionButtonTolComposite.Value = True Then
1885 ChosenTol = "ToleranceTableComposites"
1886 ElseIf OptionButtonTolFabrications.Value = True Then
1887 ChosenTol = "ToleranceTableFabrications"
1888 ElseIf OptionButtonTolCastings.Value = True Then
1889 ChosenTol = "ToleranceTableCastings"
1890 ElseIf OptionButtonTolWiring.Value = True Then
1891 ChosenTol = "ToleranceTableWiring"
1892 ElseIf OptionButtonTolPattern.Value = True Then
1893 ChosenTol = "ToleranceTablePattern"
1894 ElseIf OptionButtonTolAdditiveLayerManufacture.Value = True Then
1895 ChosenTol = "ToleranceTableAdditiveLayerManufacture"
1896 ElseIf OptionButtonTolNone.Value = True Then
1897 ChosenTol = "ToleranceTableNone"
1898 End If
1899
1900 'For each sheet open the corresponding sheet size template and copy the Table and update Drawing Standard Text
1901 Dim i As Integer
1902 For i = 1 To DrwSheets.Count
1903 Set DrwSheet = DrwSheets.Item(i)
1904 DrwSheet.Activate
1905 InitBackgroundView
1906
1907 Dim CurrentDrwSheet As DrawingSheet
1908 Set CurrentDrwSheet = DrwSheet
1909 ChosenSize = GetPageSizeFromDrawingSheet(CurrentDrwSheet)
1910
1911 Dim rqdFileName As String
1912 rqdFileName = TitleDrwName & ChosenSize & ".CATDrawing"
1913 '#### V5R24 #### ProgressBarDrawingBorder.Value = 50
1914 ImportDrawingBorderToleranceTablesAndDrawingStandardText (rqdFileName) 'To import the standard frame and titleblock
1915
1916 DrawingBorderReference
1917 Next
1918 'Now activate the 1st page
1919 Set DrwSheet = DrwSheets.Item(1)
1920 DrwSheet.Activate
1921
1922 'Update the Drawing Border Form to display the drawing border version
1923 DrawingBorderCurrentVersion = DrawingBorderNewVersion
1924 UpdateDrawingBorderExistVersion (DrawingBorderNewVersion)
1925
1926 CommandsControlsEnabledState
1927End Sub
1928Private Function GetPageSizeFromDrawingSheet(DrwSheet As DrawingSheet)
1929 If DrwSheet.PaperSize = catPaperA3 Then
1930 GetPageSizeFromDrawingSheet = "A3"
1931 ElseIf DrwSheet.PaperSize = catPaperA2 Then
1932 GetPageSizeFromDrawingSheet = "A2"
1933 ElseIf DrwSheet.PaperSize = catPaperA1 Then
1934 GetPageSizeFromDrawingSheet = "A1"
1935 ElseIf DrwSheet.PaperSize = catPaperA0 Then
1936 GetPageSizeFromDrawingSheet = "A0"
1937 End If
1938End Function
1939Private Sub CommandRevisionCopyFirstSheet_Click()
1940 DisableMainDrawingFormCommands
1941 Dim i As Integer
1942
1943 ResetInformationGeneral
1944 '#### V5R24 #### ProgressBarDrawingBorder.Value = 20
1945 If CheckOtherSheetsDrawingBorder = True Then
1946 '#### V5R24 #### ProgressBarDrawingBorder.Value = 30
1947 'Copy the revisions from 1st sheet
1948 CopyRevisionsFromFirstPage
1949 'Now extract the Drawn, Check & Date from the first page revisions
1950 Dim FirstPageDrawn As String
1951 Dim FirstPageCheck As String
1952 Dim FirstPageDate As String
1953
1954 FirstPageDrawn = DrwTexts.GetItem("TitleBlock_Text_Revision_Drawn").Text
1955 FirstPageCheck = DrwTexts.GetItem("TitleBlock_Text_Revision_Check").Text
1956 FirstPageDate = DrwTexts.GetItem("TitleBlock_Text_Date").Text
1957
1958 '#### V5R24 #### ProgressBarDrawingBorder.Value = 35
1959
1960 If Selection.Count > 0 Then
1961 'Go through the remaining sheets
1962 For i = 2 To DrwSheets.Count
1963 DrwSheets.Item(i).Activate
1964 'Delete the existing revsions
1965 InitBackgroundView
1966 'Delete any existing revisions
1967 DrawingRevisionsDelete
1968 'Paste the revisions that were copied from page 1
1969 PasteRevisions
1970 'Change the Drawn, Check & Date to be the same as the first page revisions
1971 DrwTexts.GetItem("TitleBlock_Text_Revision_Modification_Description").Text = "Initial Release"
1972 DrwTexts.GetItem("TitleBlock_Text_Revision_Drawn").Text = FirstPageDrawn
1973 DrwTexts.GetItem("TitleBlock_Text_Revision_Check").Text = FirstPageCheck
1974 DrwTexts.GetItem("TitleBlock_Text_Date").Text = FirstPageDate
1975
1976 InitMainView
1977
1978 Next
1979 '#### V5R24 #### ProgressBarDrawingBorder.Value = 80
1980 Else
1981 TextBoxInfoGeneral ("There are no revisions on the first page to copy - command aborted")
1982 End If
1983 End If
1984
1985 Selection.Clear
1986
1987 'Finish by activating the original sheet:
1988 DrwSheets.Item(ActiveSheetNumber).Activate
1989 '#### V5R24 #### ProgressBarDrawingBorder.Value = 85
1990
1991 CommandsControlsEnabledState
1992End Sub
1993Private Sub CommandRevisionsReferToFirstSheet_Click()
1994 DisableMainDrawingFormCommands
1995 Dim i As Integer
1996
1997 ResetInformationGeneral
1998 '#### V5R24 #### ProgressBarDrawingBorder.Value = 20
1999 If CheckOtherSheetsDrawingBorder = True Then
2000 '#### V5R24 #### ProgressBarDrawingBorder.Value = 25
2001 'Activate the first sheet
2002 DrwSheets.Item(1).Activate
2003 'Copy the revisions from the first sheet - ignore triangles
2004 InitBackgroundView
2005 'Find all the revisions on the first sheet and extract their type and number
2006 If FindRevisionsOnFirstSheet = True Then
2007 '#### V5R24 #### ProgressBarDrawingBorder.Value = 30
2008 'Now extract the Drawn, Check & Date from the first page revisions
2009 Dim FirstPageDrawn As String
2010 Dim FirstPageCheck As String
2011 Dim FirstPageDate As String
2012
2013 FirstPageDrawn = DrwTexts.GetItem("TitleBlock_Text_Revision_Drawn").Text
2014 FirstPageCheck = DrwTexts.GetItem("TitleBlock_Text_Revision_Check").Text
2015 FirstPageDate = DrwTexts.GetItem("TitleBlock_Text_Date").Text
2016
2017 '#### V5R24 #### ProgressBarDrawingBorder.Value = 35
2018 'Go through the remaining sheets
2019 For i = 2 To DrwSheets.Count
2020 DrwSheets.Item(i).Activate
2021 'Delete the existing revsions
2022 InitBackgroundView
2023 'Delete any drawing revisions
2024 DrawingRevisionsDelete
2025 'Change the rawn, Check & Date to be the same as the first page revisions
2026 DrwTexts.GetItem("TitleBlock_Text_Revision_Modification_Description").Text = "Initial Release"
2027 DrwTexts.GetItem("TitleBlock_Text_Revision_Drawn").Text = FirstPageDrawn
2028 DrwTexts.GetItem("TitleBlock_Text_Revision_Check").Text = FirstPageCheck
2029 DrwTexts.GetItem("TitleBlock_Text_Date").Text = FirstPageDate
2030
2031 AddRevisionsReferringtoFirstPage
2032 ActivateFrontView
2033 Next
2034 '#### V5R24 #### ProgressBarDrawingBorder.Value = 80
2035 End If
2036 End If
2037
2038 'Finish by activating the original sheet:
2039 DrwSheets.Item(ActiveSheetNumber).Activate
2040 CATIA.RefreshDisplay = True
2041
2042 '#### V5R24 #### ProgressBarDrawingBorder.Value = 85
2043 CommandsControlsEnabledState
2044End Sub
2045Private Sub CommandRevisionsReferToFirstSheetWithOneRev_Click()
2046 DisableMainDrawingFormCommands
2047 Dim i As Integer
2048
2049 ResetInformationGeneral
2050 '#### V5R24 #### ProgressBarDrawingBorder.Value = 20
2051 If CheckOtherSheetsDrawingBorder = True Then
2052 '#### V5R24 #### ProgressBarDrawingBorder.Value = 25
2053 'Activate the first sheet
2054 DrwSheets.Item(1).Activate
2055 'Copy the revisions from the first sheet - ignore triangles
2056 InitBackgroundView
2057 'Find all the revisions on the first sheet and extract their type and number
2058 If FindRevisionsOnFirstSheet = True Then
2059 '#### V5R24 #### ProgressBarDrawingBorder.Value = 30
2060 'Go through the remaining sheets
2061 For i = 2 To DrwSheets.Count
2062 Dim CurrentDrwSheet As DrawingSheet
2063 Set CurrentDrwSheet = DrwSheets.Item(i)
2064 CurrentDrwSheet.Activate
2065 'Delete the existing revsions
2066 InitBackgroundView
2067 'Delete any drawing revisions
2068 DrawingRevisionsDelete
2069 UpdateRevisionToReferToFirstPageAndAddRevisionRefTriangle CurrentDrwSheet
2070 ActivateFrontView
2071 Next
2072 '#### V5R24 #### ProgressBarDrawingBorder.Value = 80
2073 End If
2074 End If
2075
2076 'Finish by activating the original sheet:
2077 DrwSheets.Item(ActiveSheetNumber).Activate
2078 CATIA.RefreshDisplay = True
2079
2080 '#### V5R24 #### ProgressBarDrawingBorder.Value = 85
2081 CommandsControlsEnabledState
2082End Sub
2083Private Function CheckOtherSheetsDrawingBorder()
2084 CheckOtherSheetsDrawingBorder = True
2085 Dim i As Integer
2086 'Go through the remaining sheets
2087 For i = 2 To DrwSheets.Count
2088 DrwSheets.Item(i).Activate
2089 'Check a drawing Border exists
2090 If CheckDrawingBorderExists = False Then
2091 TextBoxInfoGeneral ("Sheet (" & i & ") has no drawing border - Add a drawing border to all sheets before using the Revisions commands")
2092 CheckOtherSheetsDrawingBorder = False
2093 End If
2094 Next
2095End Function
2096Private Sub CopyRevisionsFromFirstPage()
2097 'Activate the first sheet
2098 DrwSheets.Item(1).Activate
2099 'Copy the revisions from the first sheet - ignore triangles
2100 InitBackgroundView
2101 ' select every entity that starts with "TitleBlock_Rev" - in any upper/lower case
2102 FilterSelection ("Name=TitleBlock_Rev_*,sel")
2103
2104 'Extract the width - necessary if other sheets are different size from the first
2105 Width = DrwSheet.GetPaperWidth
2106
2107 ' delete all that was selected
2108 If Selection.Count > 0 Then
2109 Selection.Copy
2110 End If
2111End Sub
2112Private Sub AddRevisionsReferringtoFirstPage()
2113 Dim MyRevisionsArray As Variant
2114 Dim i As Integer
2115
2116 For i = 0 To UBound(CapturedRevisions())
2117 'Extracted from the first sheet
2118 MyRevisionsArray = Split(CapturedRevisions(i), "|")
2119
2120 AddDotRevision = MyRevisionsArray(0)
2121
2122 'Need to fill in the textbox as this will be used when creating the revision
2123 If AddDotRevision = True Then
2124 TextBoxNextRevisionTextDot.Value = MyRevisionsArray(1)
2125 Else
2126 TextBoxNextRevisionTextMajor.Value = MyRevisionsArray(1)
2127 End If
2128
2129 AddRevisionBlockFromFirstSheet (i + 1)
2130 'Once you have added a revision, you need to change the Initials, Checker's Initials, Date
2131
2132 DrwTexts.GetItem("TitleBlock_Rev_Text_Initials_" & (i + 2)).Text = MyRevisionsArray(2)
2133 DrwTexts.GetItem("TitleBlock_Rev_Text_Checked_Initials_" & (i + 2)).Text = MyRevisionsArray(3)
2134 DrwTexts.GetItem("TitleBlock_Rev_Text_Date_" & (i + 2)).Text = MyRevisionsArray(4)
2135 Next
2136End Sub
2137Private Sub UpdateRevisionToReferToFirstPageAndAddRevisionRefTriangle(DrwSheet As DrawingSheet)
2138 Dim LastRevisionIndex As Integer
2139 Dim MyRevisionsArray As Variant
2140 Dim LastRevNumb As String
2141 Dim LastRevDrawnBy As String
2142 Dim LastRevCheckedBy As String
2143 Dim LastRevDate As String
2144
2145 LastRevisionIndex = UBound(CapturedRevisions())
2146
2147 MyRevisionsArray = Split(CapturedRevisions(LastRevisionIndex), "|")
2148
2149 'Example below
2150 'True|01.1|MJM|PDF|22 Jun 2015
2151 LastRevNumb = MyRevisionsArray(1)
2152 LastRevDrawnBy = MyRevisionsArray(2)
2153 LastRevCheckedBy = MyRevisionsArray(3)
2154 LastRevDate = MyRevisionsArray(4)
2155
2156 'This is to cope with drawings that have been manually manipulated and potnetially don't have the correct Text objects
2157 On Error Resume Next
2158
2159 DrwTexts.GetItem("Frame_Text_Rev_1").Text = LastRevNumb
2160 DrwTexts.GetItem("TitleBlock_Text_Revision_Modification_Description").Text = "REFER TO SHEET 1"
2161 DrwTexts.GetItem("TitleBlock_Text_Revision_Drawn").Text = LastRevDrawnBy
2162 DrwTexts.GetItem("TitleBlock_Text_Revision_Check").Text = LastRevCheckedBy
2163 DrwTexts.GetItem("TitleBlock_Text_Date").Text = LastRevDate
2164
2165 On Error GoTo 0
2166
2167 Dim LastRevisionIdentifier As Integer
2168 LastRevisionIdentifier = LastRevisionIndex + 2
2169
2170 Dim CurrentDrawingSheetWidth As Double
2171 CurrentDrawingSheetWidth = DrwSheet.GetPaperWidth
2172 AddRevisionBlueTriangle LastRevNumb, LastRevisionIdentifier, (CurrentDrawingSheetWidth - 190) - 10, 94.5
2173
2174End Sub
2175Private Sub AddBlueTriangleForRevisionReferingToFirstPage()
2176
2177End Sub
2178Private Sub PasteRevisions()
2179 Selection.Clear
2180 Selection.Add DrwSheets.ActiveSheet.Views.Item(2)
2181 Selection.Paste
2182 MoveRevisions
2183 'The command above activates the background view, so we have to re-activate the Main view
2184 DrwSheets.ActiveSheet.Views.Item(1).Activate
2185End Sub
2186Private Sub MoveRevisions()
2187 Dim i As Integer
2188 Dim ItemToMove As SelectedElement
2189 Dim Origin(2)
2190 Dim Direction(2)
2191 Dim TranslationX As Double
2192 Dim TranslationY As Double
2193
2194 ' Move all that was selected (selection comes from items that were pasted
2195
2196 TranslationY = 0
2197 'Note the width that is used below has been taken from the first sheet
2198 TranslationX = DrwSheet.GetPaperWidth - Width
2199 'Now reset the width back to the current sheet
2200 'Width = DrwSheet.GetPaperWidth
2201 'MsgBox TranslationX & vbCrLf & DrwSheet.GetPaperWidth & vbCrLf & Width
2202 Dim MyLine2D As Line2D
2203
2204 If TranslationX <> 0 Then
2205 For i = 1 To Selection.Count
2206 Set ItemToMove = Selection.Item(i)
2207 If ItemToMove.Type = "Line2D" Then
2208 ItemToMove.Value.GetOrigin Origin
2209 ItemToMove.Value.GetDirection Direction
2210 Set MyLine2D = ItemToMove.Value
2211 MyLine2D.SetData Origin(0) + TranslationX, Origin(1) + TranslationY, Direction(0), Direction(1)
2212 ElseIf ItemToMove.Type = "DrawingText" Then
2213 ItemToMove.Value.X = ItemToMove.Value.X + TranslationX
2214 ItemToMove.Value.Y = ItemToMove.Value.Y + TranslationY
2215 End If
2216 Next
2217 End If
2218End Sub
2219Private Sub DeleteLogoAndCompanySpecificInfo()
2220 'Necessary for the selection in R19 - removed in R22
2221 'CATIA.HSOSynchronized = False
2222
2223 'Select all Logo entities and company info
2224 Selection.Search "(Name=Frame*Logo* + Name=Frame_Text_Copyright + Name=Frame_Text_address),all"
2225
2226 'Necessary for the selection in R19 - removed in R22
2227 'CATIA.HSOSynchronized = True
2228
2229 'IN CASE THERE IS NOTHING TO DELETE
2230 On Error Resume Next
2231 Selection.Delete
2232 On Error GoTo 0
2233End Sub
2234Private Sub DeleteTolerancingTablesAndDrawingStandardIAndDrawingStandardTextAndReference()
2235 'Necessary for the selection in R19 - removed in R22
2236 'CATIA.HSOSynchronized = False
2237
2238 Selection.Search "(Name=ToleranceTable* + Name=Frame_Text_Drawing_Standard_I + Name=Frame_TitleBlock_Standard_Lines_1 + Name=Frame_TitleBlock_Standard_Lines_11 + Name=Frame_TitleBlock_Standard_Lines_12 + Name=Frame_Text_Dimnesion_in_mm + Name=Reference_*),all"
2239
2240 'Necessary for the selection in R19 - removed in R22
2241 'CATIA.HSOSynchronized = True
2242
2243 'IN CASE THERE IS NOTHING TO DELETE
2244 On Error Resume Next
2245 Selection.Delete
2246 On Error GoTo 0
2247End Sub
2248Private Sub ImportDrawingBorderLogo(drawingName As String)
2249 CATIA.DisplayFileAlerts = False
2250 Dim MyDocuments As Documents
2251 Dim TemplateDrawing As Document
2252 Dim OriginalDocument As Document
2253 Dim TemplateSelection 'As selection
2254 Dim OrigDwrSheets As DrawingSheets
2255 Dim OrigDwrSheet As DrawingSheet
2256 Dim OrigDwrViews As DrawingViews
2257 Dim OrigDwrView As DrawingView
2258 Dim OrigDrwSelection As Selection
2259
2260 ' note the original document and the current sheet and view names
2261 Set OriginalDocument = CATIA.ActiveDocument
2262 Set OrigDwrSheets = DrwDocument.Sheets
2263 Set OrigDwrSheet = OrigDwrSheets.ActiveSheet
2264 Set OrigDwrViews = OrigDwrSheet.Views
2265 Set OrigDwrView = OrigDwrViews.ActiveView
2266
2267 ' open the drawing that contains the titleblock that we want
2268 Set MyDocuments = CATIA.Documents
2269 Set TemplateDrawing = MyDocuments.Open(drawingName)
2270 'TemplateDrawing.Activate
2271
2272 ' select every entity that starts with the name "titleblock" - in any upper/lower case
2273 Set TemplateSelection = TemplateDrawing.Selection
2274 TemplateSelection.Clear
2275
2276 '########## Copy the LOGO data #############
2277
2278 'Necessary for the selection in R19 - removed in R22
2279 'CATIA.HSOSynchronized = False
2280
2281 'Select all Logo entities
2282 TemplateSelection.Search "(Name=Frame*Logo* + Name=Frame_Text_Copyright + Name=Frame_Text_address),all"
2283
2284 TemplateSelection.Copy
2285 TemplateSelection.Clear
2286
2287 'Necessary for the selection in R19 - removed in R22
2288 'CATIA.HSOSynchronized = True
2289
2290 ' get to the background view on that sheet and set it as the active view
2291 Set OrigDwrViews = OrigDwrSheet.Views
2292 Set OrigDwrView = OrigDwrViews.Item(2)
2293
2294 ' Create an object of selection for the source document
2295 Set OrigDrwSelection = DrwDocument.Selection
2296
2297 ' Clear the selection then add the view to which the geometry will be pasted in the selection
2298 OrigDrwSelection.Clear
2299 OrigDrwSelection.Add OrigDwrView
2300
2301 ' Paste the clipboard and clear the selection
2302 OrigDrwSelection.Paste
2303 OrigDrwSelection.Clear
2304
2305 'close the template drawing
2306 TemplateDrawing.Close
2307
2308 'Activate front view - this is necessary as the paste automatically activates the background view
2309 Set OrigDwrView = OrigDwrViews.Item(1)
2310 OrigDwrView.Activate
2311
2312 'Activate the original drawing - necessary to update the display
2313 OriginalDocument.Activate
2314
2315End Sub
2316Private Sub CommandInitialRelease_Click()
2317 DisableMainDrawingFormCommands
2318 ResetInformationGeneral
2319 InitBackgroundView
2320
2321 DrwTexts.GetItem("TitleBlock_Text_Revision_Modification_Description").Text = "Initial Release"
2322 DrwTexts.GetItem("Frame_Text_Rev_1").Text = "01.0"
2323
2324 '#### V5R24 #### ProgressBarDrawingBorder.Value = 30
2325 UpdateDrawingBorderFields
2326 '#### V5R24 #### ProgressBarDrawingBorder.Value = 60
2327 RevisionBlockCheckedInitials
2328 '#### V5R24 #### ProgressBarDrawingBorder.Value = 70
2329 RevisionsValuesInitialRevision
2330 '#### V5R24 #### ProgressBarDrawingBorder.Value = 75
2331 'CheckRevisionCanbeAdded
2332 '#### V5R24 #### ProgressBarDrawingBorder.Value = 80
2333 CommandsControlsEnabledState
2334End Sub
2335Private Sub CommandManual_Click()
2336 ResetInformationGeneral
2337 FormDraftDrawingBorder.Hide
2338 FormDraftInitialRelease.Show
2339 CommandsControlsEnabledState
2340End Sub
2341Private Sub CommandMass_Click()
2342 DisableMainDrawingFormCommands
2343 InitBackgroundView
2344 DrwTexts.GetItem("TitleBlock_Text_Estimated_Mass").Text = TextBoxMass.Text
2345 CommandsControlsEnabledState
2346End Sub
2347Private Sub TextBoxMass_Change()
2348 If TextBoxMass.Text <> "" And IsNumeric(TextBoxMass.Text) Then
2349 MassManualCanBeAdded = True
2350 TextBoxMassManualGood
2351 Else
2352 MassManualCanBeAdded = False
2353 TextBoxMassManualWarning
2354 End If
2355End Sub
2356Private Sub TextBoxMassManualWarning()
2357 TextBoxMass.BackColor = &HC0C0FF
2358 CommandMass.Enabled = False
2359End Sub
2360Private Sub TextBoxMassManualGood()
2361 TextBoxMass.BackColor = &HC0FFFF
2362 CommandMass.Enabled = True
2363End Sub
2364Private Sub CommandUpdateFieldManual_Click()
2365 ResetInformationGeneral
2366 FormDraftDrawingBorder.Hide
2367 FormDraftUpdateField.Show
2368 CommandsControlsEnabledState
2369End Sub
2370Private Sub UpdateDrawingBorderFields()
2371 DrwTexts.GetItem("TitleBlock_Text_Date").Text = TextBoxDate.Text
2372 DrwTexts.GetItem("TitleBlock_Text_Revision_Drawn").Text = TextBoxRevisionDrawnInitials.Text
2373 DrwTexts.GetItem("TitleBlock_Text_Drawn").Text = TextBoxDrawn.Text
2374 DrwTexts.GetItem("TitleBlock_Text_Phone").Text = TextBoxPhoneNumber.Text
2375 DrwTexts.GetItem("TitleBlock_Text_Email").Text = TextBoxEmail.Text
2376End Sub
2377Private Sub CommandMajorRelease_Click()
2378 DisableMainDrawingFormCommands
2379 'ResetInformationGeneral
2380 ResetInformationRevision
2381
2382 CheckRevisionCanbeAdded
2383
2384 If RevisionCanBeAdded = True Then
2385 CheckInformationTabs
2386 'Set the boolean to indicate a modification
2387 RevisionModification = False
2388 'set whether to Add dot revision or not
2389 AddDotRevision = False
2390 'Check Whether the Initial Release has been changed
2391 DisplayRevisionFormForUserInput
2392 Else
2393 CommandsControlsEnabledState
2394 End If
2395End Sub
2396Private Sub CommandDotRelease_Click()
2397 DisableMainDrawingFormCommands
2398 ResetInformationGeneral
2399
2400 'CheckRevisionCanbeAdded
2401 'CheckInformationTabs
2402
2403 'Set the boolean to indicate a modification
2404 RevisionModification = False
2405 'set whether to Add dot revision or not
2406 AddDotRevision = True
2407 'Check Whether the Initial Release has been changed
2408 DisplayRevisionFormForUserInput
2409End Sub
2410Private Sub DisplayRevisionFormForUserInput()
2411
2412 '#### V5R24 #### ProgressBarDrawingBorder.Value = 20
2413
2414 InitBackgroundView
2415
2416 'Show the input frame
2417 FrameReleaseDescription.Visible = True
2418 FormDraftDrawingBorder.Height = FormHeightLarge
2419
2420 '#### V5R24 #### ProgressBarDrawingBorder.Value = 50
2421 'MAKE THE TEXTBOX SELECTED
2422 TextBoxUserInput.SetFocus
2423 TextBoxUserInput.Text = ""
2424 FrameReleaseDescription.Caption = "Issue Description"
2425 'Make sure button reads Add
2426 CommandDescriptionModify.Caption = " Add"
2427 '#### V5R24 #### ProgressBarDrawingBorder.Value = 100
2428 '#### V5R24 #### ProgressBarDrawingBorder.Visible = False
2429
2430 EnableRevisionModAdd
2431End Sub
2432Private Sub TextBoxUserInput_Change()
2433 CheckRevisionDescription
2434End Sub
2435Private Sub CheckRevisionDescription()
2436 If TextBoxUserInput.Text <> "" Then
2437 CommandDescriptionModify.Enabled = True
2438 Else
2439 CommandDescriptionModify.Enabled = False
2440 End If
2441End Sub
2442Private Sub CommandDescriptionModify_Click()
2443 DisableMainDrawingFormCommands
2444 Description = TextBoxUserInput.Text
2445 If FrameReleaseDescription.Caption = "Modify Latest Issue Description" Then
2446 DrawingRevisionsLastDelete
2447 ResetInformationRevision
2448 '#### V5R24 #### ProgressBarDrawingBorder.Value = 20
2449 AddRevisionBlock
2450 Else
2451 ResetInformationRevision
2452 AddRevisionBlock
2453 End If
2454 ActivateFrontView
2455 FindCurrentRevision
2456
2457 CommandsControlsEnabledState
2458End Sub
2459Private Sub ActivateFrontView()
2460 InitMainView
2461 DrwView.Activate
2462End Sub
2463Private Sub AddRevisionBlock()
2464 Dim X As Double
2465 Dim Y As Double
2466
2467 'To compute standard sizes
2468 CurrentSheetProperties
2469
2470 CATRevPos TextBoxCurrentRevisionIdentifier.Text
2471 '#### V5R24 #### ProgressBarDrawingBorder.Value = 40
2472 CATRevisionBlock TextBoxCurrentRevisionIdentifier.Text + 1, X, Y
2473 '#### V5R24 #### ProgressBarDrawingBorder.Value = 60
2474 'Activate the original drawing - necessary to update the display
2475 CATIA.ActiveDocument.Activate
2476 '#### V5R24 #### ProgressBarDrawingBorder.Value = 80
2477End Sub
2478Private Sub AddRevisionBlockFromFirstSheet(RevisionIdentifier As Integer)
2479 Dim X As Double
2480 Dim Y As Double
2481
2482 'To compute standard sizes
2483 CurrentSheetProperties
2484 CATRevPos RevisionIdentifier
2485
2486 NumbRevLines = 1
2487 RevisionModification = True
2488
2489 'Get designer to input the revision block text
2490 X = Width - 190
2491 CATRevisionBlockFrame RevisionIdentifier + 1, X, Ypos 'To draw the geometry
2492 CATRevisionBlockText "SEE SHEET 1", RevisionIdentifier + 1, X, Ypos 'To fill in the title block
2493 'InitBackgroundView
2494End Sub
2495Sub CATRevisionBlockReferenceFirstSheet(NewRevIdentifier As Integer, X As Double, Y As Double)
2496 '-------------------------------------------------------------------------------
2497 'How to create the revision block
2498 '-------------------------------------------------------------------------------
2499 Dim i As Integer
2500
2501 'Default number of lines for a single revision block to 1
2502
2503 'This was used to modify the drawn by, e-mail and phone but was asked to be removed by Geoff Clarke
2504 'Update (False)
2505End Sub
2506Sub CATRevPos(CurrentRevIdentifier As Integer)
2507 '-------------------------------------------------------------------------------
2508 'How to local the the current revision Y Pos
2509 '-------------------------------------------------------------------------------
2510 If (CurrentRevIdentifier = 1) Then
2511 Ypos = 94.5
2512 Else
2513 InitBackgroundView
2514 Ypos = DrwTexts.GetItem("TitleBlock_Rev_Numb_Text_" + CStr(CurrentRevIdentifier)).Y
2515 End If
2516End Sub
2517Sub CATRevisionBlock(NewRevIdentifier As Integer, X As Double, Y As Double)
2518 '-------------------------------------------------------------------------------
2519 'How to create the revision block
2520 '-------------------------------------------------------------------------------
2521
2522 InitBackgroundView
2523
2524 Dim i As Integer
2525
2526 'Default number of lines for a single revision block to 1
2527 NumbRevLines = 1
2528
2529 'MsgBox Len(Description) & " " & Len(Description) / 58 & " " & CInt(Len(Description) / 58)
2530 'NumbRevLines = CInt(Len(Description) / 58) + 1
2531 TextBoxUserInput.SetFocus
2532 NumbRevLines = TextBoxUserInput.LineCount
2533 'Cannot hide the box until the Linecount is calculated as it needs the focus of the textbox
2534 HideRevisionInputFrame
2535 'Define the location of the top left of the Titleblock
2536 X = Width - 190
2537 CATRevisionBlockFrame NewRevIdentifier, X, Ypos 'To draw the geometry
2538 CATRevisionBlockText Description, NewRevIdentifier, X, Ypos 'To fill in the title block
2539 InitBackgroundView
2540 'This was used to modify the drawn by, e-mail and phone but was asked to be removed by Geoff Clarke
2541 'Update (False)
2542
2543End Sub
2544Private Sub HideRevisionInputFrame()
2545 FrameReleaseDescription.Visible = False
2546 FormDraftDrawingBorder.Height = FormHeightSmall
2547End Sub
2548Private Sub CommandDescriptionCancel_Click()
2549 'Show the input frame
2550 FrameReleaseDescription.Visible = False
2551 FormDraftDrawingBorder.Height = FormHeightSmall
2552 CommandsControlsEnabledState
2553End Sub
2554Sub CATRevisionBlockText(Description As String, NewRevIdentifier As Integer, X As Double, Y As Double)
2555 '-------------------------------------------------------------------------------
2556 'How to fill in the revision block
2557 '-------------------------------------------------------------------------------
2558
2559 Dim RevTextSize As Double
2560
2561 If AddDotRevision = True Then
2562 RevBlockText = TextBoxNextRevisionTextDot.Value
2563 Else
2564 RevBlockText = TextBoxNextRevisionTextMajor.Value
2565 End If
2566
2567 InitBackgroundView
2568
2569 Set Text = DrwTexts.Add(RevBlockText, X + (0.5 * (RevisionBlockColumn0 + RevisionBlockColumn1)), Ypos + RevisionBlockHeight + (NumbRevLines - 1) * RevisionBlockHeight)
2570 CATFormatRBText "TitleBlock_Rev_Numb_Text_" & NewRevIdentifier, catMiddleCenter, 2.5
2571 SetTextVisProp
2572
2573 RevTextSize = 2.5
2574
2575 'Description
2576 Set Text = DrwTexts.Add(Description, X + (0.5 * (RevisionBlockColumn1 + RevisionBlockColumn2)) + 1, Ypos + (0.5 * RevisionBlockHeight) + 0.5 * NumbRevLines * RevisionBlockHeight)
2577 Text.WrappingWidth = 125
2578 Text.SetParameterOnSubString catAlignment, 1, Len(Text.Text), catCenter
2579 CATFormatRBText "TitleBlock_Rev_Text_Description_" & NewRevIdentifier, catMiddleCenter, RevTextSize
2580 SetTextVisProp
2581
2582 Set Text = DrwTexts.Add(TextBoxRevisionDrawnInitials.Text, X + (0.5 * (RevisionBlockColumn2 + RevisionBlockColumn3)), Ypos + RevisionBlockHeight + (NumbRevLines - 1) * RevisionBlockHeight)
2583 CATFormatRBText "TitleBlock_Rev_Text_Initials_" & NewRevIdentifier, catMiddleCenter, 2.5
2584 SetTextVisProp
2585 'Checked Initials
2586 Set Text = DrwTexts.Add(TextBoxCheckersInitials.Text, X + (0.5 * (RevisionBlockColumn3 + RevisionBlockColumn4)), Ypos + RevisionBlockHeight + (NumbRevLines - 1) * RevisionBlockHeight)
2587 CATFormatRBText "TitleBlock_Rev_Text_Checked_Initials_" & NewRevIdentifier, catMiddleCenter, 2.5
2588 SetTextVisProp
2589 'Date
2590 Set Text = DrwTexts.Add(CATmyDateTimeFormat(Date), X + (0.5 * (RevisionBlockColumn4 + RevisionBlockColumn5)), Ypos + RevisionBlockHeight + (NumbRevLines - 1) * RevisionBlockHeight)
2591 Text.SetParameterOnSubString catCharRatio, 1, Len(Text.Text), 70
2592 CATFormatRBText "TitleBlock_Rev_Text_Date_" & NewRevIdentifier, catMiddleCenter, 2.5
2593 SetTextVisProp
2594
2595 'Only add triangle if not a modification of issue
2596 If RevisionModification = False Then
2597
2598 AddRevisionBlueTriangle RevBlockText, NewRevIdentifier, X - 10, Ypos + RevisionBlockHeight + (NumbRevLines - 1) * RevisionBlockHeight
2599
2600' 'Now need to add the blue triangle text
2601' InitMainView
2602'
2603' Set Text = DrwTexts.Add(RevBlockText, X - 10, Ypos + RevisionBlockHeight + (NumbRevLines - 1) * RevisionBlockHeight)
2604' Text.SetParameterOnSubString catCharRatio, 1, Len(Text.Text), 50
2605' Text.ActivateFrame (catTriangle)
2606' 'If you want to use the triangle that has a fixed size then you can use the number instead as below
2607' 'Text.ActivateFrame (56)
2608' Text.SetParameterOnSubString catBold, 1, Len(Text.Text), 2
2609' CATFormatRBText "TitleBlock_Triangle_" & NewRevIdentifier, catMiddleCenter, 3
2610' SetTextRevisionVisProp
2611 End If
2612End Sub
2613Sub AddRevisionBlueTriangle(TextToAdd As String, NewRevIdentifier As Integer, X As Double, Y As Double)
2614 'Now need to add the blue triangle text
2615 InitMainView
2616
2617 Set Text = DrwTexts.Add(TextToAdd, X, Y)
2618 Text.SetParameterOnSubString catCharRatio, 1, Len(Text.Text), 50
2619 Text.ActivateFrame (catTriangle)
2620 'If you want to use the triangle that has a fixed size then you can use the number instead as below
2621 'Text.ActivateFrame (56)
2622 Text.SetParameterOnSubString catBold, 1, Len(Text.Text), 2
2623 CATFormatRBText "TitleBlock_Triangle_" & NewRevIdentifier, catMiddleCenter, 3
2624 SetTextRevisionVisProp
2625End Sub
2626Sub CATRevisionBlockFrame(NewRevIdentifier As Integer, X As Double, Y As Double)
2627 '-------------------------------------------------------------------------------
2628 'How to draw the revision block geometry
2629 '-------------------------------------------------------------------------------
2630' 'Activate the background View - Need to do this otherwise the lines will not be created
2631 DrwView.Activate
2632
2633 Set Line = Fact.CreateLine(X + RevisionBlockColumn0, Ypos + 0.5 * RevisionBlockHeight + NumbRevLines * RevisionBlockHeight, X + RevisionBlockColumn0, Ypos + 0.5 * RevisionBlockHeight)
2634 Line.Name = "TitleBlock_Rev_Line_" & NewRevIdentifier & ".1"
2635 SetLineVisProp
2636 Set Line = Fact.CreateLine(X + RevisionBlockColumn1, Ypos + 0.5 * RevisionBlockHeight + NumbRevLines * RevisionBlockHeight, X + RevisionBlockColumn1, Ypos + 0.5 * RevisionBlockHeight)
2637 Line.Name = "TitleBlock_Rev_Line_" & NewRevIdentifier & ".2"
2638 SetLineVisProp
2639 Set Line = Fact.CreateLine(X + RevisionBlockColumn2, Ypos + 0.5 * RevisionBlockHeight + NumbRevLines * RevisionBlockHeight, X + RevisionBlockColumn2, Ypos + 0.5 * RevisionBlockHeight)
2640 Line.Name = "TitleBlock_Rev_Line_" & NewRevIdentifier & ".3"
2641 SetLineVisProp
2642 Set Line = Fact.CreateLine(X + RevisionBlockColumn3, Ypos + 0.5 * RevisionBlockHeight + NumbRevLines * RevisionBlockHeight, X + RevisionBlockColumn3, Ypos + 0.5 * RevisionBlockHeight)
2643 Line.Name = "TitleBlock_Rev_Line_" & NewRevIdentifier & ".4"
2644 SetLineVisProp
2645 Set Line = Fact.CreateLine(X + RevisionBlockColumn4, Ypos + 0.5 * RevisionBlockHeight + NumbRevLines * RevisionBlockHeight, X + RevisionBlockColumn4, Ypos + 0.5 * RevisionBlockHeight)
2646 Line.Name = "TitleBlock_Rev_Line_" & NewRevIdentifier & ".5"
2647 SetLineVisProp
2648 Set Line = Fact.CreateLine(X, Ypos + 0.5 * RevisionBlockHeight + NumbRevLines * RevisionBlockHeight, X + RevisionBlockColumn5, Ypos + 0.5 * RevisionBlockHeight + NumbRevLines * RevisionBlockHeight)
2649 Line.Name = "TitleBlock_Rev_Line_" & NewRevIdentifier & ".6"
2650 SetLineVisProp
2651End Sub
2652Private Sub CommandRevisionBlockCheckedInitials_Click()
2653 DisableMainDrawingFormCommands
2654 RevisionBlockCheckedInitials
2655 CommandsControlsEnabledState
2656End Sub
2657Private Sub RevisionBlockCheckedInitials()
2658
2659 ResetInformationGeneral
2660 '#### V5R24 #### ProgressBarDrawingBorder.Value = 80
2661 InitBackgroundView
2662
2663 '#### V5R24 #### ProgressBarDrawingBorder.Visible = False
2664
2665 If TextBoxCurrentRevisionIdentifier.Text > 1 Then
2666 'Change the latest revision block Initials - Need to use the TextBoxCurrentRevisionIdentifier.Text sub routine to find number
2667 DrwTexts.GetItem("TitleBlock_Rev_Text_Checked_Initials_" & TextBoxCurrentRevisionIdentifier.Text).Text = TextBoxCheckersInitials.Text
2668 Else
2669 DrwTexts.GetItem("TitleBlock_Text_Revision_Check").Text = TextBoxCheckersInitials.Text
2670 End If
2671
2672End Sub
2673Private Sub CommandRevisionMod_Click()
2674 DisableMainDrawingFormCommands
2675 ResetInformationGeneral
2676 '#### V5R24 #### ProgressBarDrawingBorder.Value = 20
2677 'Set the boolean to indicate a modification
2678 RevisionModification = True
2679
2680 InitBackgroundView
2681
2682 'Promt user to input revision text - also placing the original text in it
2683
2684 'Show the input frame
2685 FrameReleaseDescription.Visible = True
2686 FormDraftDrawingBorder.Height = FormHeightLarge
2687 'Put the focus on the textbox
2688 TextBoxUserInput.SetFocus
2689 '#### V5R24 #### ProgressBarDrawingBorder.Value = 50
2690 'Make sure button reads Add
2691 CommandDescriptionModify.Caption = " Modify"
2692 FrameReleaseDescription.Caption = "Modify Latest Issue Description"
2693 TextBoxUserInput.Text = DrwTexts.GetItem("TitleBlock_Rev_Text_Description_" & TextBoxCurrentRevisionIdentifier.Text).Text
2694
2695 '#### V5R24 #### ProgressBarDrawingBorder.Value = 80
2696
2697 'need to check if the last issue was a dot revision or up-issue
2698 'If the dot revision text is = 0 then the last revision must have been a Major revision
2699 If TextBoxCurrentDotRevision.Text = 0 Then
2700 AddDotRevision = False
2701 Else
2702 AddDotRevision = True
2703 End If
2704
2705 '#### V5R24 #### ProgressBarDrawingBorder.Value = 90
2706 '#### V5R24 #### ProgressBarDrawingBorder.Visible = False
2707
2708 EnableRevisionModAdd
2709
2710End Sub
2711Private Sub CommandRevisionsDelete_Click()
2712 DisableMainDrawingFormCommands
2713 ResetInformationGeneral
2714 ResetInformationRevision
2715 DrawingRevisionsDelete
2716 '#### V5R24 #### ProgressBarDrawingBorder.Value = 30
2717 DrawingTrianglesDelete
2718 '#### V5R24 #### ProgressBarDrawingBorder.Value = 50
2719 ResetProvisionalAndDrawnAndCheck
2720 '#### V5R24 #### ProgressBarDrawingBorder.Value = 80
2721 CommandsControlsEnabledState
2722End Sub
2723Private Sub ResetProvisionalAndDrawnAndCheck()
2724 RevisionsValuesProvisionalRevision
2725 InitBackgroundView
2726 UpdateDrawingBorderFields
2727 DrwTexts.GetItem("TitleBlock_Text_Revision_Modification_Description").Text = "------ Provisional ------"
2728 DrwTexts.GetItem("TitleBlock_Text_Revision_Drawn").Text = "-"
2729 DrwTexts.GetItem("TitleBlock_Text_Revision_Check").Text = "-"
2730End Sub
2731Private Sub CommandRevisionsLastDelete_Click()
2732 DisableMainDrawingFormCommands
2733 ResetInformationGeneral
2734 ResetInformationRevision
2735 '#### V5R24 #### ProgressBarDrawingBorder.Value = 30
2736 DrawingRevisionsLastDelete
2737 '#### V5R24 #### ProgressBarDrawingBorder.Value = 80
2738 InitBackgroundView
2739
2740 '#### V5R24 #### ProgressBarDrawingBorder.Value = 90
2741
2742 'Activate the original drawing - necessary to update the display
2743 CATIA.ActiveDocument.Activate
2744 CommandsControlsEnabledState
2745End Sub
2746Sub CATFormatRBText(textName As String, anchorPosition As String, fontSize As Double)
2747 '-------------------------------------------------------------------------------
2748 'How to format the texts belonging to the titleblock
2749 '-------------------------------------------------------------------------------
2750 Text.Name = textName
2751 Text.anchorPosition = anchorPosition
2752 Text.SetFontSize 0, 0, fontSize
2753
2754End Sub
2755Private Sub SetLineVisProp()
2756 'This Sets the properties of the line
2757
2758 Dim MyVisProps As VisPropertySet
2759
2760 Selection.Clear
2761 Selection.Add Line
2762
2763 Set MyVisProps = Selection.VisProperties
2764
2765 'Set the line width type
2766 MyVisProps.SetRealWidth 1, 0
2767 'Set the line colour
2768 MyVisProps.SetRealColor 118, 118, 118, 0
2769
2770 'Deselect everything
2771 Selection.Clear
2772End Sub
2773Private Sub SetTextRevisionVisProp()
2774 'This Sets the properties of the line
2775 Dim MySelection As Selection
2776 Set MySelection = DrwDocument.Selection
2777
2778 MySelection.Clear
2779 MySelection.Add Text
2780
2781 Dim MyVisProps As VisPropertySet
2782 Set MyVisProps = MySelection.VisProperties
2783
2784 'Set the text colour - blue
2785 MyVisProps.SetRealColor 0, 0, 255, 0
2786 'Set the line width type
2787 MyVisProps.SetRealWidth 3, 0
2788
2789 'Deselect everything
2790 MySelection.Clear
2791End Sub
2792Private Sub SetTextVisProp()
2793 'This Sets the properties of the line
2794 Dim MySelection As Selection
2795 Set MySelection = DrwDocument.Selection
2796
2797 MySelection.Clear
2798 MySelection.Add Text
2799
2800 Dim MyVisProps As VisPropertySet
2801 Set MyVisProps = MySelection.VisProperties
2802
2803 'Set the line colour
2804 MyVisProps.SetRealColor 118, 118, 118, 0
2805
2806 'Deselect everything
2807 MySelection.Clear
2808
2809End Sub
2810Private Sub CommandUpdateFields_Click()
2811 UpdateFields
2812End Sub
2813Private Sub CommandUpdateFields2_Click()
2814 UpdateFields
2815End Sub
2816Private Sub CheckBoxUpdateFirstView_Click()
2817 CheckBoxUpdateFirstView2.Value = CheckBoxUpdateFirstView.Value
2818End Sub
2819Private Sub CheckBoxUpdateFirstView2_Click()
2820 CheckBoxUpdateFirstView.Value = CheckBoxUpdateFirstView2.Value
2821End Sub
2822Private Sub CheckBoxUpdateMass_Click()
2823 CheckBoxUpdateMass2.Value = CheckBoxUpdateMass.Value
2824End Sub
2825Private Sub CheckBoxUpdateMass2_Click()
2826 CheckBoxUpdateMass.Value = CheckBoxUpdateMass2.Value
2827End Sub
2828Private Sub UpdateFields()
2829 DisableMainDrawingFormCommands
2830
2831 ResetInformationGeneral
2832 ResetInformationMass
2833
2834 InitBackgroundView
2835
2836 'need to make sure the macro runs for parts that don't have these variables in them
2837 On Error Resume Next
2838 'Description
2839 DrwTexts.GetItem("TitleBlock_Text_Description").Text = TextBoxProductDrawnDescription.Text
2840 'Update Part Number
2841 DrwTexts.GetItem("TitleBlock_Text_Part_Number_As_Drawn").Text = TextBoxProductDrawnPartNumber.Text
2842 'Op-Hand Part No
2843 DrwTexts.GetItem("TitleBlock_Text_Part_Number_Symmetrically_Opposite").Text = TextBoxProductDrawnSymOppPartNumber.Text
2844 'Lifed Part
2845 DrwTexts.GetItem("TitleBlock_Text_Classification").Text = ReformatClassification(TextBoxClassification.Text)
2846 'Serviceable Part
2847 DrwTexts.GetItem("TitleBlock_Text_Service").Text = TextBoxService.Text
2848
2849 '#### V5R24 #### ProgressBarDrawingBorder.Value = 60
2850
2851 ' Reformat titleblock attributes for comparison with titleblock
2852 Dim ProcessCheckRequired As Boolean
2853 ProcessCheckRequired = False
2854
2855 Dim TitleBlockMaterial As String
2856 TitleBlockMaterial = Replace(DrwTexts.GetItem("TitleBlock_Text_Material").Text, Chr(10), "|")
2857 Dim PartMaterial As String
2858 PartMaterial = Replace(TextBoxMaterial.Text, vbCrLf, "|")
2859
2860 Dim TitleBlockHeatTreatment As String
2861 TitleBlockHeatTreatment = Replace(DrwTexts.GetItem("TitleBlock_Text_Heat_Treatment").Text, Chr(10), "|")
2862 Dim PartHeatTreatment As String
2863 PartHeatTreatment = Replace(TextBoxHeatTreatment.Text, vbCrLf, "|")
2864
2865 Dim TitleBlockFinishProtection As String
2866 TitleBlockFinishProtection = Replace(DrwTexts.GetItem("TitleBlock_Text_Finish_Protection").Text, Chr(10), "|")
2867 Dim PartFinishProtection As String
2868 PartFinishProtection = Replace(TextBoxFinishProtection.Text, vbCrLf, "|")
2869
2870 If TitleBlockMaterial <> PartMaterial Or TitleBlockHeatTreatment <> PartHeatTreatment Or TitleBlockFinishProtection <> PartFinishProtection Then
2871 ' Need to check processes and notes are correct since material attributes are out of sync between part and drawing
2872 ProcessCheckRequired = True
2873 End If
2874
2875 On Error GoTo 0
2876 'Update Material, Spec, Heat Treatment and Finish/Protection (Replace delimiter with a carriage return)
2877 'Also need to check that the part has materials on it
2878 'Set the Check for material parameters to assume they exist
2879 Dim CheckMaterialParameter As Boolean
2880 CheckMaterialParameter = True
2881
2882 On Error Resume Next
2883 DrwTexts.GetItem("TitleBlock_Text_Material").Text = TextBoxMaterial.Text
2884 If Err.Number <> 0 Then
2885 CheckMaterialParameter = False
2886 End If
2887 DrwTexts.GetItem("TitleBlock_Text_Heat_Treatment").Text = TextBoxHeatTreatment.Text
2888 If Err.Number <> 0 Then
2889 CheckMaterialParameter = False
2890 End If
2891 DrwTexts.GetItem("TitleBlock_Text_Finish_Protection").Text = TextBoxFinishProtection.Text
2892 If Err.Number <> 0 Then
2893 CheckMaterialParameter = False
2894 End If
2895
2896 '#### V5R24 #### ProgressBarDrawingBorder.Value = 70
2897
2898 'Display Message dependent upon wheather Material has been applied
2899 If CheckMaterialParameter = False Then
2900 TextBoxInfoGeneral ("No Material Parameters found on the part or product (" & ProductDrawnMass.PartNumber & ") that are associated with generative drawing view." _
2901 & "You may want to consider updating these parameters and re-run the drawing border script." & vbCrLf & _
2902 "You can do this by updating the materials on your part/product. These will be automatically picked up by the drawing border - 'Border (Auto) > Update' script")
2903 End If
2904
2905' If CheckBoxUpdateMass.Value = True And TextBoxProductDrawnType.Text = "Product" Then
2906' ProductDrawnMass.ApplyWorkMode DESIGN_MODE
2907' ProductDrawnMassDoc
2908' End If
2909
2910 'Update the mass
2911 If CheckBoxUpdateMass.Value = True Then
2912
2913 'Update the mass
2914 DrwTexts.GetItem("TitleBlock_Text_Estimated_Mass").Text = TextBoxProductDrawnCalcMass
2915
2916 'Check if the Independent mass view checkbox is ticked and make sure the selection is different from the parameteres view
2917 If CheckBoxIndependentMassGenerativeView.Value = True And (ComboBoxProductDrawnViewMass.Text <> ComboBoxProductDrawnView.Text) Then
2918 'Add an invisible reference to the background, which will be read by the drawing border script
2919 DeleteIndependentMassViewReference
2920 AddIndependentMassViewReference
2921 Else
2922 DeleteIndependentMassViewReference
2923 End If
2924 End If
2925
2926 '#### V5R24 #### ProgressBarDrawingBorder.Value = 80
2927
2928 'Update the sheet # of #
2929 UpdateSheetInfo
2930 'Reorder the selected view to be the first
2931 ReOrder (ExtractViewID)
2932
2933 'Run the Bounding Box Updater Tool
2934 RunBBoxUpdater
2935 CommandsControlsEnabledState
2936
2937 'Run the Process Checker if required
2938 If ProcessCheckRequired Then
2939 RunProcessBoxAndNotesChecker
2940 End If
2941End Sub
2942
2943Private Function ReformatClassification(Classification As String)
2944 If InStr(1, Classification, "Class NC") = 1 Then
2945 ReformatClassification = "Class NC"
2946 Else
2947 ReformatClassification = Classification
2948 End If
2949End Function
2950
2951Private Sub RunBBoxUpdater()
2952
2953 'e.g. \\cad-server\data\Scripts\V5\R24\Environment\Production\Apps\BoundingBoxAndWetSurfaceAreaUpdater\BoundingBoxAndWetSurfaceAreaUpdater.exe
2954 'PLMScriptsDir=\\cad-server\data\Scripts\V5\R24
2955 'PLMEnvironment=Production
2956
2957 Dim PLMScriptsDir As String
2958 PLMScriptsDir = CATIA.SystemService.Environ("PLMScriptsDir")
2959 Dim PLMEnvironment As String
2960 PLMEnvironment = CATIA.SystemService.Environ("PLMEnvironment")
2961
2962 Dim BBoxAndWetSurfaceUpdateExe As String
2963 BBoxAndWetSurfaceUpdateExe = PLMScriptsDir & "\Environment\" & PLMEnvironment & "\Apps\BoundingBoxAndWetSurfaceAreaUpdater\BoundingBoxAndWetSurfaceAreaUpdater.exe"
2964
2965 Dim ReturnCode As Long
2966 ReturnCode = CATIA.SystemService.ExecuteBackgroundProcessus(BBoxAndWetSurfaceUpdateExe)
2967
2968 If ReturnCode <> 0 Then
2969 MsgBox "Please raise a helpdesk call to the PLM Team that there has been an issue with the bounding Box Updater script - Please indicate a part number", vbCritical, "Issue with Bounding Box Updater"
2970 End If
2971
2972End Sub
2973
2974Private Sub RunProcessBoxAndNotesChecker()
2975
2976 Dim PLMScriptsDir As String
2977 PLMScriptsDir = CATIA.SystemService.Environ("PLMScriptsDir")
2978 Dim PLMEnvironment As String
2979 PLMEnvironment = CATIA.SystemService.Environ("PLMEnvironment")
2980
2981 Dim ProcessBoxAndNotesCheckerExe As String
2982 ProcessBoxAndNotesCheckerExe = PLMScriptsDir & "\Environment\" & PLMEnvironment & "\Apps\ProcessBoxAndNotesChecker\ProcessBoxAndNotesChecker.exe"
2983
2984 Dim ReturnCode As Long
2985 ReturnCode = CATIA.SystemService.ExecuteBackgroundProcessus(ProcessBoxAndNotesCheckerExe)
2986
2987 If ReturnCode <> 0 Then
2988 MsgBox "Please raise a helpdesk call to the PLM Team that there has been an issue with the Process Box and Notes Checker script - Please indicate a part number", vbCritical, "Issue with Process Box and Notes Checker"
2989 End If
2990
2991End Sub
2992
2993Private Sub CommandBoundingBox_Click()
2994 CommandBoundingBox.Enabled = False
2995 RunAddDrawingBoundingBox
2996End Sub
2997Private Sub RunAddDrawingBoundingBox()
2998
2999 'e.g. \\cad-server\data\Scripts\V5\R24\Environment\Production\Apps\AddDrawingBoundingBox\AddDrawingBoundingBox.exe
3000 'PLMScriptsDir=\\cad-server\data\Scripts\V5\R24
3001 'PLMEnvironment=Production
3002
3003 Dim PLMScriptsDir As String
3004 PLMScriptsDir = CATIA.SystemService.Environ("PLMScriptsDir")
3005 Dim PLMEnvironment As String
3006 PLMEnvironment = CATIA.SystemService.Environ("PLMEnvironment")
3007
3008 Dim ProgramToExecute As String
3009 ProgramToExecute = PLMScriptsDir & "\Environment\" & PLMEnvironment & "\Apps\AddDrawingBoundingBox\AddDrawingBoundingBox.App.exe"
3010
3011 Dim ReturnCode As Long
3012 ReturnCode = CATIA.SystemService.ExecuteBackgroundProcessus(ProgramToExecute)
3013
3014 If ReturnCode <> 0 Then
3015 MsgBox "Please raise a helpdesk call to the PLM Team that there has been an issue with the AddDrawingBoundingBox script - Please include a part number", vbCritical, "Issue with AddDrawingBoundingBox"
3016 End If
3017
3018End Sub
3019Private Sub CommandWetSurfaceArea_Click()
3020 CommandWetSurfaceArea.Enabled = False
3021 RunAddDrawingWetSurfaceArea
3022End Sub
3023Private Sub RunAddDrawingWetSurfaceArea()
3024
3025 'e.g. \\cad-server\data\Scripts\V5\R24\Environment\Production\Apps\AddDrawingWetSurfaceArea\AddDrawingWetSurfaceArea.exe
3026 'PLMScriptsDir=\\cad-server\data\Scripts\V5\R24
3027 'PLMEnvironment=Production
3028
3029 Dim PLMScriptsDir As String
3030 PLMScriptsDir = CATIA.SystemService.Environ("PLMScriptsDir")
3031 Dim PLMEnvironment As String
3032 PLMEnvironment = CATIA.SystemService.Environ("PLMEnvironment")
3033
3034 Dim ProgramToExecute As String
3035 ProgramToExecute = PLMScriptsDir & "\Environment\" & PLMEnvironment & "\Apps\AddDrawingWetSurfaceArea\AddDrawingWetSurfaceArea.App.exe"
3036
3037 Dim ReturnCode As Long
3038 ReturnCode = CATIA.SystemService.ExecuteBackgroundProcessus(ProgramToExecute)
3039
3040 If ReturnCode <> 0 Then
3041 MsgBox "Please raise a helpdesk call to the PLM Team that there has been an issue with the AddDrawingWetSurfaceArea script - Please include a part number", vbCritical, "Issue with AddDrawingWetSurfaceArea"
3042 End If
3043
3044End Sub
3045Sub ReOrder(FirstDrawingViewIdentifier As Integer)
3046 If CheckBoxUpdateFirstView.Value = True Then
3047 Dim DrawingViewItdetifier As Integer
3048 Dim DrwViews As DrawingViews
3049 Dim ObjectViewArray() 'As Variant
3050
3051 Set DrwViews = DrwSheet.Views
3052
3053 Dim i As Integer
3054 Dim j As Integer
3055 ReDim Preserve ObjectViewArray(DrwViews.Count - 1)
3056
3057 'Main & Background View
3058 Set ObjectViewArray(0) = DrwViews.Item(1)
3059 Set ObjectViewArray(1) = DrwViews.Item(2)
3060 'First view
3061 Set ObjectViewArray(2) = DrwViews.Item(FirstDrawingViewIdentifier)
3062
3063
3064 DrawingViewItdetifier = 3
3065
3066 For i = 3 To DrwViews.Count - 1
3067
3068 If i = FirstDrawingViewIdentifier Then
3069 DrawingViewItdetifier = DrawingViewItdetifier + 1
3070 End If
3071
3072 Set ObjectViewArray(i) = DrwViews.Item(DrawingViewItdetifier)
3073 DrawingViewItdetifier = DrawingViewItdetifier + 1
3074 Next
3075
3076 DrwSheet.reorder_Views (ObjectViewArray)
3077 CATIA.RefreshDisplay = True
3078
3079 'Once the view has been re-ordered we need to rerun the active sheet to update the drop downs and menus
3080 ChangeActiveSheet
3081 End If
3082End Sub
3083Private Sub OptionButton_A3_Click()
3084 ResetInformationGeneral
3085 OptionButton_A2.Value = False
3086 OptionButton_A1.Value = False
3087 OptionButton_A0.Value = False
3088 'Only process the Mode Check once the form has been initialised otherwise this is processed twice.
3089 If FormInitialisation = False And SpinButtonChange = False Then
3090 CreateOrModifyModeCheck
3091 End If
3092 'Display information message asking user to change drafting standard dependent upon size selection
3093 If displayFormat = "A0" Or displayFormat = "A1" Then
3094 TextBoxInfoGeneral ("2,5mm text height may be used for A3 and A2 drawing sheets - Select draughting standard F1_2-5mm_v# (Where # is the latest drafting standard version)" & vbCrLf & vbCrLf & _
3095 "Instructions: File > page Set-up > Standard > F1_2-5mm_v# > Update")
3096 End If
3097End Sub
3098Private Sub OptionButton_A2_Click()
3099 ResetInformationGeneral
3100 OptionButton_A3.Value = False
3101 OptionButton_A1.Value = False
3102 OptionButton_A0.Value = False
3103 'Only process the Mode Check once the form has been initialised otherwise this is processed twice.
3104 If FormInitialisation = False And SpinButtonChange = False Then
3105 CreateOrModifyModeCheck
3106 End If
3107 'Display information message asking user to change drafting standard dependent upon size selection
3108 If displayFormat = "A0" Or displayFormat = "A1" Then
3109 TextBoxInfoGeneral ("2,5mm text height may be used for A3 and A2 drawing sheets - Select draughting standard F1_2-5mm_v# (Where # is the latest drafting standard version)" & vbCrLf & vbCrLf & _
3110 "Instructions: File > page Set-up > Standard > F1_2-5mm_v# > Update")
3111 End If
3112End Sub
3113Private Sub OptionButton_A1_Click()
3114 ResetInformationGeneral
3115 OptionButton_A3.Value = False
3116 OptionButton_A2.Value = False
3117 OptionButton_A0.Value = False
3118 'Only process the Mode Check once the form has been initialised otherwise this is processed twice.
3119 If FormInitialisation = False And SpinButtonChange = False Then
3120 CreateOrModifyModeCheck
3121 End If
3122 'Display information message asking user to change drafting standard dependent upon size selection
3123 If displayFormat = "A3" Or displayFormat = "A2" Then
3124 TextBoxInfoGeneral ("3,5mm text height should be used for A1 and A0 drawing sheets - Select draughting standard F1_3-5mm_v# (Where # is the latest drafting standard version)" & vbCrLf & vbCrLf & _
3125 "Instructions: File > page Set-up > Standard > F1_3-5mm_v# > Update")
3126 End If
3127End Sub
3128Private Sub OptionButton_A0_Click()
3129 ResetInformationGeneral
3130 OptionButton_A3.Value = False
3131 OptionButton_A2.Value = False
3132 OptionButton_A1.Value = False
3133 'Only process the Mode Check once the form has been initialised otherwise this is processed twice.
3134 If FormInitialisation = False And SpinButtonChange = False Then
3135 CreateOrModifyModeCheck
3136 End If
3137 'Display information message asking user to change drafting standard dependent upon size selection
3138 If displayFormat = "A3" Or displayFormat = "A2" Then
3139 TextBoxInfoGeneral ("3,5mm text height should be used for A1 and A0 drawing sheets - Select draughting standard F1_3-5mm_v# (Where # is the latest drafting standard version)" & vbCrLf & vbCrLf & _
3140 "Instructions: File > page Set-up > Standard > F1_3-5mm_v# > Update")
3141 End If
3142End Sub
3143Private Sub OptionButtonTolStandard_Click()
3144 ResetInformationGeneral
3145 OptionButtonTolComposite.Value = False
3146 OptionButtonTolFabrications.Value = False
3147 OptionButtonTolCastings.Value = False
3148 OptionButtonTolWiring.Value = False
3149 OptionButtonTolPattern.Value = False
3150 OptionButtonTolAdditiveLayerManufacture.Value = False
3151 OptionButtonTolNone.Value = False
3152 SelectedToleranceSetting = "Standard"
3153 'Only process the Mode Check once the form has been initialised otherwise this is processed twice.
3154 If FormInitialisation = False And SpinButtonChange = False Then
3155 CreateOrModifyModeCheck
3156 End If
3157End Sub
3158Private Sub OptionButtonTolComposite_Click()
3159 ResetInformationGeneral
3160 OptionButtonTolStandard.Value = False
3161 OptionButtonTolFabrications.Value = False
3162 OptionButtonTolCastings.Value = False
3163 OptionButtonTolWiring.Value = False
3164 OptionButtonTolPattern.Value = False
3165 OptionButtonTolAdditiveLayerManufacture.Value = False
3166 OptionButtonTolNone.Value = False
3167 SelectedToleranceSetting = "Composite"
3168 'Only process the Mode Check once the form has been initialised otherwise this is processed twice.
3169 If FormInitialisation = False And SpinButtonChange = False Then
3170 CreateOrModifyModeCheck
3171 End If
3172End Sub
3173Private Sub OptionButtonTolFabrications_Click()
3174 ResetInformationGeneral
3175 OptionButtonTolStandard.Value = False
3176 OptionButtonTolComposite.Value = False
3177 OptionButtonTolCastings.Value = False
3178 OptionButtonTolWiring.Value = False
3179 OptionButtonTolPattern.Value = False
3180 OptionButtonTolAdditiveLayerManufacture.Value = False
3181 OptionButtonTolNone.Value = False
3182 SelectedToleranceSetting = "Fabrications"
3183 'Only process the Mode Check once the form has been initialised otherwise this is processed twice.
3184 If FormInitialisation = False And SpinButtonChange = False Then
3185 CreateOrModifyModeCheck
3186 End If
3187End Sub
3188Private Sub OptionButtonTolCastings_Click()
3189 ResetInformationGeneral
3190 OptionButtonTolStandard.Value = False
3191 OptionButtonTolComposite.Value = False
3192 OptionButtonTolFabrications.Value = False
3193 OptionButtonTolWiring.Value = False
3194 OptionButtonTolPattern.Value = False
3195 OptionButtonTolAdditiveLayerManufacture.Value = False
3196 OptionButtonTolNone.Value = False
3197 SelectedToleranceSetting = "Castings"
3198 'Only process the Mode Check once the form has been initialised otherwise this is processed twice.
3199 If FormInitialisation = False And SpinButtonChange = False Then
3200 CreateOrModifyModeCheck
3201 End If
3202End Sub
3203Private Sub OptionButtonTolWiring_Click()
3204 ResetInformationGeneral
3205 OptionButtonTolStandard.Value = False
3206 OptionButtonTolComposite.Value = False
3207 OptionButtonTolFabrications.Value = False
3208 OptionButtonTolCastings.Value = False
3209 OptionButtonTolPattern.Value = False
3210 OptionButtonTolAdditiveLayerManufacture.Value = False
3211 OptionButtonTolNone.Value = False
3212 SelectedToleranceSetting = "Wiring"
3213 'Only process the Mode Check once the form has been initialised otherwise this is processed twice.
3214 If FormInitialisation = False And SpinButtonChange = False Then
3215 CreateOrModifyModeCheck
3216 End If
3217End Sub
3218Private Sub OptionButtonTolPattern_Click()
3219 ResetInformationGeneral
3220 OptionButtonTolStandard.Value = False
3221 OptionButtonTolComposite.Value = False
3222 OptionButtonTolFabrications.Value = False
3223 OptionButtonTolCastings.Value = False
3224 OptionButtonTolWiring.Value = False
3225 OptionButtonTolAdditiveLayerManufacture.Value = False
3226 OptionButtonTolNone.Value = False
3227 SelectedToleranceSetting = "Pattern"
3228 'Only process the Mode Check once the form has been initialised otherwise this is processed twice.
3229 If FormInitialisation = False And SpinButtonChange = False Then
3230 CreateOrModifyModeCheck
3231 End If
3232End Sub
3233Private Sub OptionButtonTolAdditiveLayerManufacture_Click()
3234 ResetInformationGeneral
3235 OptionButtonTolStandard.Value = False
3236 OptionButtonTolComposite.Value = False
3237 OptionButtonTolFabrications.Value = False
3238 OptionButtonTolCastings.Value = False
3239 OptionButtonTolWiring.Value = False
3240 OptionButtonTolPattern.Value = False
3241 OptionButtonTolNone.Value = False
3242 SelectedToleranceSetting = "AdditiveLayerManufacture"
3243 'Only process the Mode Check once the form has been initialised otherwise this is processed twice.
3244 If FormInitialisation = False And SpinButtonChange = False Then
3245 CreateOrModifyModeCheck
3246 End If
3247End Sub
3248Private Sub OptionButtonTolNone_Click()
3249 ResetInformationGeneral
3250 OptionButtonTolStandard.Value = False
3251 OptionButtonTolComposite.Value = False
3252 OptionButtonTolFabrications.Value = False
3253 OptionButtonTolCastings.Value = False
3254 OptionButtonTolWiring.Value = False
3255 OptionButtonTolPattern.Value = False
3256 OptionButtonTolAdditiveLayerManufacture.Value = False
3257 SelectedToleranceSetting = "None"
3258 'Only process the Mode Check once the form has been initialised otherwise this is processed twice.
3259 If FormInitialisation = False And SpinButtonChange = False Then
3260 CreateOrModifyModeCheck
3261 End If
3262End Sub
3263Private Sub SetTolTableAndPageSize()
3264 'If The Drawing Border exists
3265 If CheckBoxDrawingBorderExists.Value = True Then
3266 Dim DrwTables As DrawingTables
3267 Dim DrwTable As DrawingTable
3268 Dim CheckToleranceTable As Boolean
3269 Dim i As Integer
3270
3271 InitBackgroundView
3272
3273 Set DrwTables = DrwView.Tables
3274 i = 0
3275 CheckToleranceTable = False
3276 While (i < DrwTables.Count And CheckToleranceTable = False)
3277 i = i + 1
3278 Set DrwTable = DrwTables.Item(i)
3279 If (Left(DrwTable.Name, 14) = "ToleranceTable") Then
3280 CheckToleranceTable = True
3281 End If
3282 Wend
3283
3284 'Check if the drawing has been created properly
3285 'If it has a tolerance table will exist
3286 If DrwTable Is Nothing Then
3287 'Disable all the commands
3288 DisableMainDrawingFormCommands
3289 'Enable the delete drawing border command so the user can delete the existing data
3290 'Enable the Cancel command so the user can cancel the script
3291 CommandDeleteDrawingBorder.Enabled = True
3292 CommandCancel.Enabled = True
3293 TextBoxInfoGeneral ("There has been an issue creating the drawing border and not all the drawing border objects are present" & vbCrLf & _
3294 "Please select the 'Delete All' icon, this will delete the existing drawing border including any hidden text that is used in the drawing border creation - then attempt to re-create the drawing border using the drawing border script" & vbCrLf & _
3295 "If the problem persists, please raise a support call")
3296 Exit Sub
3297 End If
3298
3299 If DrwTable.Name = "ToleranceTableStandard" Then
3300 OptionButtonTolStandard.Value = True
3301 CurrentTolSetting = "Standard"
3302 ElseIf DrwTable.Name = "ToleranceTableComposites" Then
3303 OptionButtonTolComposite.Value = True
3304 CurrentTolSetting = "Composite"
3305 ElseIf DrwTable.Name = "ToleranceTableFabrications" Then
3306 OptionButtonTolFabrications.Value = True
3307 CurrentTolSetting = "Fabrications"
3308 ElseIf DrwTable.Name = "ToleranceTableCastings" Then
3309 OptionButtonTolCastings.Value = True
3310 CurrentTolSetting = "Castings"
3311 ElseIf DrwTable.Name = "ToleranceTableWiring" Then
3312 OptionButtonTolWiring.Value = True
3313 CurrentTolSetting = "Wiring"
3314 ElseIf DrwTable.Name = "ToleranceTablePattern" Then
3315 OptionButtonTolPattern.Value = True
3316 CurrentTolSetting = "Pattern"
3317 ElseIf DrwTable.Name = "ToleranceTableAdditiveLayerManufacture" Then
3318 OptionButtonTolAdditiveLayerManufacture.Value = True
3319 CurrentTolSetting = "AdditiveLayerManufacture"
3320 Else
3321 OptionButtonTolNone.Value = True
3322 CurrentTolSetting = "None"
3323 End If
3324 End If
3325
3326 'Make the Page size selected the same as the currently Active View
3327 OptionButton_A3.Value = 1
3328 If displayFormat = "A3" Then
3329 OptionButton_A3.Value = 1
3330 ElseIf displayFormat = "A2" Then
3331 OptionButton_A2.Value = 1
3332 ElseIf displayFormat = "A1" Then
3333 OptionButton_A1.Value = 1
3334 ElseIf displayFormat = "A0" Then
3335 OptionButton_A0.Value = 1
3336 End If
3337
3338 If FormInitialisation = False Then
3339 CheckInformationTabs
3340 End If
3341End Sub
3342Private Sub CommandCreateDrawingBorder_Click()
3343 DisableMainDrawingFormCommands
3344 ResetInformationGeneral
3345 DrawingBorderCreateOrModify
3346 CommandsControlsEnabledState
3347End Sub
3348Private Sub DrawingBorderCreateOrModify()
3349
3350 'To check the Mode and create or modify a drawing border
3351 If CheckBoxDrawingBorderExists.Value = True Then
3352 '###################################
3353 '####### resize the drawing #######
3354 '###################################
3355 ResetInformationGeneral
3356 'Obtain Chosen Page Size and resize page
3357 CheckChangeSizeOption
3358 '#### V5R24 #### ProgressBarDrawingBorder.Value = 40
3359 DrawingBorderResize
3360 '#### V5R24 #### ProgressBarDrawingBorder.Value = 70
3361 ResetInformationGeneral
3362 Else
3363 '###################################
3364 '#### create the drawing border ####
3365 '###################################
3366 ResetInformationGeneral
3367 'Obtain Chosen Page Size and resize page
3368 CheckChangeSizeOption
3369 '#### V5R24 #### ProgressBarDrawingBorder.Value = 20
3370 DrawingBorderCreate
3371 '#### V5R24 #### ProgressBarDrawingBorder.Value = 40
3372 ModifyInitialText
3373 ResetInformationGeneral
3374 '#### V5R24 #### ProgressBarDrawingBorder.Value = 50
3375 RevisionsValuesProvisionalRevision
3376 If NumberOfGenerativeViews > 0 Then
3377 UpdateFields
3378 End If
3379 End If
3380End Sub
3381Private Sub CheckSizeOption()
3382 If OptionButton_A3.Value = True Then
3383 ChosenSize = "A3"
3384 ElseIf OptionButton_A2.Value = True Then
3385 ChosenSize = "A2"
3386 ElseIf OptionButton_A1.Value = True Then
3387 ChosenSize = "A1"
3388 ElseIf OptionButton_A0.Value = True Then
3389 ChosenSize = "A0"
3390 End If
3391End Sub
3392Private Sub CheckChangeSizeOption()
3393 If OptionButton_A3.Value = True Then
3394 ChosenSize = "A3"
3395 DrwSheet.PaperSize = catPaperA3
3396 ElseIf OptionButton_A2.Value = True Then
3397 ChosenSize = "A2"
3398 DrwSheet.PaperSize = catPaperA2
3399 ElseIf OptionButton_A1.Value = True Then
3400 ChosenSize = "A1"
3401 DrwSheet.PaperSize = catPaperA1
3402 ElseIf OptionButton_A0.Value = True Then
3403 ChosenSize = "A0"
3404 DrwSheet.PaperSize = catPaperA0
3405 End If
3406End Sub
3407Private Sub DrawingBorderCreate()
3408 'To place on the drawing a reference piece of text that contains no text
3409 DrawingBorderReference
3410
3411 If OptionButtonTolStandard.Value = True Then
3412 ChosenTol = "ToleranceTableStandard"
3413 CurrentTolSetting = "Standard"
3414 ElseIf OptionButtonTolComposite.Value = True Then
3415 ChosenTol = "ToleranceTableComposites"
3416 CurrentTolSetting = "Composite"
3417 ElseIf OptionButtonTolFabrications.Value = True Then
3418 ChosenTol = "ToleranceTableFabrications"
3419 CurrentTolSetting = "Fabrications"
3420 ElseIf OptionButtonTolCastings.Value = True Then
3421 ChosenTol = "ToleranceTableCastings"
3422 CurrentTolSetting = "Castings"
3423 ElseIf OptionButtonTolWiring.Value = True Then
3424 ChosenTol = "ToleranceTableWiring"
3425 CurrentTolSetting = "Wiring"
3426 ElseIf OptionButtonTolPattern.Value = True Then
3427 ChosenTol = "ToleranceTablePattern"
3428 CurrentTolSetting = "Pattern"
3429 ElseIf OptionButtonTolAdditiveLayerManufacture.Value = True Then
3430 ChosenTol = "ToleranceTableAdditiveLayerManufacture"
3431 CurrentTolSetting = "AdditiveLayerManufacture"
3432 ElseIf OptionButtonTolNone.Value = True Then
3433 ChosenTol = "ToleranceTableNone"
3434 CurrentTolSetting = "None"
3435 End If
3436
3437 'To compute standard sizes
3438 CurrentSheetProperties
3439 Dim rqdFileName As String
3440 rqdFileName = TitleDrwName & ChosenSize & ".CATDrawing"
3441 '#### V5R24 #### ProgressBarDrawingBorder.Value = 50
3442 ImportDrawingBorder (rqdFileName) 'To import the standard frame and titleblock
3443
3444 InitBackgroundView
3445 If ChosenTol <> "ToleranceTableStandard" And ChosenTol <> "ToleranceTablePattern" And ChosenTol <> "ToleranceTableNone" Then
3446 DrwTexts.GetItem("Frame_Text_General_Tolerances").Text = "See Table"
3447 Else
3448 DrwTexts.GetItem("Frame_Text_General_Tolerances").Text = "ISO 2768 -fH"
3449 End If
3450
3451
3452End Sub
3453Private Sub DrawingBorderResize()
3454 'Init
3455
3456 DrawingBorderDelete
3457 DrawingToleranceTablesDelete
3458 DrawingBorderMoveExisting
3459 DrawingBorderCreate
3460
3461 'Obtain the current sheet properties
3462 CurrentSheetProperties
3463End Sub
3464Private Sub DrawingBorderReference()
3465 '-------------------------------------------------------------------------------
3466 'How to create a reference text
3467 '-------------------------------------------------------------------------------
3468 'Place it on the background view - less chance of someone accidently deleting it from the front view
3469 InitBackgroundView
3470 Set Text = DrwTexts.Add("", 0, 0)
3471 Text.Name = "Reference_" + DrawingBorderNewVersion
3472
3473 'Update the Drawing Border Form to display the drawing border version
3474 UpdateDrawingBorderExistVersion (DrawingBorderNewVersion)
3475
3476 InitMainView
3477End Sub
3478Private Sub AddIndependentMassViewReference()
3479 '-------------------------------------------------------------------------------
3480 'How to create a reference text
3481 '-------------------------------------------------------------------------------
3482 'Place it on the background view - less chance of someone accidently deleting it from the front view
3483 InitBackgroundView
3484
3485 Set Text = DrwTexts.Add("", 0, 5)
3486 Text.Name = "Independent_Mass_View_" + ExtractIndependentMassViewID
3487End Sub
3488Private Sub ModifyInitialText()
3489 TextBoxInformationGeneral.Text = ""
3490 InitBackgroundView
3491
3492 'This will update the Drawn by, e-mail, phone number rev initial Date
3493 UpdateDrawingBorderFields
3494 UpdateSheetInfo
3495
3496End Sub
3497Private Sub UpdateSheetInfo()
3498 Dim i As Integer
3499
3500 InitBackgroundView
3501
3502 Dim nbSheet As Integer
3503 Dim curSheet As Integer
3504 nbSheet = 0
3505 curSheet = 0
3506
3507 Select Case TypeName(DrwDocument)
3508 Case "DrawingDocument"
3509 If (Not DrwSheet.IsDetail) Then
3510 For i = 1 To DrwSheets.Count
3511 If (Not DrwSheets.Item(i).IsDetail) Then
3512 nbSheet = nbSheet + 1
3513 End If
3514 Next
3515 For i = 1 To DrwSheets.Count
3516 'MsgBox DrwSheets.Item(i).IsDetail
3517 If (DrwSheets.Item(i).IsDetail) = False Then
3518 curSheet = curSheet + 1
3519 'Need to allow for when sheets may not include a drawing border
3520 On Error Resume Next
3521 DrwSheets.Item(i).Views.Item(2).Texts.GetItem("TitleBlock_Text_Sheet_A").Text = CStr(curSheet)
3522 DrwSheets.Item(i).Views.Item(2).Texts.GetItem("TitleBlock_Text_Sheet_B").Text = CStr(nbSheet)
3523 On Error GoTo 0
3524 End If
3525 Next
3526 End If
3527
3528 Case "PartDocument"
3529 'If (Not LaySheet.IsDetail) Then
3530 'For i = 1 To LaySheets.Count
3531 'If (Not LaySheets.Item(i).IsDetail) Then
3532 'nbSheet = nbSheet + 1
3533 'End If
3534 'Next
3535 'For i = 1 To LaySheets.Count
3536 'If (Not LaySheets.Item(i).IsDetail) Then
3537 'On Error Resume Next
3538 'curSheet = curSheet + 1
3539 'LaySheets.Item(i).Views.Item(2).Texts.GetItem("TitleBlock_Text_Sheet_1").text = CStr(curSheet) & "/" & CStr(nbSheet)
3540 'End If
3541 'Next
3542 'End If
3543 MsgBox "This is a partDocument"
3544 End Select
3545
3546 On Error GoTo 0
3547End Sub
3548Private Sub DrawingBorderMoveExisting()
3549 ' select every entity that starts with "titleblock" or "frame" - in any upper/lower case
3550 ' also select the reference text that says this drawing has a titleblock
3551
3552
3553 Dim i As Integer
3554 Dim ItemToMove As SelectedElement
3555 Dim Origin(2)
3556 Dim Direction(2)
3557 Dim TranslationX As Double
3558 Dim TranslationY As Double
3559
3560 FilterSelection ("Name=TitleBlock_Text* + Name=TitleBlock_Rev_* + Name=DrawingBorderNotes,sel")
3561
3562 ' Move all that was selected
3563
3564 TranslationY = 0
3565 TranslationX = DrwSheet.GetPaperWidth - Width
3566 'MsgBox TranslationX & vbCrLf & DrwSheet.GetPaperWidth & vbCrLf & Width
3567 Dim MyLine2D As Line2D
3568
3569 For i = 1 To Selection.Count
3570 Set ItemToMove = Selection.Item(i)
3571 If ItemToMove.Type = "Line2D" Then
3572 ItemToMove.Value.GetOrigin Origin
3573 ItemToMove.Value.GetDirection Direction
3574 Set MyLine2D = ItemToMove.Value
3575 MyLine2D.SetData Origin(0) + TranslationX, Origin(1) + TranslationY, Direction(0), Direction(1)
3576 ElseIf ItemToMove.Type = "DrawingText" Then
3577 ItemToMove.Value.X = ItemToMove.Value.X + TranslationX
3578 ItemToMove.Value.Y = ItemToMove.Value.Y + TranslationY
3579 Else
3580 TextBoxInfoGeneral ("Selection Contains Type: " & ItemToMove.Type & vbCrLf & _
3581 "Please report this condition to the CAD Administrator")
3582 End If
3583 Next
3584
3585 '-----------------------------------------------------------
3586 'Now Move the process box information
3587 '-----------------------------------------------------------
3588
3589 FilterSelection ("Name=Process_Box*,sel")
3590
3591 ' Move all that was selected
3592
3593 TranslationY = DrwSheet.GetPaperHeight - Height
3594 TranslationX = DrwSheet.GetPaperWidth - Width
3595
3596 For i = 1 To Selection.Count
3597 Set ItemToMove = Selection.Item(i)
3598 If ItemToMove.Type = "Line2D" Then
3599 ItemToMove.Value.GetOrigin Origin
3600 ItemToMove.Value.GetDirection Direction
3601 Set MyLine2D = ItemToMove.Value
3602 MyLine2D.SetData Origin(0) + TranslationX, Origin(1) + TranslationY, Direction(0), Direction(1)
3603 ElseIf ItemToMove.Type = "DrawingText" Then
3604 ItemToMove.Value.X = ItemToMove.Value.X + TranslationX
3605 ItemToMove.Value.Y = ItemToMove.Value.Y + TranslationY
3606 Else
3607 TextBoxInfoGeneral ("Selection Contains Type: " & ItemToMove.Type & vbCrLf & _
3608 "Please report this condition to the CAD Administrator")
3609 End If
3610 Next
3611
3612 Selection.Clear
3613End Sub
3614Private Sub CommandDeleteDrawingBorder_Click()
3615 DisableMainDrawingFormCommands
3616 ResetInformationGeneral
3617 TextBoxInfoGeneral ("Please wait while your drawing border & process box are deleted ....")
3618 FormDraftDrawingBorder.Repaint
3619
3620 'You don't perform a check to see if there is a drawing border
3621 'as some of the entities may have already been removed includeing the ref text
3622
3623 DrawingBorderDelete
3624 '#### V5R24 #### ProgressBarDrawingBorder.Value = 20
3625 DrawingBorderTextDelete
3626 '#### V5R24 #### ProgressBarDrawingBorder.Value = 30
3627 DrawingBorderMainViewTextDelete
3628 '#### V5R24 #### ProgressBarDrawingBorder.Value = 40
3629 'DrawingProcessBoxDelete
3630 DrawingToleranceTablesDelete
3631 '#### V5R24 #### ProgressBarDrawingBorder.Value = 50
3632 DrawingRevisionsDelete
3633 '#### V5R24 #### ProgressBarDrawingBorder.Value = 60
3634 DrawingTrianglesDelete
3635 '#### V5R24 #### ProgressBarDrawingBorder.Value = 70
3636 DeleteIndependentMassViewReference
3637 '#### V5R24 #### ProgressBarDrawingBorder.Value = 75
3638 RevisionsValuesNoDrawing
3639 '#### V5R24 #### ProgressBarDrawingBorder.Value = 80
3640
3641 DrawingProcessBoxAndNotesTagDelete
3642
3643
3644 ResetInformationGeneral
3645 CommandsControlsEnabledState
3646 SetTolTableAndPageSize
3647End Sub
3648Private Sub DrawingBorderDelete()
3649
3650 ' select every entity that starts with "titleblock" or "frame" - in any upper/lower case
3651 ' also select the reference text that says this drawing has a titleblock
3652
3653 FilterSelection ("Name=TitleBlock_Line* + Name=frame* + Name=TitleBlock_Table* + Name=Reference_*" & ",sel")
3654
3655 ' delete all that was selected
3656 If Selection.Count > 0 Then
3657 Selection.Delete
3658 End If
3659
3660 Selection.Clear
3661End Sub
3662Private Sub DrawingBorderTextDelete()
3663
3664 ' select every entity that starts with "titleblock" or "frame" - in any upper/lower case
3665 ' also select the reference text that says this drawing has a titleblock
3666
3667 FilterSelection ("Name=TitleBlock_Text*,sel")
3668
3669 ' delete all that was selected
3670 If Selection.Count > 0 Then
3671 Selection.Delete
3672 End If
3673
3674 Selection.Clear
3675End Sub
3676Private Sub DrawingBorderMainViewTextDelete()
3677
3678 ' select every entity that starts with "titleblock" or "frame" - in any upper/lower case
3679 ' also select the reference text that says this drawing has a titleblock
3680
3681 FilterSelection ("Name=MainView_Frame_Text*,sel")
3682
3683 ' delete all that was selected
3684 If Selection.Count > 0 Then
3685 Selection.Delete
3686 End If
3687
3688 Selection.Clear
3689End Sub
3690Private Sub DrawingProcessBoxDelete()
3691
3692 ' select every entity that starts with "titleblock" or "frame" - in any upper/lower case
3693 ' also select the reference text that says this drawing has a titleblock
3694
3695 FilterSelection ("Name=Process_Box*,sel")
3696
3697 ' delete all that was selected
3698 If Selection.Count > 0 Then
3699 Selection.Delete
3700 End If
3701
3702 Selection.Clear
3703End Sub
3704Private Sub DrawingNotesDelete()
3705
3706 FilterSelection ("Name=DrawingBorderNotes*,sel")
3707 ' delete all that was selected
3708 If Selection.Count > 0 Then
3709 Selection.Delete
3710 End If
3711
3712 Selection.Clear
3713End Sub
3714Private Sub DrawingNotesViewDelete()
3715
3716 FilterSelection ("Name=NOTES VIEW,sel")
3717 ' delete all that was selected
3718 If Selection.Count > 0 Then
3719 Selection.Delete
3720 End If
3721
3722 Selection.Clear
3723End Sub
3724Private Sub DrawingProcessBoxAndNotesTagDelete()
3725
3726 FilterSelection ("Name=DrawingAutoGeneratedText_v*,sel")
3727 ' delete all that was selected
3728 If Selection.Count > 0 Then
3729 Selection.Delete
3730 End If
3731
3732 Selection.Clear
3733End Sub
3734Private Sub DrawingLayupDelete()
3735
3736 FilterSelection ("Name=Layup*,sel")
3737 ' delete all that was selected
3738 If Selection.Count > 0 Then
3739 Selection.Delete
3740 End If
3741
3742 Selection.Clear
3743End Sub
3744Private Sub DrawingRevisionsDelete()
3745
3746 ' select every entity that starts with "TitleBlock_Rev" - in any upper/lower case
3747 FilterSelection ("Name=TitleBlock_Rev_*,sel")
3748
3749 ' delete all that was selected
3750 If Selection.Count > 0 Then
3751 Selection.Delete
3752 End If
3753
3754 Selection.Clear
3755End Sub
3756Private Sub DrawingTrianglesDelete()
3757
3758 ' select every entity that starts with "TitleBlock_Rev" - in any upper/lower case
3759 FilterSelection ("Name=TitleBlock_Triangle*,sel")
3760
3761 ' delete all that was selected
3762 If Selection.Count > 0 Then
3763 Selection.Delete
3764 End If
3765
3766 Selection.Clear
3767End Sub
3768Private Sub DrawingToleranceTablesDelete()
3769 ' IN ALL VIEWS (foreground and background) !!
3770 ' select every entity that starts with "titleblock" or "frame" - in any upper/lower case
3771 ' also select the reference text that says this drawing has a titleblock
3772 FilterSelection ("Name=ToleranceTable*,sel")
3773
3774 ' delete all that was selected
3775 If Selection.Count > 0 Then
3776 Selection.Delete
3777 End If
3778
3779 Selection.Clear
3780End Sub
3781Private Sub DrawingRevisionsLastDelete()
3782
3783 'Do not Delete the triangle if you are making a modification
3784 If RevisionModification = True Then
3785 FilterSelection ("Name=TitleBlock_Rev_*_" & TextBoxCurrentRevisionIdentifier.Text & " + Name=TitleBlock_Rev_*_" & TextBoxCurrentRevisionIdentifier.Text & ".*,sel")
3786 Else
3787 FilterSelection ("Name=TitleBlock_Rev_*_" & TextBoxCurrentRevisionIdentifier.Text & " + Name=TitleBlock_Rev_*_" & TextBoxCurrentRevisionIdentifier.Text & ".* + Name=TitleBlock_Triangle_*_" & TextBoxCurrentRevisionIdentifier.Text & ",sel")
3788 End If
3789
3790 ' delete all that was selected
3791 If Selection.Count > 0 Then
3792 Selection.Delete
3793 End If
3794
3795 If TextBoxCurrentRevisionIdentifier.Text = 1 Then
3796 ResetProvisionalAndDrawnAndCheck
3797 End If
3798
3799 FindCurrentRevision
3800
3801 Selection.Clear
3802End Sub
3803Private Sub DeleteIndependentMassViewReference()
3804
3805 ' select every entity that starts with "TitleBlock_Rev" - in any upper/lower case
3806 FilterSelection ("Name=Independent_Mass_View_*,sel")
3807
3808 ' delete all that was selected
3809 If Selection.Count > 0 Then
3810 Selection.Delete
3811 End If
3812
3813 Selection.Clear
3814End Sub
3815Private Sub FilterSelection(SearchText As String)
3816
3817 'We use the filter method as it is the only way we know how to search for objects within a single sheet
3818
3819 'e.g. ("Name=Reference_" & DrawingBorderNewVersion & ",sel")
3820
3821 Selection.Clear
3822
3823 'Necessary for the selection in R19 - removed in R22
3824 'CATIA.HSOSynchronized = False
3825
3826 'Select all entities within the current sheet
3827 Selection.Search ("Name in Graph = '" & DrwSheet.Name & "*',all")
3828
3829 'Now filter the existing search for specific named entities
3830 Selection.Search (SearchText)
3831
3832 'Necessary for the selection in R19 - removed in R22
3833 'CATIA.HSOSynchronized = True
3834
3835End Sub
3836'Private Sub CommandProcessBox_Click()
3837' ResetInformationGeneral
3838' FormDraftDrawingBorder.Hide
3839' FormDraftProcessBox.Show
3840'End Sub
3841Private Sub InitialiseObjects()
3842 Set DrwDocument = CATIA.ActiveDocument
3843 Set DrwSheets = DrwDocument.Sheets
3844 Set Selection = DrwDocument.Selection
3845End Sub
3846Private Sub InitMainView()
3847 Set DrwSheet = DrwSheets.ActiveSheet
3848 Set DrwView = DrwSheet.Views.Item(1)
3849 Set DrwTexts = DrwView.Texts
3850 Set Fact = DrwView.Factory2D
3851End Sub
3852Private Sub InitBackgroundView()
3853 Set DrwSheet = DrwSheets.ActiveSheet
3854 Set DrwView = DrwSheet.Views.Item(2)
3855 Set DrwTexts = DrwView.Texts
3856 Set Fact = DrwView.Factory2D
3857End Sub
3858Sub FindCurrentRevision()
3859
3860 If CheckBoxDrawingBorderExists.Value = True Then
3861 '-------------------------------------------------------------------------------
3862 'How to check that a revision block already exists and the number of
3863 'revision blocks there are
3864 '-------------------------------------------------------------------------------
3865 Dim i As Integer
3866 Dim CurrentRevisionIdentifier As Integer
3867
3868 InitBackgroundView
3869
3870 'Need to make the check against a capitalised INITIAL RELEASE as older drawings were INITIAL RELEASE and newer drawings are Initial Release
3871 If UCase(DrwTexts.GetItem("TitleBlock_Text_Revision_Modification_Description").Text) <> "INITIAL RELEASE" Then
3872 'PROVISIONAL REVISION
3873 RevisionsValuesProvisionalRevision
3874 Else
3875
3876 'Check the number of revision block on the drawing
3877 'There is already one on the drawing border so the first number returned should be 2 for a new drawing
3878 CurrentRevisionIdentifier = 1
3879 'Count how many texts are in the drawing
3880 i = 0
3881 While (i < DrwTexts.Count)
3882 i = i + 1
3883 Set Text = DrwTexts.Item(i)
3884 'DrwTexts.Item(1).text
3885 If (Left(Text.Name, 25) = "TitleBlock_Rev_Numb_Text_") Then
3886 TextBoxCurrentRevisionText.Text = Text.Text
3887 CurrentRevisionIdentifier = CurrentRevisionIdentifier + 1
3888 End If
3889 Wend
3890
3891 'If this is not = 1 then we have additional revisions
3892 TextBoxCurrentRevisionIdentifier.Text = CurrentRevisionIdentifier
3893
3894 'Check if no extra revisions are found - if not, then it's an initial revision
3895 If TextBoxCurrentRevisionIdentifier.Text = 1 Then
3896 'INITIAL REVISION
3897 RevisionsValuesInitialRevision
3898 Else
3899 'Find out current major revision number
3900 TextBoxCurrentMajorRevision.Text = Left(TextBoxCurrentRevisionText.Text, 2)
3901 'Find out current dot revision
3902 TextBoxCurrentDotRevision.Text = Split(TextBoxCurrentRevisionText.Text, ".")(1)
3903 'Find the next major Revision
3904 TextBoxNextRevisionTextMajor.Text = Format(TextBoxCurrentMajorRevision + 1 & ".0", "00.0")
3905 'Find the next dot revision
3906
3907 Dim NewDotRevision As Integer
3908 NewDotRevision = TextBoxCurrentDotRevision + 1
3909
3910 If Len(Trim(Str(NewDotRevision))) = 1 Then
3911 TextBoxNextRevisionTextDot.Text = Format(TextBoxCurrentMajorRevision & "." & TextBoxCurrentDotRevision + 1, "00.0")
3912 Else
3913 TextBoxNextRevisionTextDot.Text = Format(TextBoxCurrentMajorRevision & "." & TextBoxCurrentDotRevision + 1, "00.00")
3914 End If
3915
3916 'ADDITIONAL REVISIONS
3917 RevisionsValuesAdditionalRevisions
3918 End If
3919 End If
3920 End If
3921End Sub
3922Private Function FindRevisionsOnFirstSheet() As Boolean
3923 FindRevisionsOnFirstSheet = True
3924 If CheckBoxDrawingBorderExists.Value = True Then
3925 '-------------------------------------------------------------------------------
3926 'How to check that a revision block already exists and the number of
3927 'revision blocks there are
3928 '-------------------------------------------------------------------------------
3929 Dim i As Integer
3930 Dim CurrentRevisionIdentifier As Integer
3931 Dim MinorRevision As Boolean
3932 InitBackgroundView
3933
3934 'Need to make the check against a capitalised INITIAL RELEASE as older drawings were INITIAL RELEASE and newer drawings are Initial Release
3935 If UCase(DrwTexts.GetItem("TitleBlock_Text_Revision_Modification_Description").Text) <> "INITIAL RELEASE" Then
3936 FindRevisionsOnFirstSheet = False
3937 'Tell the user that no revisions exist
3938 TextBoxInfoGeneral ("There are no revisions to copy - aborting command")
3939 Exit Function
3940 Else
3941
3942 'Check the number of revision block on the drawing
3943 'There is already one on the drawing border so the first number returned should be 2 for a new drawing
3944 CurrentRevisionIdentifier = 1
3945 'Count how many texts are in the drawing
3946 i = 0
3947 While (i < DrwTexts.Count)
3948 i = i + 1
3949 Set Text = DrwTexts.Item(i)
3950 'DrwTexts.Item(1).text
3951 If (Left(Text.Name, 25) = "TitleBlock_Rev_Numb_Text_") Then
3952
3953 ReDim Preserve CapturedRevisions(CurrentRevisionIdentifier - 1)
3954
3955 'Find out if the revision was a major or minor
3956 If Right(Text.Text, 1) = "0" Then
3957 MinorRevision = False
3958 Else
3959 MinorRevision = True
3960 End If
3961
3962 CurrentRevisionIdentifier = CurrentRevisionIdentifier + 1
3963
3964 'Capture the following MinorRevision(True/False)
3965 'Revision, Initials, Checker's Initials & Date
3966 CapturedRevisions(CurrentRevisionIdentifier - 2) = MinorRevision & "|" & _
3967 Text.Text & "|" & _
3968 DrwTexts.GetItem("TitleBlock_Rev_Text_Initials_" & CurrentRevisionIdentifier).Text & "|" & _
3969 DrwTexts.GetItem("TitleBlock_Rev_Text_Checked_Initials_" & CurrentRevisionIdentifier).Text & "|" & _
3970 DrwTexts.GetItem("TitleBlock_Rev_Text_Date_" & CurrentRevisionIdentifier).Text
3971
3972 End If
3973 Wend
3974
3975 'Check if no extra revisions are found - if not, then it's an initial revision
3976 If CurrentRevisionIdentifier = 1 Then
3977 FindRevisionsOnFirstSheet = False
3978 'INITIAL REVISION
3979 TextBoxInfoGeneral ("There are no revisions on the first sheet to refer too - aborting command")
3980 End If
3981 End If
3982 End If
3983End Function
3984Private Sub CheckRevisionCanbeAdded()
3985 If CheckBoxDrawingBorderExists.Value = True Then
3986 If NumberOfGenerativeViews = 0 Then
3987 RevBlockText = TextBoxNextRevisionTextMajor.Value
3988 TextBoxInfoRevision ("There is no generative view (view with a link to a part, product or scene) on your drawing" _
3989 & " - The revision has been extracted from your existing revisions on your drawing sheet - " & RevBlockText)
3990 Else
3991 Dim ParameterViewName As String
3992 ParameterViewName = "[" & Right(ComboBoxProductDrawnView.Value, Len(ComboBoxProductDrawnView.Value) - 4) & "]"
3993
3994 'If the part is a new part that has been created by standard CATIA
3995 'and not created through the PNG.
3996 If TextBoxProductDrawnVersion.Value = "" Then
3997 TextBoxInfoRevision ("The Parameter view " & ParameterViewName & " is linked to a " & TextBoxProductDrawnType.Value & " that has no revision value." & vbCrLf & _
3998 "The revision will be assumed to be 01")
3999 'FormDraftDrawingBorder.Repaint
4000 End If
4001
4002 '#############################
4003 'If Parameter View Type is PRC
4004 '#############################
4005 If TextBoxProductDrawnType.Value = "PRC" Then
4006 TextBoxInfoRevision ("You have a parameter view " & ParameterViewName & " that is linked to a PRC. " & _
4007 "Before the drawing border can add an issue you must:" & vbCrLf & _
4008 "Load the PDM Context of this drawing (data associated with the drawing), " & _
4009 "Select the drawing part number in the top left window, " & _
4010 " Right hand mouse button > select Load PDM Conext")
4011 RevisionCanBeAdded = False
4012 Else
4013
4014 '#########################################
4015 'If Parameter View Type is Product or Part
4016 '#########################################
4017
4018 'Now need to check that the last major revision on the drawing matches
4019 'the version from the parameter view's part/product
4020
4021 Dim ParametersViewVersion As Integer
4022 Dim NextMajorRevision As Integer
4023 Dim RevisionTextWarning As String
4024
4025 If TextBoxProductDrawnVersion.Value = "" Then
4026 ParametersViewVersion = "01"
4027 Else
4028 ParametersViewVersion = TextBoxProductDrawnVersion
4029 End If
4030 NextMajorRevision = TextBoxNextRevisionTextMajor
4031
4032 'Check if the revision from the parameters view is greater than or equal to the Next Major Revision
4033 If ParametersViewVersion >= NextMajorRevision Then
4034 RevisionCanBeAdded = True
4035 Else
4036 RevisionCanBeAdded = False
4037
4038 RevisionTextWarning = "If you are attempting to perform a major revision - The 'Border (Auto) > Revision' button has been disabled" & vbCrLf & _
4039 "The next revision (" & Format(NextMajorRevision, "00") & ") calculated from last revision on the sheet (" & TextBoxCurrentRevisionText & ") must be less than or equal to the Parameters view version (" & TextBoxProductDrawnVersion & "). The following is a list of possible reasons:"
4040
4041 If TextBoxProductDrawnType.Value = "Product" Then
4042 'If Parameter View Type is Product - add additional info
4043 RevisionTextWarning = RevisionTextWarning & vbCrLf & _
4044 " - PVR revision incorrect - If the Parameter view is pointing at a PVR, Check the PVRs Revision (Properties > Product > Revision)" & vbCrLf & _
4045 " - Check the revision matches the PVRs revision in the filename and if not manually change it to be the same as the revision in the filename - known CATIA issue."
4046 End If
4047 'Add additional info if for parts/products
4048 RevisionTextWarning = RevisionTextWarning & vbCrLf & _
4049 " - Part/Product requires versioning - Use Edit > Links > Pointed Documents > select the view " & ParameterViewName & " > check the pointed part/product is at the correct version" & vbCrLf & _
4050 " - The chosen Parameters view " & ParameterViewName & " does not correspond to the revisions on the drawing - please choose the correct parameters view"
4051
4052 TextBoxInfoRevision (RevisionTextWarning)
4053 End If
4054 End If
4055 End If
4056 End If
4057End Sub
4058Private Sub CheckFirstViewCanBeUpdated()
4059 Dim FirstDrawingViewIdentifier As Integer
4060 FirstDrawingViewIdentifier = ExtractViewID
4061 'Take the input (integer) and make that the first view
4062 'Ignoring inputs that the main [1]& background view [2] & 1st view [3]
4063 If FirstDrawingViewIdentifier = 1 Or FirstDrawingViewIdentifier = 2 Or FirstDrawingViewIdentifier = 3 Then
4064 CheckBoxUpdateFirstView.Value = False
4065 FirstViewCanBeUpdated = False
4066 Else
4067 CheckBoxUpdateFirstView.Value = True
4068 FirstViewCanBeUpdated = True
4069 End If
4070End Sub
4071Private Sub RevisionsValuesNoDrawing()
4072
4073 'Drawing Border (Auto) Tab
4074 CheckBoxDrawingBorderExists.Value = False
4075 CheckBoxProvisionalRevision.Value = False
4076 CheckBoxInitialRevision.Value = False
4077 CheckBoxAdditionalRevision = False
4078
4079
4080 'Update the Drawing Border Form to display the drawing border version
4081 DrawingBorderCurrentVersion = ""
4082 UpdateDrawingBorderExistVersion (DrawingBorderCurrentVersion)
4083
4084 'Revisions Tab
4085 TextBoxCurrentMajorRevision.Text = ""
4086 TextBoxCurrentDotRevision.Text = ""
4087 TextBoxCurrentRevisionText.Text = ""
4088
4089 TextBoxCurrentRevisionIdentifier.Text = ""
4090
4091 CheckBoxCurrentExistingDrawing.Value = False
4092 CheckBoxCurrentProvisionalRevision.Value = False
4093 CheckBoxCurrentInitialRevision.Value = False
4094 CheckBoxCurrentAdditionalRevision.Value = False
4095
4096 TextBoxNextRevisionTextMajor.Text = "01.0"
4097 TextBoxNextRevisionTextDot.Text = "01.0"
4098
4099 CheckBoxNextExistingDrawing.Value = True
4100 CheckBoxNextProvisionalRevision.Value = True
4101 CheckBoxNextInitialRevision.Value = False
4102 CheckBoxNextAdditionalRevision.Value = False
4103
4104 LabelNextDotRevision.Visible = False
4105 LabelNextDotRevisionArrow.Visible = False
4106 TextBoxNextRevisionTextDot.Visible = False
4107
4108End Sub
4109Private Sub RevisionsValuesProvisionalRevision()
4110
4111 'Drawing Border (Auto) Tab
4112 CheckBoxDrawingBorderExists.Value = True
4113 CheckBoxProvisionalRevision.Value = True
4114 CheckBoxInitialRevision.Value = False
4115 CheckBoxAdditionalRevision = False
4116
4117 'Revisions Tab
4118 TextBoxCurrentMajorRevision.Text = "01"
4119 TextBoxCurrentDotRevision.Text = "0"
4120 TextBoxCurrentRevisionText.Text = "01.0"
4121
4122 TextBoxCurrentRevisionIdentifier.Text = "1"
4123
4124 CheckBoxCurrentExistingDrawing.Value = True
4125 CheckBoxCurrentProvisionalRevision.Value = True
4126 CheckBoxCurrentInitialRevision.Value = False
4127 CheckBoxCurrentAdditionalRevision.Value = False
4128
4129 TextBoxNextRevisionTextMajor.Text = "01.0"
4130 TextBoxNextRevisionTextDot.Text = "01.0"
4131
4132 CheckBoxNextExistingDrawing.Value = True
4133 CheckBoxNextProvisionalRevision.Value = False
4134 CheckBoxNextInitialRevision.Value = True
4135 CheckBoxNextAdditionalRevision.Value = False
4136
4137 LabelNextDotRevision.Visible = False
4138 LabelNextDotRevisionArrow.Visible = False
4139 TextBoxNextRevisionTextDot.Visible = False
4140
4141End Sub
4142Private Sub RevisionsValuesInitialRevision()
4143
4144 'Drawing Border (Auto) Tab
4145 CheckBoxDrawingBorderExists.Value = True
4146 CheckBoxProvisionalRevision.Value = False
4147 CheckBoxInitialRevision.Value = True
4148 CheckBoxAdditionalRevision = False
4149
4150 'Revisions Tab
4151 TextBoxCurrentMajorRevision.Text = "01"
4152 TextBoxCurrentDotRevision.Text = "0"
4153 TextBoxCurrentRevisionText.Text = "01.0"
4154
4155 TextBoxCurrentRevisionIdentifier.Text = "1"
4156
4157 CheckBoxCurrentExistingDrawing.Value = True
4158 CheckBoxCurrentProvisionalRevision.Value = False
4159 CheckBoxCurrentInitialRevision.Value = True
4160 CheckBoxCurrentAdditionalRevision.Value = False
4161
4162 TextBoxNextRevisionTextMajor.Text = "02.0"
4163 TextBoxNextRevisionTextDot.Text = "01.1"
4164
4165 CheckBoxNextExistingDrawing.Value = True
4166 CheckBoxNextProvisionalRevision.Value = False
4167 CheckBoxNextInitialRevision.Value = False
4168 CheckBoxNextAdditionalRevision.Value = True
4169
4170 LabelNextDotRevision.Visible = True
4171 LabelNextDotRevisionArrow.Visible = True
4172 TextBoxNextRevisionTextDot.Visible = True
4173
4174End Sub
4175Private Sub RevisionsValuesAdditionalRevisions()
4176
4177 'Drawing Border (Auto) Tab
4178 CheckBoxDrawingBorderExists.Value = True
4179 CheckBoxProvisionalRevision.Value = False
4180 CheckBoxInitialRevision.Value = False
4181 CheckBoxAdditionalRevision = True
4182
4183 'Revisions Tab
4184 CheckBoxCurrentExistingDrawing.Value = True
4185 CheckBoxCurrentProvisionalRevision.Value = False
4186 CheckBoxCurrentInitialRevision.Value = False
4187 CheckBoxCurrentAdditionalRevision.Value = True
4188
4189 CheckBoxNextExistingDrawing.Value = True
4190 CheckBoxNextProvisionalRevision.Value = False
4191 CheckBoxNextInitialRevision.Value = False
4192 CheckBoxNextAdditionalRevision.Value = True
4193
4194 LabelNextDotRevision.Visible = True
4195 LabelNextDotRevisionArrow.Visible = True
4196 TextBoxNextRevisionTextDot.Visible = True
4197
4198End Sub
4199Private Sub CurrentSheetProperties()
4200
4201 '-------------------------------------------------------------------------------
4202 'How to compute Current drawing properties (height, width, sheetformat)
4203 'Also updates the display on the FormDraftDrawingBorder
4204 '-------------------------------------------------------------------------------
4205
4206 InitMainView
4207 Height = DrwSheet.GetPaperHeight
4208 Width = DrwSheet.GetPaperWidth
4209 sheetformat = DrwSheet.PaperSize
4210
4211 Dim documentStd As CatDrawingStandard
4212 documentStd = DrwDocument.Standard
4213 If (documentStd = catISO) Then
4214 If sheetformat = 13 Then
4215 displayFormat = "USER"
4216 Else
4217 displayFormat = "A" + CStr(sheetformat - 2)
4218 End If
4219 Else
4220 Select Case sheetformat
4221 Case 0
4222 displayFormat = "Letter"
4223 Case 1
4224 displayFormat = "Legal"
4225 Case 7
4226 displayFormat = "A"
4227 Case 8
4228 displayFormat = "B"
4229 Case 9
4230 displayFormat = "C"
4231 Case 10
4232 displayFormat = "D"
4233 Case 11
4234 displayFormat = "E"
4235 Case 12
4236 displayFormat = "F"
4237 Case 13
4238 displayFormat = "J"
4239 End Select
4240 End If
4241
4242 LabelCurrentSheetSize.Caption = "Current: " & displayFormat
4243
4244End Sub
4245Private Sub ImportDrawingBorder(drawingName As String)
4246 CATIA.DisplayFileAlerts = False
4247 Dim MyDocuments As Documents
4248 Dim TemplateDocument As Document
4249 Dim OriginalDocument As Document
4250 Dim TemplateSelection 'As selection
4251 Dim OrigDwrSheets As DrawingSheets
4252 Dim OrigDwrSheet As DrawingSheet
4253 Dim OrigDwrViews As DrawingViews
4254 Dim OrigDwrView As DrawingView
4255 Dim OrigDrwSelection As Selection
4256
4257 ' note the original document and the current sheet and view names
4258 Set OriginalDocument = CATIA.ActiveDocument
4259 Set OrigDwrSheets = OriginalDocument.Sheets
4260 Set OrigDwrSheet = OrigDwrSheets.ActiveSheet
4261 Set OrigDwrViews = OrigDwrSheet.Views
4262 Set OrigDwrView = OrigDwrViews.ActiveView
4263
4264 ' open the drawing that contains the titleblock that we want
4265 Set MyDocuments = CATIA.Documents
4266 Set TemplateDocument = MyDocuments.Open(drawingName)
4267
4268 '#### V5R24 #### ProgressBarDrawingBorder.Value = 60
4269
4270 ' select every entity that starts with the name "titleblock" - in any upper/lower case
4271 Set TemplateSelection = TemplateDocument.Selection
4272 TemplateSelection.Clear
4273
4274 '########## Copy background view data #############
4275
4276 'copy the Titleblock text and lines if you are creating a new drawing
4277 'Otherwise only copy the lines
4278 'Depending upon the chosen Tolerance select the Tol Table and copy it
4279
4280 'Necessary for the selection in R19 - removed in R22
4281 'CATIA.HSOSynchronized = False
4282
4283 'CheckBoxDrawingBorderExists is true - means re-size rather than creation
4284 If CheckBoxDrawingBorderExists.Value = True Then
4285 'Resizing
4286 If ChosenTol = "ToleranceTableNone" Then
4287 TemplateSelection.Search "(Name=titleblock_line* + Name=frame*),all"
4288 Else
4289 TemplateSelection.Search "(Name=titleblock_line* + Name=frame* + Name=" & ChosenTol & "*),all"
4290 End If
4291 Else
4292 'Creation
4293 If ChosenTol = "ToleranceTableNone" Then
4294 TemplateSelection.Search "(Name=titleblock* + Name=frame* + Name=MainView_Frame_*),all"
4295 Else
4296 TemplateSelection.Search "(Name=titleblock* + Name=frame* + Name=MainView_Frame_* + Name=" & ChosenTol & "*),all"
4297 End If
4298 End If
4299 TemplateSelection.Copy
4300 TemplateSelection.Clear
4301
4302 'Necessary for the selection in R19 - removed in R22
4303 'CATIA.HSOSynchronized = True
4304
4305 'Activate the original drawing
4306 OriginalDocument.Activate
4307
4308 ' get to the background view on that sheet and set it as the active view
4309 Set OrigDwrViews = OrigDwrSheet.Views
4310 Set OrigDwrView = OrigDwrViews.Item(2)
4311 OrigDwrView.Activate
4312
4313 ' Create an object of selection for the source document
4314 Set OrigDrwSelection = OriginalDocument.Selection
4315
4316 ' Clear the selection then add the view to which the geometry will be pasted in the selection
4317 OrigDrwSelection.Clear
4318 OrigDrwSelection.Add OrigDwrView
4319
4320 ' Paste the clipboard and clear the selection
4321 OrigDrwSelection.Paste
4322 OrigDrwSelection.Clear
4323
4324 'close the template drawing
4325 TemplateDocument.Close
4326
4327 '#### V5R24 #### ProgressBarDrawingBorder.Value = 65
4328
4329 'Activate front view - this is necessary as the paste automatically activates the background view
4330 Set OrigDwrView = OrigDwrViews.Item(1)
4331 OrigDwrView.Activate
4332
4333 'Activate the original drawing - necessary to update the display
4334 OriginalDocument.Activate
4335
4336 'Now cut the objects that have been copied to the background view and paste them to the foreground view
4337 If CheckBoxDrawingBorderExists.Value = False Then
4338 ' select every entity that starts with "TitleBlock_Rev" - in any upper/lower case
4339 FilterSelection ("Name=MainView_Frame_*,sel")
4340
4341 ' delete all that was selected
4342 If Selection.Count > 0 Then
4343 Selection.Cut
4344 'Clear the paste object
4345 OrigDrwSelection.Clear
4346 'Set the MainView to be the current paste object
4347 OrigDrwSelection.Add OrigDwrView
4348 ' Paste the clipboard and clear the selection
4349 OrigDrwSelection.Paste
4350 OrigDrwSelection.Clear
4351 End If
4352 End If
4353End Sub
4354Private Sub ImportDrawingBorderToleranceTablesAndDrawingStandardText(drawingName As String)
4355 CATIA.DisplayFileAlerts = False
4356 Dim MyDocuments As Documents
4357 Dim TemplateDocument As Document
4358 Dim OriginalDocument As Document
4359 Dim TemplateSelection 'As selection
4360 Dim OrigDwrSheets As DrawingSheets
4361 Dim OrigDwrSheet As DrawingSheet
4362 Dim OrigDwrViews As DrawingViews
4363 Dim OrigDwrView As DrawingView
4364 Dim OrigDrwSelection As Selection
4365
4366 ' note the original document and the current sheet and view names
4367 Set OriginalDocument = CATIA.ActiveDocument
4368 Set OrigDwrSheets = OriginalDocument.Sheets
4369 Set OrigDwrSheet = OrigDwrSheets.ActiveSheet
4370 Set OrigDwrViews = OrigDwrSheet.Views
4371 Set OrigDwrView = OrigDwrViews.ActiveView
4372
4373 ' open the drawing that contains the titleblock that we want
4374 Set MyDocuments = CATIA.Documents
4375 Set TemplateDocument = MyDocuments.Open(drawingName)
4376
4377 '#### V5R24 #### ProgressBarDrawingBorder.Value = 60
4378
4379 ' select every entity that starts with the name "titleblock" - in any upper/lower case
4380 Set TemplateSelection = TemplateDocument.Selection
4381 TemplateSelection.Clear
4382
4383 '########## Copy background view data #############
4384
4385 'Depending upon the chosen Tolerance select the Tol Table and copy it
4386
4387 'Necessary for the selection in R19 - removed in R22
4388 'CATIA.HSOSynchronized = False
4389
4390 TemplateSelection.Search "(Name=Frame_Text_Dimension_in_mm + Name=" & ChosenTol & "*),all"
4391
4392 TemplateSelection.Copy
4393 TemplateSelection.Clear
4394
4395 'Necessary for the selection in R19 - removed in R22
4396 'CATIA.HSOSynchronized = True
4397
4398 'Activate the original drawing
4399 OriginalDocument.Activate
4400
4401 ' get to the background view on that sheet and set it as the active view
4402 Set OrigDwrViews = OrigDwrSheet.Views
4403 Set OrigDwrView = OrigDwrViews.Item(2)
4404 OrigDwrView.Activate
4405
4406 ' Create an object of selection for the source document
4407 Set OrigDrwSelection = OriginalDocument.Selection
4408
4409 ' Clear the selection then add the view to which the geometry will be pasted in the selection
4410 OrigDrwSelection.Clear
4411 OrigDrwSelection.Add OrigDwrView
4412
4413 ' Paste the clipboard and clear the selection
4414 OrigDrwSelection.Paste
4415 OrigDrwSelection.Clear
4416
4417 'close the template drawing
4418 TemplateDocument.Close
4419
4420 '#### V5R24 #### ProgressBarDrawingBorder.Value = 65
4421
4422 'Activate front view - this is necessary as the paste automatically activates the background view
4423 Set OrigDwrView = OrigDwrViews.Item(1)
4424 OrigDwrView.Activate
4425
4426 'Activate the original drawing - necessary to update the display
4427 OriginalDocument.Activate
4428
4429 'Now cut the objects that have been copied to the background view and paste them to the foreground view
4430 If CheckBoxDrawingBorderExists.Value = False Then
4431 ' select every entity that starts with "TitleBlock_Rev" - in any upper/lower case
4432 FilterSelection ("Name=MainView_Frame_*,sel")
4433
4434 ' delete all that was selected
4435 If Selection.Count > 0 Then
4436 Selection.Cut
4437 'Clear the paste object
4438 OrigDrwSelection.Clear
4439 'Set the MainView to be the current paste object
4440 OrigDrwSelection.Add OrigDwrView
4441 ' Paste the clipboard and clear the selection
4442 OrigDrwSelection.Paste
4443 OrigDrwSelection.Clear
4444 End If
4445 End If
4446End Sub
4447Function CATmyDateTimeFormat(DateTime)
4448 '-------------------------------------------------------------------------------
4449 'How to Return the date in the format 01/Jan/2004
4450 '-------------------------------------------------------------------------------
4451 'USAGE:
4452 'myDateBefore = date()
4453 'myDateAfter = myDateTimeFormat(myDateBefore)
4454
4455 DateTime = Now
4456
4457
4458 Dim myDateTime_tmp As String
4459 Dim myDateTime_day
4460 Dim myDateTime_mth
4461 Dim myDateTime_yr
4462 Dim myDateTime_hr
4463 Dim myDateTime_min
4464
4465 myDateTime_tmp = CDate(DateTime)
4466 myDateTime_day = Day(myDateTime_tmp)
4467 myDateTime_mth = MonthName(Month(myDateTime_tmp), True)
4468 myDateTime_yr = Year(myDateTime_tmp)
4469 myDateTime_hr = Hour(myDateTime_tmp)
4470 myDateTime_min = Minute(myDateTime_tmp)
4471
4472 If Len(myDateTime_day) = 1 Then myDateTime_day = "0" & myDateTime_day
4473 If Len(myDateTime_hr) = 1 Then myDateTime_hr = "0" & myDateTime_hr
4474 If Len(myDateTime_min) = 1 Then myDateTime_min = "0" & myDateTime_min
4475
4476 CATmyDateTimeFormat = myDateTime_day & " " & myDateTime_mth & " " & myDateTime_yr
4477End Function
4478Private Sub CommandCancel_Click()
4479 Unload FormDraftDrawingBorder
4480End Sub