Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Adapt Journal to only select specific colors?

Status
Not open for further replies.

Kenja824

Automotive
Nov 5, 2014
949
This code takes the curves one selects and changes them to specific settings.... (Coler, Type, Etc..)

How hard is it to change this so the selection only allows one to select specific colored curves? The only colors I want to be able to select are 31 and 7.



Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI

Module NXJournal
    Sub Main()

        Dim theSession As Session = Session.GetSession()
        Dim workPart As Part = theSession.Parts.Work
        Dim displayPart As Part = Nothing
        Dim ufs As UFSession = UFSession.GetUFSession()
        Dim mySelectedObjects As NXObject()

        Try
            displayPart = theSession.Parts.Display
        Catch Ex As NXException
            ufs.UI().DisplayMessage("Please set drafting mode before running the journal", 1)
            Exit Sub
        End Try

        If IsNothing(displayPart) = True Then
            ufs.UI().DisplayMessage("Please set drafting mode before running the journal", 1)
            Exit Sub
        End If

        Dim markId4 As Session.UndoMarkId
        markId4 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Edit Object Display")

        If SelectObjects("Select Curves to Change",
        mySelectedObjects) = Selection.Response.Ok Then

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

            displayModification1.ApplyToAllFaces = False

            displayModification1.ApplyToOwningParts = False

            'displayModification1.NewLayer = 242

            displayModification1.NewColor = 152

            displayModification1.NewWidth = DisplayableObject.ObjectWidth.Two

            displayModification1.NewFont = DisplayableObject.ObjectFont.Solid

            Dim count As Integer
            count = mySelectedObjects.Length - 1
            Dim objects1(count) As DisplayableObject

            Dim i As Integer
            i = 0
            For Each mySelObj As NXObject In mySelectedObjects
                Dim body1 As Curve = mySelObj
                objects1(i) = body1
                i = i + 1

            Next

            displayModification1.Apply(objects1)
            displayModification1.Dispose()

        End If

    End Sub

    Function SelectObjects(prompt As String, ByRef selObj As NXObject()) As Selection.Response

        Dim theUI As UI = UI.GetUI

        Dim typeArray() As Selection.SelectionType =
        {Selection.SelectionType.Curves, Selection.SelectionType.Curves}
        ' {Selection.SelectionType.All, Selection.SelectionType.Curves}

        Dim resp As Selection.Response = theUI.SelectionManager.SelectObjects(
        prompt, "Selection",
        Selection.SelectionScope.AnyInAssembly,
        False, typeArray, selObj)

        If resp = Selection.Response.ObjectSelected Or
        resp = Selection.Response.ObjectSelectedByName Or
        resp = Selection.Response.OK Then
            Return Selection.Response.Ok
        Else
            Return Selection.Response.Cancel
        End If
    End Function

End Module

Ken
My brain is like a sponge. A sopping wet sponge. When I use it, I seem to lose more than I soak in.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor