I'm trying to create macro for Catia V5 that will automaticly unlock all views and update them. Macro updates all the views(when they are unlocked). Problem is it only unlocks views on sheet that i was currently at before running macro and then it wont update other views on other sheets.
So Unlocking of views will work only on Drawing Sheet that i had active last before running my macro. But if all of my views are unlocked and i run the macro it will update all of my views, but for some reason unlocking them when i have them locked wont work as previously stated above.
Sub CATMain()
Dim oDrawing As DrawingRoot
Dim oViews As DrawingViews
Dim oSheets As DrawingSheets
Set oDrawing = CATIA.ActiveDocument.DrawingRoot
Set oSheets = oDrawing.Sheets
Set oViews = oDrawing.Sheets.ActiveSheet.Views
Dim i, y As Integer
For y = 1 To oSheets.Count
oDrawing.Sheets.Item(y).Activate
For i = 1 To oViews.Count
oViews.Item(i).LockStatus = False
oDrawing.Sheets.ActiveSheet.Update
Next
Next
End Sub
I expect from my macro to unlock all views and update them on each sheet of drawing.
I'm not using Catia, but your code should look like this:
Sub CATMain()
Dim oDrawing As DrawingRoot
Dim oView As DrawingView
Dim oSheet As DrawingSheet
Set oDrawing = CATIA.ActiveDocument.DrawingRoot
For Each oSheet in oDrawing.Sheets
For Each oView in oSheet.Views
oView.LockStatus = False
oSheet.Update 'Not sure if required here, might be moved outside the loop?
Next
Next
End Sub