Forum Replies Created

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • in reply to: Getting others to use your macros #2065

    fredtheblue
    Participant

    Managers are generally ignorant of the benefit of vba automation. If I approach them and say I can save them time if they give me 2-3 days to develop a macro they wont authorize it. They think throwing bodies or working around the clock with the mouse on fire is the best way to get a task out of the door quicker.

    When other workers observe the benefit of a macro then they want it, however it’s often difficult to hand it over, as its my blood sweat and tears that went into it with no recompense or real thanks. Also these macros are not fully validated when they have been written for personal use.

    Larger companies employ application engineers who develop macros as their job. at my small private design company, I have a design task to do and there’s no real work time to develop macros, so I have to do them in my own time

    • This reply was modified 2 years, 5 months ago by  fredtheblue.
    in reply to: Closing drawings #2064

    fredtheblue
    Participant

    Thanks Matt much appreciated.

    Macro was amended as below and sometimes worked but more often than not the drawings looped more than once and then ended with a run-time error 13: type mismatch on the line “Set oDrawing = CATIA.Documents.Item(cDrawings.Item(i).Name)”

    I have changed the odrawing type to an object and this seems to have worked. I think this is a bit of a fiddle but it works!

    Option Explicit
    Sub CATMain()

    Dim iDoc As Integer
    Dim i As Integer
    Dim N As Integer
    Dim strType As String
    Dim cDrawings As New Collection
    Dim oDrawing As Object
    For iDoc = 1 To CATIA.Documents.Count
    CATIA.Documents.Item(iDoc).Activate

    strType = TypeName(CATIA.ActiveDocument)

    Select Case strType

    Case “DrawingDocument”

    cDrawings.Add CATIA.Documents.Item(iDoc)

    Case “ProductDocument”

    ‘ just to do something

    CATIA.StartCommand “Center Graph”

    Case “PartDocument”

    ‘ just to do something

    CATIA.StartCommand “Center Graph”

    End Select
    Next

    For i = 1 To cDrawings.Count
    Set oDrawing = CATIA.Documents.Item(cDrawings.Item(i).Name)
    oDrawing.Close

    Next

    MsgBox (“macro ended.”)

    End Sub

    cheers

    Dave

    in reply to: create pdfs #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

    in reply to: create pdfs #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.
Viewing 4 posts - 1 through 4 (of 4 total)