Inventor 2023: Access a member create with the frame generator

Inventor 2023: Access a member create with the frame generator

Sébastien_G
Advocate Advocate
378 Views
4 Replies
Message 1 of 5

Inventor 2023: Access a member create with the frame generator

Sébastien_G
Advocate
Advocate

Dear All,

Here is the context in which I work.

I am in a General Assembly that is composed of part, welded construction and frame generated by the Frame Generator.

The question is how to reach the angle (in my case) with an iLogic code.

Sbastien_G_0-1695307737130.png

The code should look something like this

Dim oDoc As AssemblyDocument = ThisDoc.Document
Dim oCompDef As Componentdefinition = ...

I have to go to the angle with the API objects.

 

I am listening to your proposals

@Sébastien_G 

0 Likes
379 Views
4 Replies
Replies (4)
Message 2 of 5

JelteDeJong
Mentor
Mentor

You did not specify if you wanted to get that occurrence or the document of that occurrence. If you want to get the document and you have a unique "Part number" then this could get you the document.

Dim doc As AssemblyDocument = ThisDoc.Document
Dim refDoc = doc.AllReferencedDocuments.Cast(Of Document).
    FirstOrDefault(Function(d) d.PropertySets("Design Tracking Properties")("Part Number").Value.Equals("<Your part number here>"))

If (refDoc Is Nothing) Then
    MsgBox("document was not found")
Else
    MsgBox("You found the document: " & refDoc.FullDocumentName)
End If

 

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 5

JelteDeJong
Mentor
Mentor

or if you want to find the occurrence then you could try this.

 

Sub Main()
    Dim doc As AssemblyDocument = ThisDoc.Document

    Dim occ = GetOccurence(doc.ComponentDefinition.Occurrences, "<Occurence name here>")

    If (occ Is Nothing) Then
        MsgBox("Occurence was not found")
    Else
        MsgBox("You found the Occurence: " & occ.Name)
    End If
End Sub
Public Function GetOccurence(Occurrences As ComponentOccurrences, name As String) As ComponentOccurrence

    For Each occ As ComponentOccurrence In Occurrences
        If (occ.Name.Equals(name)) Then
            Return occ
        End If

        If (occ.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject) Then
            Dim foundOcc = GetOccurence(occ.Definition.Occurrences, name)
            If (foundOcc IsNot Nothing) Then
                Return foundOcc
            End If
        End If
    Next
    Return Nothing

End Function

 

This is the complicated way but will find all occurrences including sub-assemblies.

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 4 of 5

JelteDeJong
Mentor
Mentor

Or if you don't care if you can't find subassemblies occurrences then you could try this:

Dim doc As AssemblyDocument = ThisDoc.Document

Dim occ = doc.ComponentDefinition.Occurrences.
    AllLeafOccurrences.Cast(Of ComponentOccurrence).
    FirstOrDefault(Function(o) o.Name.Equals("<Occurence name here>"))

If (occ Is Nothing) Then
    MsgBox("Occurence was not found")
Else
    MsgBox("You found the Occurence: " & occ.Name)
End If

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 5 of 5

Sébastien_G
Advocate
Advocate

Hello Jelte,
In fact, I’m trying to reach the Material iProperty of the Angle.
I’m trying to perform the same function I asked you for help on a few days ago.

0 Likes