Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete all constraints from the assembly and subassemblies at once 1

Status
Not open for further replies.

fsh27

Industrial
Apr 18, 2016
57
0
0
ES
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??

Airin
NX Designer
 
Replies continue below

Recommended for you

You Could use arrangements that ignore all constraints combined with making the component positions arrangement specific. Another useful feature is Override Component position which makes it possible to define new constraints at a higher assembly level.
 
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
 
Status
Not open for further replies.
Back
Top