0

Is there any possibility to loop through open CATDrawing files using VBA?

I found below code but it is counting sheets inside the same CATDrawing file.

Dim drawingDocument1 As Document
Set drawingDocument1 = CATIA.ActiveDocument
Set oDrwView = drawingDocument1.Sheets.ActiveSheet.Views

Debug.Print drawingDocument1.Sheets.Count

For i = 1 To drawingDocument1.Sheets.Count
Set oSheet = drawingDocument1.Sheets.Item(i)
oSheet.Activate
Debug.Print oSheet.Name
Next

1 Answer 1

1

Therefor you can loop over the documents collection:

Sub CATMain()

    Dim oDoc as Document
    
    for each oDoc in CATIA.Documents
        if TypeName(oDoc) = "DrawingDocument" then
            MsgBox "Drawing: " & oDoc.Name & " is opened"
            'Do something with the drawing      
        End If  
    next

End Sub

Be aware, the documents collection include not only the documents which are opened in a own window, also these which are referenced. (e.g. PartDocument in a ProcuctDocument)

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your reply yes its working as expected thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.