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
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.
Hi Philippe,
I woul like to center the browser to the selected constraint and highlight it.
Thanks Georg
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.
I get a Run-time-error: Method "Expanded" of object "BrowserNode" failed at line "parent.Expanded = True"
2010 is an unsupported version so I can't help you on that. It might be that an issue has been fixed in between...
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