Search for suppressed constraint in assembly

Search for suppressed constraint in assembly

GeorgK
Advisor Advisor
663 Views
7 Replies
Message 1 of 8

Search for suppressed constraint in assembly

GeorgK
Advisor
Advisor

Hello Together,

 

how could I center the suppressed constraint? I woul like to selecet it in the listbox.

 

Private Sub CommandButton1_Click()

Dim oAssDoc As AssemblyDocument
Set oAssDoc = ThisApplication.ActiveDocument

Dim oConstraint As AssemblyConstraint

For Each oConstraint In oAssDoc.ComponentDefinition.Constraints

If oConstraint.HealthStatus = kSuppressedHealth Then

Call ListBox1.AddItem(oConstraint.Name)

End If

Next oConstraint

End Sub

 

Thank you Georg

0 Likes
664 Views
7 Replies
Replies (7)
Message 2 of 8

philippe.leefsma
Alumni
Alumni

Hi Georg,

 

What do you mean by "center the suppressed constraints"?  Do you just mean list them?

 

You can use the AssemblyConstraint.Suppressed property:

 

Sub ListConstraints()

    Dim asm As AssemblyDocument
    Set asm = ThisApplication.ActiveDocument
    
    Dim constraint As AssemblyConstraint
    For Each constraint In asm.ComponentDefinition.Constraints
        
        Debug.Print constraint.name & " Suppressed: " & constraint.Suppressed
   
    Next

End Sub

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 8

GeorgK
Advisor
Advisor

Hi Philippe,

 

I woul like to center the browser to the selected constraint and highlight it.

 

Thanks Georg

 

 

0 Likes
Message 4 of 8

philippe.leefsma
Alumni
Alumni

You need to find the corresponding BrowserNode in the hierarchy and set BrowserNode.Selected = True and also expand its parent.

 

Here is an example that will highlight and expand the constraint browser node. In your case it might be a bit more complex as it seems you want to highlight the constraint under a part occurrence node.

 

Sub ListConstraints()

    Dim asm As AssemblyDocument
    Set asm = ThisApplication.ActiveDocument
    
    Dim bp As BrowserPane
    Set bp = asm.BrowserPanes.Item("AmBrowserArrangement")
    
    Dim constraint As AssemblyConstraint
    For Each constraint In asm.ComponentDefinition.Constraints
        
        If (constraint.Name = "Mate:1") Then
        
            asm.SelectSet.Select constraint
        
            Dim bn As BrowserNode
            Set bn = bp.GetBrowserNodeFromObject(constraint)
        
            Dim parent As BrowserNode
            Set parent = bn.parent
            
            parent.Expanded = True
        End If
    Next

End Sub

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 5 of 8

GeorgK
Advisor
Advisor

I get a Run-time-error: Method "Expanded" of object "BrowserNode" failed at line "parent.Expanded = True"

 

0 Likes
Message 6 of 8

GeorgK
Advisor
Advisor

It works for Inventor 2014 but not for 2010.

0 Likes
Message 7 of 8

philippe.leefsma
Alumni
Alumni

2010 is an unsupported version so I can't help you on that. It might be that an issue has been fixed in between...



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 8 of 8

GeorgK
Advisor
Advisor

This works for 2010:     

 

  Dim oDoc As Document
        oDoc = m_invApp.ActiveDocument

        Dim oView As View
        oView = oDoc.Views.Item(1)

        Call oView.Fit()

        Dim oTopNode As BrowserNode
        Dim oNode As BrowserNode

        oTopNode = m_invApp.ActiveDocument.BrowserPanes.ActivePane.TopNode

        For Each oNode In oTopNode.BrowserNodes
            If oNode.Visible = True Then
                oNode.Expanded = True
            End If
        Next

0 Likes