Get face from selected edge

Get face from selected edge

NachoShaw
Advisor Advisor
455 Views
5 Replies
Message 1 of 6

Get face from selected edge

NachoShaw
Advisor
Advisor
Hi

Is there a way to select the 2 faces comnected to a selected edge in a drawing?

Cheers

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


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.


0 Likes
456 Views
5 Replies
Replies (5)
Message 2 of 6

bshbsh
Collaborator
Collaborator

If I understand correctly, you want something like this?

Public Sub SelectFaces()
    If ThisApplication.ActiveDocument Is Nothing Then
        Exit Sub
    Else
        Dim InvDoc As Document
        Set InvDoc = ThisApplication.ActiveDocument
    End If
    If InvDoc.DocumentType <> kDrawingDocumentObject Then
        MsgBox ("Open a drawing document first!")
        Exit Sub
    End If
    If InvDoc.SelectSet.Count = 0 Then
        MsgBox ("Select an edge first")
        Exit Sub
    End If
    If InvDoc.SelectSet.Item(1).Type = kDrawingCurveSegmentObject Then
        Dim oEdge As Variant
        Set oEdge = InvDoc.SelectSet.Item(1)
        Dim oModel As Document
        Set oModel = ThisApplication.Documents.Open(oEdge.Parent.Parent.ReferencedDocumentDescriptor.FullDocumentName)
        oModel.Activate
        oModel.SelectSet.Clear
        oModel.SelectSet.Select (oEdge.Parent.ModelGeometry.Faces.Item(1))
        oModel.SelectSet.Select (oEdge.Parent.ModelGeometry.Faces.Item(2))
    Else
        MsgBox ("Selected item is not an edge!")
    End If
End Sub

This needs more error filtering though. It will fail on certain selected "edges" that do not have associated faces, such as thread lines, tangential lines, etc.

0 Likes
Message 3 of 6

NachoShaw
Advisor
Advisor

Hi

 

Thanks for the reply. I actually had put the incorrect information in my post. I dont need to do it in a drawing, i need to do it in an assembly.

 

I need to select an edge in an assembly and select both faces directly attached to the edge

 

sorry for the misunderstanding 🙂

 

 

Nacho

 

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


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.


0 Likes
Message 4 of 6

NachoShaw
Advisor
Advisor

Hi

 

im actually tyinking that i may need to go a bit deeper. the faces i need to have selected from the edge will be on a part in the assembly but i dont want to open the part independently so i guess it will using the part definition or proxy?

 

Cheers

 

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


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.


0 Likes
Message 5 of 6

bshbsh
Collaborator
Collaborator
Public Sub SelectFaces()
    If ThisApplication.ActiveDocument Is Nothing Then
        Exit Sub
    Else
        Dim InvDoc As Document
        Set InvDoc = ThisApplication.ActiveDocument
    End If
    If InvDoc.DocumentType <> kAssemblyDocumentObject Then
        MsgBox ("Open an assembly document first!")
        Exit Sub
    End If
    If InvDoc.SelectSet.Count = 0 Then
        MsgBox ("Select an edge first")
        Exit Sub
    End If
    If InvDoc.SelectSet.Item(1).Type = kEdgeProxyObject Then
        Dim oEdge As Object
        Set oEdge = InvDoc.SelectSet.Item(1)
        InvDoc.SelectSet.Clear
        InvDoc.SelectSet.Select (oEdge.Faces.Item(1))
        InvDoc.SelectSet.Select (oEdge.Faces.Item(2))
    Else
        MsgBox ("Selected item is not an edge!")
    End If
End Sub
0 Likes
Message 6 of 6

NachoShaw
Advisor
Advisor

Hi

 

Thanks for that. works ok. i added a user selection instead of hsving an edge preselected 🙂

 

to slightly further this, is there a method of selecting the midpoint of the selected edge too? This would be after the faces have been selected

 

 

 

 

cheers

 

nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


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.


0 Likes