×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

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

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

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

(OP)
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,

RE: CHANGE COLOR VIA VB SCRIPT!!!!!!!!!! HELP!!!!

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

RE: CHANGE COLOR VIA VB SCRIPT!!!!!!!!!! HELP!!!!

(OP)
Yes that is correct. And thanks for the command info.

RE: CHANGE COLOR VIA VB SCRIPT!!!!!!!!!! HELP!!!!

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

RE: CHANGE COLOR VIA VB SCRIPT!!!!!!!!!! HELP!!!!

(OP)
THANK YOU!!!!! This is Awesome!

RE: CHANGE COLOR VIA VB SCRIPT!!!!!!!!!! HELP!!!!

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources