Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting Measurements from Catia to Excel using Macros 1

Status
Not open for further replies.

esho99

Automotive
Apr 12, 2022
1
DE
Hallo,

I need to import specific defined measurements from a tree to a excel sheet.
In the Photos attached below are the screenshots
Photo - 1:
Screenshot of the Selected items in Tree with the circled values that i want to Export to Excel.

Photo - 2:
The second Screenshot is the Code in CatiaScript ive wrote till now.

Photo - 3:
Screenshot from Excel Output.

Photo - 4:
Desired Output of Excel.
 
Replies continue below

Recommended for you

could you pls. print out your code in the post, rather than posting a picture of it?

regards,
LWolf
 
I actually did something similar a while back :)
had to do two selections...
the first one searches for the measures, and the second for all the parameters contained in each and every measure.
I didn't go for Excel, but rather for a csv file (hence the ";")
hope you can tweak it according to your needs.

Code:
Dim USel As Selection
Set USel = CATIA.ActiveDocument.Selection
USel.Clear

Dim SearchStr As String
SearchStr = "'Digital Mockup'.Measure;in"
USel.Search SearchStr

If USel.Count > 0 Then

    ReDim ToArray(USel.Count - 1)
    Dim ii, i, k As Integer
    Dim MyParam As Parameter

    For ii = 1 To USel.Count
        Set ToArray(ii - 1) = USel.item(ii).Value
    Next
                
    USel.Clear
    For i = 0 To UBound(ToArray)
        USel.Add ToArray(i)
        USel.Search "Knowledgeware.Parameter;sel"
        If USel.Count > 0 Then
        ValueTrain = ""
            For k = 1 To USel.Count
                Set MyParam = USel.item(k).Value
                ValueTrain = ValueTrain & ";" & MyParam.Value
            Next
            If k = 2 Then ValueTrain = ValueTrain & ";;"
            If k = 3 Then ValueTrain = ValueTrain & ";"
        MeasureName = GetUsefulName(MyParam.name)
        ToArray(i) = MeasureName & ";;" & part1.name & ValueTrain
        End If
        USel.Clear
    Next
End If

regards,
LWolf
 
Requested value is stored as Parameter under measurement feature. To retrieve all parameters aggregated within a feature use Parameters.Sublist method. To identify required parameter use index or it's name:

Code:
set measParams = CATIA.ActiveDocument.Product.Sublist(measurement, false)
measValue = measParams.Item(1).Value
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top