Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Get Part Parameter name from assembly

karl.leduc-berard
Contributor

Get Part Parameter name from assembly

karl.leduc-berard
Contributor
Contributor

Hi,

 

im trying to create a Function to find a part in my assembly and then find in it a parameter which can be a model or a user parameter.

But the farthest i could go is to look into assembly parameters....

Any Idea?

Here is my code so far.

 

----------------------------------

Function fuFindPartParam(ByVal sVar1 as string, ByVal sVar2 as string, ByVal sVar3 as string) as string
 

Dim oDoc As AssemblyDocument
oDoc = ThisDoc.Document
Dim oComps As ComponentOccurrences
oComps = oDoc.ComponentDefinition.Occurrences


For Each oComp In oComps
    If oComp.Name = sVar3 Then
        For Each oParameter In oComp.Definition.Parameters.ModelParameters
             If oParameter.Name.Contains(sVar1) And oParameter.Name.Contains(sVar2) Then
                   Return oParameter.Name
             End If
        Next
    End If
Next

For Each oComp In oComps
    If oComp.Name = sVar3 Then
        For Each oParameter In oComp.Definition.Parameters.UserParameters
             If oParameter.Name.Contains(sVar1) And oParameter.Name.Contains(sVar2) Then
                   Return oParameter.Name
             End If
        Next
    End If
Next

End Function

0 Likes
Reply
Accepted solutions (1)
418 Views
2 Replies
Replies (2)

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@karl.leduc-berard,

 

Hope this below code may be helpful.

Function fuFindPartParam(ByVal sVar1 As String, ByVal sVar2 As String, ByVal sVar3 As String) As String
 

Dim oDoc As AssemblyDocument
oDoc = ThisDoc.Document
Dim oComps As ComponentOccurrences
oComps = oDoc.ComponentDefinition.Occurrences


For Each oComp In oComps
    If oComp.Name = sVar3 Then
        For Each oParameter In oComp.Definition.Parameters 
             If oParameter.Name.Contains(sVar1) Or oParameter.Name.Contains(sVar2) Then
                   Return oParameter.Name
             End If
        Next
    End If
Next

 

End Function

Thanks and regards


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



karl.leduc-berard
Contributor
Contributor

thanks!

0 Likes