This topic contains 4 replies, has 2 voices, and was last updated by  Emmett Ross 3 years, 1 month ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1213

    fredtheblue
    Participant

    `I have a macro that creates pdf’s of active drawing sheets to a directory. It works fine but always creates the detail sheet too. This I believe is coming from the line:-
    docDrawing.ExportData intrare, “pdf” i.e the docdrawing command.
    Do you have a way of exporting only the mysheet variable with the exportdata command to only create a pdf of the sheet.1 and not the detail sheet?

    Sub CATMain()

    Dim docDrawing As DrawingDocument
    Dim iDoc
    Dim k As Integer
    Dim j As Integer
    Dim MySheet As DrawingSheet
    Dim folderinput As String

    folderinput = InputBox(“save your pdf files here”, “folder”, “K:\DBRIDDON\PDF\”)

    For iDoc = 1 To CATIA.Documents.Count
    If (TypeName(CATIA.Documents.Item(iDoc)) = “DrawingDocument”) Then

    Set docDrawing = CATIA.Documents.Item(iDoc)
    k = docDrawing.Sheets.Count
    For Each MySheet In docDrawing.Sheets
    If MySheet.IsDetail Then
    k = k – 1
    End If

    docDrawing.Sheets.Item(1).Activate
    Set window1 = CATIA.ActiveWindow
    Set specsViewer1 = window1.ActiveViewer
    specsViewer1.Reframe

    Filename = Left(docDrawing.Name, Len(docDrawing.Name) – 11)

    Dim path as String
    path = folderinput & Filename & “.pdf”

    docDrawing.ExportData path, “pdf”

    Next

    End If
    Next

    MsgBox (“macro ended.”)

    End Sub

    thanks

    Dave

    • This topic was modified 3 years, 1 month ago by  fredtheblue.
    • This topic was modified 3 years, 1 month ago by  fredtheblue.
    • This topic was modified 3 years, 1 month ago by  fredtheblue.
    #1217

    Emmett Ross
    Keymaster

    Hi Dave. Thanks for registering for the forum. Looks like your code is close but you’re subtracting from the count and not actually skipping the detail sheet. Try something like the code shown below where you use IsDetail to check whether the sheet is a detail sheet or not and if so to skip it. Let me know if this works for you.

    #1218

    fredtheblue
    Participant

    Hi Emmot,
    I’ve edited what I think is needed, but your answer was a bit cryptic for my vba level. I cant understand what the j is doing? any ways I’ve edited as below but I’m getting a “object variable or with block variable not set” error at the isDetail line. (Is this because mysheet is a Boolean now and not a DrawingSheet?

    (note this is a catvba so all variables have to be set)

    Sub CATMain()

    Dim docDrawing As DrawingDocument
    Dim iDoc As Integer
    Dim i As Integer
    Dim MySheet As DrawingSheet
    Dim folderinput As String

    folderinput = InputBox(“save your pdf files here”, “folder”, “K:\DBRIDDON\PDF\”)

    For iDoc = 1 To CATIA.Documents.Count
    If (TypeName(CATIA.Documents.Item(iDoc)) = “DrawingDocument”) Then

    Set docDrawing = CATIA.Documents.Item(iDoc)

    For i = 1 To docDrawing.Sheets.Count
    If MySheet.IsDetail = False Then
    MySheet.Activate
    End If

    Set window1 = CATIA.ActiveWindow
    Set specsViewer1 = window1.ActiveViewer
    specsViewer1.Reframe

    Filename = Left(docDrawing.Name, Len(docDrawing.Name) – 11)

    Dim intrare As String
    intrare = folderinput & Filename & “.pdf”

    docDrawing.ExportData intrare, “pdf”

    Next i

    End If
    Next iDoc

    MsgBox (“macro ended.”)

    End Sub

    • This reply was modified 3 years, 1 month ago by  fredtheblue.
    #1220

    fredtheblue
    Participant

    Emmott,
    I’ve added the line

    Set MySheet = docDrawing.Sheets.Item(i)

    before the If MySheet.IsDetail = False Then, line and the code runs but I’m still recreating the detail sheet pdf’s?

    Could you explain why the code is not ignoring the detail sheets now?

    Dave

    #1221

    Emmett Ross
    Keymaster

    OK, I just did a quick test and it looks like the code I am using works for TIF files but still exports the detail sheet for PDFs. I’ll have to look into it more why that is.

Viewing 5 posts - 1 through 5 (of 5 total)

The forum ‘CATIA Macro Programming’ is closed to new topics and replies.