Delete all constraints from the assembly and subassemblies at once
Delete all constraints from the assembly and subassemblies at once
(OP)
Hi to all.
There is anyway of deleting all contraints from a big assembly?
I have a big assembly, with a lot of sumassemblies. Each one has restrictions.
I would like to clean/delete all restrictions at once.
If I access to Constraints navigator I can´t delete subassemblies restrictions.
The only way I am able is expanding each subassembly in Assembly Navigator and deleting the restrictions.
Any help??
There is anyway of deleting all contraints from a big assembly?
I have a big assembly, with a lot of sumassemblies. Each one has restrictions.
I would like to clean/delete all restrictions at once.
If I access to Constraints navigator I can´t delete subassemblies restrictions.
The only way I am able is expanding each subassembly in Assembly Navigator and deleting the restrictions.
Any help??
Airin
NX Designer





RE: Delete all constraints from the assembly and subassemblies at once
Unfortunatly no without any VB journal
Regards
Didier Psaltopoulos
http://www.psi-cad.fr
RE: Delete all constraints from the assembly and subassemblies at once
Thank you!
Airin
NX Designer
RE: Delete all constraints from the assembly and subassemblies at once
RE: Delete all constraints from the assembly and subassemblies at once
That could do the job but It seems to be time consuming
Regards
Didier Psaltopoulos
http://www.psi-cad.fr
RE: Delete all constraints from the assembly and subassemblies at once
re constraint ? Work without constraints ?
I'm only curious.
RE: Delete all constraints from the assembly and subassemblies at once
Airin
NX Designer
RE: Delete all constraints from the assembly and subassemblies at once
Could you share it ?
Regards
Didier Psaltopoulos
http://www.psi-cad.fr
RE: Delete all constraints from the assembly and subassemblies at once
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