Code to re-select edge?

Code to re-select edge?

MattH_Work
Collaborator Collaborator
489 Views
3 Replies
Message 1 of 4

Code to re-select edge?

MattH_Work
Collaborator
Collaborator

I can use

 

oEdge = oApp.CommandManager.Pick(Inventor.SelectionFilterEnum.kPartEdgeCircularFilter, "Select an edge.") to grab an edge.

 

From 'oEdge' I can get the occurence of the owning part ( Occurrence = oEdge.Parent.Parent )

I can get the unique identifier from 'oEdge' using oEdge.TransientKey (?) which will then allow me to iterate another occurence of the same part and find the equivalent edge

 

How do I then select the 'new' edge programmatically but with the same outcome/properties as oApp.CommandManager.Pick (ie I need to get the occurence name from the newly selected edge via  Occurrence = oNewEdge.Parent.Parent)

 

Cheers

 

MattH


MattH
Product Design Collection 2026
Vault Pro 2026
0 Likes
490 Views
3 Replies
Replies (3)
Message 2 of 4

NSBowser
Advocate
Advocate

Can you loop through all of the edges in the second part comparing if oEdgeNew.TransientKey equals oEdge.TransientKey?


Best of Luck

---------------------------------------------------------------------------------------------------------------------------------
If you find this reply helpful or insightful, please use the 'Accept as Solution' or 'Kudos' button below.
0 Likes
Message 3 of 4

MattH_Work
Collaborator
Collaborator

As it happens, that is exactly what I am already doing.

 

Using the oApp.CommandManager.Pick method I can get the occurence owner of the edge by Occurrence = oEdge.Parent.Parent because there is a value to the effect of oEdge.Parent.Parent.occurence = "Part1:1"

 

When I iterate the second occurence's edges, find the matching TransientKey, then drill down there is no oEdge2.Parent.Parent.occurence entry, therefore the code I subsiquently use, which relies on both the oEdge2 reference and its resulting oEdge2.Parent.Parent.occurence = "Part1:2" does not work because I am failing to get the oEdge2.Parent.Parent.occurence = "Part1:2" element.

 

cheers

 

Matt


MattH
Product Design Collection 2026
Vault Pro 2026
0 Likes
Message 4 of 4

dg2405
Advocate
Advocate

I do not know how your workflow is, i normally search for identic edges like this:

 

Sub Select_Same_Edges()
Dim oApp As Inventor.Application
Set oApp = ThisApplication
Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = oApp.ActiveDocument
Dim oAsmCompDef As AssemblyComponentDefinition
Set oAsmCompDef = oAsmDoc.ComponentDefinition
Dim oSelectedEdge As EdgeProxy
Set oSelectedEdge = ThisApplication.CommandManager.Pick(kPartEdgeCircularFilter, "Celect circular edge")
'Occurrence ermitteln
Dim oSelectedOcc As Inventor.ComponentOccurrence
Set oSelectedOcc = oSelectedEdge.Parent.Parent

'Loop through all occs of the assembly, if want all oOccs (inc. child-occs) you have to write a recursive function
Dim oOcc As ComponentOccurrence
For Each oOcc In oAsmCompDef.Occurrences
    Dim oEdge As Edge
    If TypeOf oOcc.Definition.Document Is PartDocument Then
        For Each oEdge In oOcc.Definition.SurfaceBodies.Item(1).Edges
            If oEdge Is oSelectedEdge.NativeObject Then
                 Dim oEdgeProxy As EdgeProxy
                 Call oOcc.CreateGeometryProxy(oEdge, oEdgeProxy)
                 Call oAsmDoc.SelectSet.Select(oEdgeProxy)
            End If
        Next
    End If
Next
End Sub
0 Likes