Get all the parameters of active ipt

Get all the parameters of active ipt

tecnico.tbi
Explorer Explorer
477 Views
3 Replies
Message 1 of 4

Get all the parameters of active ipt

tecnico.tbi
Explorer
Explorer

Good morning,
I need to get a list with all the parameters of the part in which the ilogic rule is executed.
I would like to know how to do it with the parameters api.
Best regards

0 Likes
478 Views
3 Replies
Replies (3)
Message 2 of 4

A.Acheson
Mentor
Mentor

Here is the the API sample written in VBA.

To convert to the ilogic/VB.NET environment.

Using find and replace

1.Change “Sub ModelParameters” to “Sub Main”

2. Change “Debug.Print” to “Logger.Info()”. Ensure the contents come inside the brackets.

3. Replace “Set” with blank or nothing. 

 

 

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 4

WCrihfield
Mentor
Mentor

Just curious about how you want to store/record/format this list of parameters, or how you need to use them once you have them.  Do you just need to capture them into a single variable within the code, or do you need the list output to a something like a text file or Excel spreadsheet.  Just the names of the parameters, or their values too?  Just 'model' dimensions, or 'user' parameters and other types too?  Do you need to record which types of parameters they are (model, user, reference, etc.)?  Do you need to record what units each parameter is in?  How detailed do you need this list to be?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 4

tonythm
Advocate
Advocate

Please ref code below:

Sub GetParam()
    Dim oWkbk As Workbook
    Set oWkbk = ThisWorkbook
    Dim oSheet As Worksheet
    Set oSheet = oWkbk.ActiveSheet
    Dim oCell As Range
    oLastRow = oSheet.Cells(oSheet.Rows.Count, 1).End(XlDirection.xlUp).Row
    Dim oInv As inventor.Application
    Set oInv = GetObject(, "Inventor.Application")
    Dim oDoc As Document
    Set oDoc = oInv.ActiveDocument
    Dim partDoc As PartDocument
    Set partDoc = oInv.ActiveDocument
    Dim userParams As UserParameters
    Dim oUserParam As UserParameter
    Set userParams = partDoc.ComponentDefinition.Parameters.UserParameters
    A = 3
    For Each oUserParam In userParams
        Range("A" & A) = oUserParam.name
        A = A + 1
    Next
    For Each oCell In Range("A3:A" & oLastRow)
        'On Error Resume Next
        'If Err.Number <> 0 Then
        'On Error Resume Next
        'End If
        'Dim oUserParam As UserParameter
        For Each oUserParam In userParams
            If oUserParam.name = oCell.Value Then
                oCell.Offset(, 1) = (oUserParam.Value) * 10
                oCell.Offset(, 2) = oUserParam.Units
                oCell.Offset(, 3) = oUserParam.Comment
            End If
        Next
            'Dim oLen As Variant
            'oLen = Len(oUserParam.Name)
            'If oLen <> 5 Then
                'oUserParam.Delete
            'End If
        'Next
    Next oCell
    MsgBox "Done!"
End Sub
0 Likes