Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • in reply to: Macro code save images and list parts in Excel #1451

    Tony_bcn
    Participant

    Hello Emmet,

    as discussed , I started to retrieve information from a list of catparts,
    using the code published in your book.

    Now I would like to be able to run this script on every part and export the properties into the same Excel sheet. ( like I am showing in this code)
    Any ideas how to add on to my code to accomplish this?

    Remarks: The code opens the excel sheet but is not able to export the properties of the catparts.

    Any ideas how to fix this issue?

    Thanks and regards

    Sub CATMain()
    Dim documents1 As Documents
    Set documents1 = CATIA.Documents
    MsgBox “The number of documents is ” & documents1.Count
    Dim doc1 As String
    Set doc1 = documents1.Item(1)
    ‘MsgBox doc1.Name
    ‘MsgBox doc1.FullName
    ‘For Each doc1 in documents1
    ‘MsgBox doc1.Name
    ‘Next
    Dim partDoc1 as PartDocument
    Set partDoc1 = doc1
    MsgBox partDoc1.Name

    ‘to excel

    Dim Excel As Object
    Dim workbooks As workbooks
    Dim workbook As workbook
    Dim worksheet As Excel.worksheet

    On Error Resume Next
    Set Excel = GetObject(, “EXCEL.Application”)
    If Err.Number <> 0 Then
    Err.Clear
    Set Excel = CreateObject(“EXCEL.Application”)
    Else
    Err.Clear
    MsgBox “Please note you have to close Excel”, vbCritical
    Exit Sub
    End If

    Excel.Visible = True

    ‘load a sheet

    Set workbooks = Excel.Application.workbooks
    Set myworkbook = Excel.workbooks.Add
    Set myworksheet = Excel.ActiveWorkbook.Add
    Set myworksheet = Excel.Sheets.Add

    ‘download the properties
    ‘row one
    Excel.Cells(1,1)=”Part Number”
    Excel.Cells(1,2)=”Thickness”
    Excel.Cells(1,3)=”Material”
    Excel.Cells(1,4)=”Mass”

    ‘row 2
    Excel.Cells(2,1)= doc1
    Excel.Cells(2, 2) = getThickness
    Excel.Cells(2, 3) = getMaterial
    Excel.Cells(2, 4) = getMass

    End Sub

    in reply to: Macro code save images and list parts in Excel #1449

    Tony_bcn
    Participant

    Hello Emmet,

    thanks again for your nice reply.

    The macro I want to create should do the steps described below

    From a list of CAT Parts

    1. Open a CATpart
    2. Retrieve info from catpart (part number etc..)
    3. Change viewpoint to iso and hide the specification tree.
    4. Reframe part in window so that it is all visible.
    5. Take picture and store it in required location with specific filename (probably the catpart filename and the current date / time and the fileextension for the picture type.)
    6. Write info including hyperlink to open picture to an empty line in an excel file.
    7. Close the catpart
    8. Goto step 1.

    Regarding step number 2 I didn’ t find info regarding this topic and also I dont know how to create the loop in order to save the list of images.

    Thanks again and regards
    Toni

    PS: My current version is CATIA V5 R24

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