Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Search for suppressed constraint in assembly

7 REPLIES 7
Reply
Message 1 of 8
GeorgK
453 Views, 7 Replies

Search for suppressed constraint in assembly

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

7 REPLIES 7
Message 2 of 8
philippe.leefsma
in reply to: GeorgK

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

Message 3 of 8
GeorgK
in reply to: GeorgK

Hi Philippe,

 

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

 

Thanks Georg

 

 

Message 4 of 8
philippe.leefsma
in reply to: GeorgK

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

Message 5 of 8
GeorgK
in reply to: philippe.leefsma

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

 

Message 6 of 8
GeorgK
in reply to: GeorgK

It works for Inventor 2014 but not for 2010.

Message 7 of 8
philippe.leefsma
in reply to: GeorgK

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

Message 8 of 8
GeorgK
in reply to: GeorgK

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report