Sorry for the delay.
This is the journal:
Option Strict Off
Imports System
Imports System.IO
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.UI
Imports NXOpen.Utilities
Imports NXOpen.Assemblies
Imports NXOpen.Positioning
Module delete_all_assembly_constraints
Public s As Session = Session.GetSession()
Public ufs As UFSession = UFSession.GetUFSession()
Public lw As ListingWindow = s.ListingWindow
Public dp As Part = s.Parts.Display
Public msg As NXMessageBox = UI.GetUI().NXMessageBox
Public Lsub_assembly As Collection = New Collection
Sub Main()
If (dp Is Nothing) Then
msg.Show("", NXOpen.NXMessageBox.DialogType.Error, "No Display Part !!!")
Return
End If
Try ' return a collection of all the sub_assembly in the displayed part
Lsub_assembly.Add(dp, dp.ToString)
Scan_Assembly(dp.ComponentAssembly.RootComponent, Lsub_assembly)
Catch e As Exception
End Try
Dim nom As String
Dim comp, parent As Component
For Each part As Part In Lsub_assembly
nom = Descriptive_Part_Name(part)
Echo("Part = " & nom)
Try
Dim save_arrangement = part.ComponentAssembly.ActiveArrangement
Dim marque As Session.UndoMarkId = s.SetUndoMark(Session.MarkVisibility.Visible, "Delete Constraints")
For Each a As Arrangement In part.ComponentAssembly.Arrangements
part.ComponentAssembly.ActiveArrangement = a
Echo(vbTab & "Arrangement = " & a.Name)
For Each c As ComponentConstraint In part.ComponentAssembly.Positioner.Constraints
s.UpdateManager.AddToDeleteList(c)
Echo(vbTab & vbTab & "Constraint deleted = " & c.Name)
Next
s.UpdateManager.DoAssemblyConstraintsUpdate(marque)
Next
part.ComponentAssembly.ActiveArrangement = save_arrangement
Catch ex As Exception
End Try
Next
ufs.Modl.Update()
End Sub
Private Sub Scan_Assembly(ByVal c As Component, ByRef Lsub_assembly As Collection)
Dim enfants As Component() = c.GetChildren()
Dim maquette As Part = CType(c.Prototype, Part)
If enfants.Length <> 0 And Not Lsub_assembly.Contains(maquette.ToString) Then
Lsub_assembly.Add(maquette, maquette.ToString)
End If
For Each comp As Component In enfants
Scan_Assembly(comp, Lsub_assembly)
Next
End Sub
Private Function Descriptive_Part_Name(ByVal part As Part) As String
Dim chaine() = part.FullPath.Split("\")
Descriptive_Part_Name = chaine(chaine.Length - 1)
End Function
Public Sub Echo(ByVal output As String)
lw.Open()
lw.WriteLine(output)
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
End Function
End Module
Airin
NX Designer