Let’s Start Programming! Forums CATIA Macro Programming Notes as Parameters in Geometric Sets/Hybrid Bodies

This topic contains 1 reply, has 2 voices, and was last updated by  Emmett Ross 3 years, 5 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #1071

    Ben Zander

    I’m working on a macro to extract notes from Catia Part files that are created as parameters under a Geometric set in the Tree. It took me a while, but I finally got it to work, I’ve posted a bit of the code below, but my question now is, can you help me develop a way to step through each parameter, so as to not have to know the specific name of each or how many might be there. See Below

    Example of Tree

    -xy plane
    -yz plane
    -zx plane
    -Axis Systems
    -Part1 Body
    -GeoSet1 Notes
    –‘Notexyz7485902’=Notexyz7485902| Some info about the part here
    –‘Notexyz7452871’=Notexyz7452871| Another note about the part


    Here is an example of my code:

    Sub CATMain()

    Dim partDocument1 As Document
    Dim part1 As Part
    ‘Error Handling
    On Error Resume Next
    Set partDocument1 = CATIA.ActiveDocument
    Set part1 = partDocument1.Part

    ‘Set Object set to GeoSet1 Notes
    Dim objGeoSet As HybridBody
    Dim obj1Params As Parameters
    Set objGeoSet=part1.HybridBodies.Item(“GeoSet1 Notes”)
    Set obj1Params=part1.Parameters.SubList(objGeoSet,False)

    ‘Get Values for Parameters of GeoSet1 Notes
    Dim SnParam1 as Parameter
    Set SnParam1=obj1Params.Item(“Notexyz7485902”)
    ‘Unlock Parameter
    Dim Note1 as String

    Dim SnParam2 as Parameter
    Set SnParam2=obj1Params.Item(“Notexyz7452871″)
    ‘Unlock Parameter
    Dim Note2 as String

    ‘Create and Write Notes to TXT File
    Dim strFilePath as String
    Dim objFSO as Object
    Dim objStream as Object

    Set objFSO=CreateObject(“Scripting.FilesystemObject”)
    Set objStream=objFSO.OpenTextFile(strFilePath, 8, True, 0)

    ObjStream.WriteLine (Note1)
    ObjStream.WriteLine (Note2)



    Emmett Ross

    Hi Ben. Have you tried adding a For..Next loop to the code? Something like this maybe(I haven’t tested it myself yet):

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

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