Submitted by dnenadov on Sat, 04/11/2020 - 06:49
Forums:
Hello, I was wondering if someone has a journal file that is similar to this:
I have a reference set called "True"
I want to be able to remove all sketches and curves from this reference set.
Thanks in advance for any reply.
re: reference set
The following code might be a good start:
Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Module Module2
Sub Main()
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()
Dim theReferenceSet As ReferenceSet = Nothing
Dim refMembers(-1) As NXObject
Dim refSetObjsToRemove As New List(Of NXObject)
'%%%%%%%%%% Change the following line to point to the name of your reference set %%%%%%%%%%
Const whatRefSet As String = "TRUE"
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
For Each myRefSet As ReferenceSet In workPart.GetAllReferenceSets()
If myRefSet.Name.ToUpper() = whatRefSet.ToUpper Then
theReferenceSet = myRefSet
refMembers = myRefSet.AskAllDirectMembers()
For Each myObject As NXObject In refMembers
lw.WriteLine(myObject.GetType.ToString)
'add sketches and curves to the 'remove' list
If TypeOf myObject Is Sketch Then
refSetObjsToRemove.Add(myObject)
End If
If TypeOf (myObject) Is SketchConstraint Then
refSetObjsToRemove.Add(myObject)
End If
If TypeOf (myObject) Is Curve Then
refSetObjsToRemove.Add(myObject)
End If
Next
End If
Next
If Not IsNothing(theReferenceSet) Then
theReferenceSet.RemoveObjectsFromReferenceSet(refSetObjsToRemove.ToArray)
End If
lw.Close()
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
'Unloads the image when the NX session terminates
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
End Function
End Module
Thank you!
Thank you!