Cancel
Showing results for 
Search instead for 
Did you mean: 

Removing Objects From Reference Set

Pioneer
Pioneer

We're expiereincing some difficulties when it comes to removing objects from reference sets. We've checked that it returns the proper reference set from the part, but then it error out when we attempt to remove it. Has anyone had success using this function?

 

    Sub FixVisibility(ByVal obj As Body, ByVal refsetName As String)
        'hide body by removing it from the reference set
        Dim refset As ReferenceSet = wrkPrt.GetReferenceSet(refsetName)
            refset.RemoveObjectsFromReferenceSet({CType(obj, NXObject)})
Type : NXException
Error Code : 580014
Work Part : 126_MO
Display Part : LWR_ASM
Message : An operation was attempted on an invalid or unsuitable OM object
   at NXOpen.ReferenceSet.RemoveObjectsFromReferenceSet(NXObject[] components)
   at NxOpenTools.Main.FixVisibility(Body obj, String refsetName) 
DHuskic Nx 9
5 REPLIES

Re: Removing Objects From Reference Set

Honored Contributor
Honored Contributor

What part does "wrkPrt" refer to when you run the code and are the objects that you are attempting to remove owned by the same part? In other words, double check that "wrkPrt" refers to the intended part and the objects are owned by this same part.

Re: Removing Objects From Reference Set

Pioneer
Pioneer

We've veryfied that the work part is the proper component. Right before we make the call, we go through the workpart's reference set and find the body that way. We also debugged it in visual studio and made certain that the body was within the work part.

DHuskic Nx 9

Re: Removing Objects From Reference Set

Esteemed Contributor
Esteemed Contributor

Is the object you remove from the reference set also contained in the reference set?

May be you need some kind of type conversion before you remove the object.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX12.0

How to Get the Most from Your Signature in the Community

Re: Removing Objects From Reference Set

Pioneer
Pioneer

The method we have to sort through a component's bodies by reference sets returns occurance objects. Once I used obj.prototype in the example above it worked. This call should be done at the part file level (proper terminology?). Thanks for the help, happy holidays.

DHuskic Nx 9

Re: Removing Objects From Reference Set

Genius
Genius

You can only remove objects that you are sure that they are in the refset (kind of logical...)

so best approach would be to ask the members of the refset.

 

refMembers = myRefSet.AskAllDirectMembers()
For Each myObject As DisplayableObject In refMembers

if.....
 myRefSet.RemoveObjectsFromReferenceSet(myObject)
end if
next

If i remember correctly i had some issues in journals with refsets when looping though an assembly without changing workpart (NX9).