This topic contains 3 replies, has 2 voices, and was last updated by  polo 2 years, 5 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #2200


    Does anyone know of (or has an idea how to write ) a macro that gives a parts list of a product with associated images (screen shot, capture or drawing) of the parts?
    Thanks for any ideas.



    Okay I’m slowly getting there, but I can’t find how to change the view to isometric by macro… can anyone help?


    Emmett Ross

    Hi Polo. I’ve created part lists in Excel from CATProduct data. Changing the viewpoint to iso is actually an example taken straight out of my book ( Here’s how it is done:

    Sub CATMain()
    ‘declare the active document
    Dim oActDoc As Document
    Set oActDoc = CATIA.ActiveDocument

    ‘define the camera
    Dim camIsoView As Camera3D
    Set camIsoView = oActDoc.Cameras.Item(“* iso”)

    Dim oIsoViewPoint As Viewpoint3D
    Set oIsoViewPoint = camIsoView.Viewpoint3D

    ‘define the active window
    Dim oActWin As Window
    Set oActWin = CATIA.ActiveWindow

    ‘ set desired viewpoint for active viewer
    Dim oActViewer As Viewer3D
    Set oActViewer = oActWin.ActiveViewer

    oActViewer.Viewpoint3D = oIsoViewPoint

    End Sub

    Let me know if you need any more help making your parts list, and I would love to see the finished product.



    Thanks for the help,
    Here is my end (working) macro:

    Sub CATMain()
    ‘Cette macro permet de créer une part liste dans excel avec des images associé

    Dim doc As Documents
    Set doc = CATIA.Documents

    Set oexcel = CreateObject(“excel.application”)
    oexcel.Visible = True
    Set oexcelsheet = oexcel.Workbooks(oexcel.ActiveWorkbook.Name).Sheets(1)
    oexcelsheet.Range(“A” & 1).ColumnWidth = 50
    oexcelsheet.Range(“B” & 1).ColumnWidth = 15

    For D = 1 To doc.Count

    If TypeName(doc.Item(D)) Like “PartDocument” Then

    Dim partDocument1 As PartDocument
    Set partDocument1 = doc.Open(doc.Item(D).FullName)

    Dim MyViewer1 As Viewer
    Set MyViewer1 = CATIA.ActiveWindow.ActiveViewer

    Dim specsAndGeomWindow1 As SpecsAndGeomWindow
    Set specsAndGeomWindow1 = CATIA.ActiveWindow

    Dim viewer3D1 As Viewer3D
    Set viewer3D1 = specsAndGeomWindow1.ActiveViewer

    Dim viewpoint3D1 As Viewpoint3D
    Set viewpoint3D1 = viewer3D1.Viewpoint3D

    MyViewer1.Viewpoint3D = CATIA.ActiveDocument.Cameras.Item(1)


    Dim Chemin As String
    Chemin = “C:\Documents and Settings\co051\Bureau\Nouveau dossier\” & doc.Item(D).Name & “.jpeg”

    Dim MyViewer
    Set MyViewer = CATIA.ActiveWindow.ActiveViewer
    ‘—–Memorise le BackGround d’origine
    Dim color(2)
    Dim MyViewer_deb
    Set MyViewer_deb = MyViewer
    MyViewer_deb.GetBackgroundColor color
    ‘—–Passe en fond blanc
    MyViewer_deb.PutBackgroundColor Array(1, 1, 1)

    CATIA.StartCommand “Boussole”
    CATIA.StartCommand “Arbre de spécifications”
    MyViewer1.CaptureToFile catCaptureFormatJPEG, Chemin
    CATIA.StartCommand “Boussole”
    CATIA.StartCommand “Arbre de spécifications”

    ‘—–Retour au fond d’écran d’origine
    MyViewer_deb.PutBackgroundColor (color)

    oexcelsheet.Range(“A” & D).Value = doc.Item(D).Name
    oexcelsheet.Range(“A” & D).RowHeight = 100

    Dim ImageName As String
    ImageName = “Image” & D
    oexcelsheet.Range(“B” & D).Select
    oexcelsheet.Pictures.Insert(Chemin).Name = ImageName
    With oexcelsheet.Shapes(ImageName)
    .Left = 100
    .Top = 100
    .Width = 100
    .Height = 100
    End With

    oexcelsheet.Range(“B” & D).Select
    End If


    ‘—–Retour au fond d’écran d’origine
    MyViewer_deb.PutBackgroundColor (color)
    End Sub

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

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