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


NX11 - Journal Help Please

NX11 - Journal Help Please

NX11 - Journal Help Please


Im trying to record a journal where it will fit all on the screen, then select all according to these filters....
Type = Solid Body
Attribute Filter - User Definied Attributes....
Attribute Type = String
Low String Value = CROSS/CAR
High String Value = CROSS/CAR

(I am not sure if both LOW and HIGH need to be filled but it worked for me on tests that way. lol)

Once filters are set, I need it to select all bodies. (Recording a journal only lists each particular body being selected) Then it will change the color of the solid bodies to Color 78.

I actually was trying to record one that would do this over again for a total of 6 colors according to the Attribute filter.

It wouldnt record right as a journal as it doesnt record the filters or the SELECT ALL on the solid bodies. So I tried to record a macro instead. This worked good but in testing it, I learned that if the case came up where one of the filters did not find any solid bodies, it would error out and not finish.

Can anyone help with this?

RE: NX11 - Journal Help Please

I found this code and adjusted it to select bodies.... it works great for changing the color to all bodies on a specific layer. Can anyone help me with how to change the filters so it ignores the layer and works with String Attributes?

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpenUI

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 answer as String
dim layerNumber as Integer = 2
dim i as Integer = 0

Dim lw As ListingWindow = theSession.ListingWindow
Dim allObjects as NXObject()
Dim BodyObject as Body

allObjects = workPart.Layers.GetAllObjectsOnLayer(layerNumber)
for each someObject as NXObject in allObjects
' lw.WriteLine(someObject.GetType.ToString)
if someObject.GetType.ToString = "NXOpen.Body" then
BodyObject = someObject
BodyObject.Color = 216
i += 1
end if
lw.WriteLine(i & " Bodies processed on layer: " & layerNumber)

End Sub
End Module

RE: NX11 - Journal Help Please

I mean to use the String Attribute in place of the layer filter.

RE: NX11 - Journal Help Please

Try this:


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

Module Module1

    Dim theSession As Session = Session.GetSession()
    Dim theUfSession As UFSession = UFSession.GetUFSession()

    Dim theUI As UI = UI.GetUI()
    Dim lw As ListingWindow = theSession.ListingWindow

    Sub Main()

        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "body color by attribute")


        Const attTitle As String = "CONTROL DIRECTION"
        Const attValue As String = "CROSS/CAR"
        Const newBodyColor As Integer = 78
        Dim bodies1 As New List(Of Body)

        For Each temp As Body In theSession.Parts.Work.Bodies
            If temp.IsSheetBody Then
                'skip sheet bodies
                Continue For
            End If

            If temp.HasUserAttribute(attTitle, NXObject.AttributeType.String, -1) Then
                If temp.GetStringUserAttribute(attTitle, -1).ToUpper = attValue Then
                End If
            End If

        Dim displayModification1 As DisplayModification
        displayModification1 = theSession.DisplayManager.NewDisplayModification()
        displayModification1.ApplyToAllFaces = True
        displayModification1.NewColor = newBodyColor


    End Sub

    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

    End Function

End Module 


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!


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close