Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Display Properties Journal Needed 1

Status
Not open for further replies.

3dr

Automotive
Jul 10, 2004
451
I'm looking for something to get me going in the right direction

I frequently change the properties of selected solids.
Layer, Color, Line type, Translucency

They're used on alternate ref sets to subtract from other bodies.

Anyone have anything for this?

I can make one, but it doesn't let me select the objects I want.
Doing that is water over my head!

TIA

Dave
Automotive Tooling / Aircraft Tooling / Ground Support Structures

NX9, Win 7 Pro SP1
 
Replies continue below

Recommended for you

What type of objects are you trying to select? Will these objects be selected interactively by the user, or automatically by the journal?

www.nxjournaling.com
 
Only solid bodies with user interaction.
They could be picked from model space or a selected browser feature, but that's not important.

Just that multiples can be selected if required. Once you hit OK it should process.

Wouldn't hurt if it were to move it to the correct REF set too. lol
If that were done I would probably prefer it be selected with interaction from the ref set dialogue.

This journal thing is great but I'm clueless on the user interaction stuff.
I never have enough time to sit an really figure it out.



Dave
Automotive Tooling / Aircraft Tooling / Ground Support Structures

NX9, Win 7 Pro SP1
 
This should get you started:

Code:
Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF

Module Module2

    Sub Main()

        Dim theSession As Session = Session.GetSession()
        Dim theUfSession As UFSession = UFSession.GetUFSession
        Dim theUi As UI = UI.GetUI
        If IsNothing(theSession.Parts.Work) Then
            'active part required
            Return
        End If

        Dim workPart As Part = theSession.Parts.Work
        Dim lw As ListingWindow = theSession.ListingWindow
        lw.Open()

        Const undoMarkName As String = "NXJ body display properties"
        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)

        Dim theBodies As New List(Of Body)
        If SelectBodies("select bodies", theBodies) = Selection.Response.Cancel Then
            'user pressed cancel
            lw.WriteLine("cancel")
            Return
        End If

        Dim displayModification1 As DisplayModification = theSession.DisplayManager.NewDisplayModification()

        'specify new layer (1 - 256)
        displayModification1.NewLayer = 1
        'specify new color (CDF palette entry 1 - 216)
        displayModification1.NewColor = 6
        'specify line font
        '  DisplayableObject.ObjectFont.Centerline
        '  DisplayableObject.ObjectFont.Dashed
        '  DisplayableObject.ObjectFont.Dotted
        '  DisplayableObject.ObjectFont.DottedDashed
        '  DisplayableObject.ObjectFont.LongDashed
        '  DisplayableObject.ObjectFont.Phantom
        '  DisplayableObject.ObjectFont.Solid
        displayModification1.NewFont = DisplayableObject.ObjectFont.Dashed
        'specify translucency %
        displayModification1.NewTranslucency = 50

        displayModification1.ApplyToAllFaces = True
        displayModification1.ApplyToOwningParts = False

        displayModification1.Apply(theBodies.ToArray)

        displayModification1.Dispose()

        lw.Close()

    End Sub

    Function SelectBodies(ByVal prompt As String, ByRef selBodies As List(Of Body)) As Selection.Response

        Dim theUI As UI = UI.GetUI
        Dim title As String = "Select a body"
        Dim includeFeatures As Boolean = False
        Dim keepHighlighted As Boolean = False
        Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
        Dim scope As Selection.SelectionScope = Selection.SelectionScope.AnyInAssembly
        Dim selectionMask_array(0) As Selection.MaskTriple
        Dim selObjs() As TaggedObject

        With selectionMask_array(0)
            .Type = UFConstants.UF_solid_type
            .SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_BODY
        End With

        Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObjects(prompt,
         title, scope, selAction,
         includeFeatures, keepHighlighted, selectionMask_array,
         selObjs)
        If resp = Selection.Response.Back OrElse resp = Selection.Response.Cancel Then
            Return Selection.Response.Cancel
        Else
            For Each tempObj As TaggedObject In selObjs
                selBodies.Add(tempObj)
            Next
            Return Selection.Response.Ok
        End If

    End Function

    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

www.nxjournaling.com
 
Wow, that works beautifully.

Thanks Cowski. U da man!

Dave
Automotive Tooling / Aircraft Tooling / Ground Support Structures

NX9, Win 7 Pro SP1
 
Hi Cowski

I'm interesting in this journal but with a reset
to the original setting.

Is it possible to save the settings in somewhere
on the part so later after saving I can read theme back.

Thank you in advanced

 
One way to do this would be to save the current property values in the object's attributes; your code could then read the attributes to restore the previous values or fall back on the current object display defaults.

www.nxjournaling.com
 
Cowski Thank you
I'll take a thought of this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor