Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

CHANGE COLOR VIA VB SCRIPT!!!!!!!!!! HELP!!!!

Status
Not open for further replies.

mnash60

Materials
Feb 21, 2012
29
I'm in need of assistance. I currently have a journal file that selects all faces and changes the color to 103. I now need to modify this journal file to have a select certain faces via user input ex. "Select objects". Is there anyone out there that can assist me with this or have any suggestions.

Also is there a way to create a button to easily access a journal file operation?

Attach is an copy of a stp file and the current vb script I created

Thanks,
 
Replies continue below

Recommended for you

So instead of selecting all faces, you want user interaction to select only certain faces?

For info on creating a custom button to start a journal, have a look here.

www.nxjournaling.com
 
Yes that is correct. And thanks for the command info.
 
Here's one way of selecting the faces:

Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Utilities
Imports NXOpen.Assemblies
Imports System.Windows.Forms
Imports System.IO
Imports System.Collections
Imports System.Collections.Generic
Imports System.Environment
Imports NXOpenUI

Module Module6

    Sub Main()

        Dim S As Session = Session.GetSession()
        Dim workPart As Part = S.Parts.Work
        Dim ufs As UFSession = UFSession.GetUFSession()
        Dim lw As ListingWindow = S.ListingWindow
        Dim layerColorID(256) As Integer
        layerColorID(1) = 6

        Dim myFaces As New List(Of Face)
        If SelectFaces("select faces", myFaces) = Selection.Response.Cancel Then
            Exit Sub
        End If

        Dim displayModification1 As DisplayModification
        displayModification1 = S.DisplayManager.NewDisplayModification()
        'displayModification1.NewColor = layerColorID(1)
        'displayModification1.NewFont = DisplayableObject.ObjectFont.LongDashed
        displayModification1.NewWidth = DisplayableObject.ObjectWidth.Thick
        displayModification1.ApplyToAllFaces = False
        displayModification1.ApplyToOwningParts = False

        displayModification1.NewColor = 103
        displayModification1.Apply(myFaces.ToArray)
        displayModification1.Dispose()

    End Sub

    Function SelectFaces(ByVal prompt As String, _
                 ByRef theFaces As List(Of Face)) As Selection.Response

        Dim theObjs() As NXObject
        Dim theUI As UI = UI.GetUI
        Dim typeArray() As Selection.SelectionType = _
            {Selection.SelectionType.Faces}

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

        If resp = Selection.Response.ObjectSelected Or _
                resp = Selection.Response.ObjectSelectedByName Or _
                resp = Selection.Response.Ok Then
            For Each temp As Face In theObjs
                theFaces.Add(temp)
            Next
            Return Selection.Response.Ok
        Else
            Return Selection.Response.Cancel
        End If

    End Function


End Module

www.nxjournaling.com
 
THANK YOU!!!!! This is Awesome!
 
Hi,
It's possible to have the journal that open the color palette mask to select the right color ?

Thank you...

Using NX 8 and TC9.1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor