Showing results for 
Search instead for 
Do you mean 
Reply

Set component as reference only

Hi,

I've this journal, but doesn't work.

Can someone adjust this Journal ?

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.Assemblies
Imports NXOpen.UI
Imports NXOpen.UF

Module NXJournal
    Sub Main

    Dim theSession As Session = Session.GetSession()
    Dim workPart As Part = theSession.Parts.Work
    Dim displayPart As Part = theSession.Parts.Display
    Dim lw As ListingWindow = theSession.ListingWindow
    Dim component1 As Component = nothing

    If SelectAComponent(component1) = Selection.Response.Ok Then
        If (component1.GetStringAttribute("REFERENCE_COMPONENT")).Length Then
            component1.DeleteAttributeByTypeAndTitle(NXObject.AttributeType.String,"REFERENCE_COMPONENT")
            lw.Open
            lw.WriteLine(component1.ToString & " is no reference anymore.")
        Else
            component1.SetAttribute("REFERENCE_COMPONENT", "1")
            lw.Open
            lw.WriteLine(component1.ToString & " is now reference.")
        End If
    Else 
        lw.Open
        lw.WriteLine("Nothing selected.")
    End If

    End Sub

    Function SelectAComponent(ByRef obj As Component) As Selection.Response

        Dim ui As UI = GetUI()
        Dim mask(0) As Selection.MaskTriple
            With mask(0)
                .Type = UFConstants.UF_component_type
                .Subtype = 0
                .SolidBodySubtype = 0
            End With
        Dim cursor As Point3d = Nothing
        Dim resp As Integer

        resp = ui.SelectionManager.SelectObject("Select a component", "Select a component", _
            Selection.SelectionScope.WorkPart, _
            Selection.SelectionAction.ClearAndEnableSpecific, _
            False, False, mask, obj, cursor)

    If resp = Selection.Response.ObjectSelected Or _
         resp = Selection.Response.ObjectSelectedByName Then
        return Selection.Response.Ok
    Else
        return Selection.Response.Cancel
    End If

    End Function


End Module

 

Thank you...

Using NX 11 / RuleDesigner PDM

5 REPLIES

Re: Set component as reference only

 

What version are you trying to run this in?  Some of these calls were deprecated in NX8.

 

Thanks.

Re: Set component as reference only

I'm using NX 8 and the journa must run in NX 8, but I hope that if will be correct, I can use in NX 9 or NX 10.

Thank you...

Using NX 11 / RuleDesigner PDM

Re: Set component as reference only

When something is marked as deprecated it means it will be removed in a future release of NX. So these calls might not be available in NX9/NX10.

Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | C# | KF
Production: NX8.5.3.3 MP11 64bit Testing: NX9.0.2.5

Re: Set component as reference only

I tested it on NX 9 and it is working fine. Yes it gives error if you donot have attribute called "REFERENCE_COMPONENT".

Re: Set component as reference only


pv3wqm wrote:

I tested it on NX 9 and it is working fine. Yes it gives error if you donot have attribute called "REFERENCE_COMPONENT".


I want to set the attribute at assembly level not at component level.

Thank you...

Using NX 11 / RuleDesigner PDM