combine journal

You cannot combine these directly because "journal 2" is actually a "macro"; a journal and a macro are two different things in NX. It appears that the macro regenerates the work view. This can be accomplished in a journal with the following line of code:

workPart.ModelingViews.WorkView.Regenerate()

Simply add that line into "journal 1" as needed.

I will

Do you mean that you do not see the new colors applied until you regenerate the view in NX?

Yes, I am not getting it.

That's odd. It has been my experience that the view updates when the display modification's .Apply method is called. Perhaps it is a difference in our setups (maybe a graphics card/driver issue).

Yes,maybe

Just add the "regenerate" line after the display modification, as below:

Option Strict Off

Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI

Module Module26
Sub Main()

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

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

Dim theSolids As New List(Of Body)
If SelectSolids("Select one or more solid bodies", theSolids) = Selection.Response.Cancel Then
Return
End If

Dim displayModification1 As DisplayModification
displayModification1 = theSession.DisplayManager.NewDisplayModification()
displayModification1.ApplyToAllFaces = True
displayModification1.ApplyToOwningParts = False

'$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
'$ change color and layer to desired values before running journal
displayModification1.NewColor = 1
displayModification1.NewLayer = 2
'$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

displayModification1.Apply(theSolids.ToArray)
displayModification1.Dispose()

displayPart.ModelingViews.WorkView.Regenerate()

End Sub

Function SelectSolids(ByVal prompt As String, ByRef tempBodies As List(Of Body)) As Selection.Response

Dim theUI As UI = UI.GetUI
Dim title As String = "Select one or more solid bodies"
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.WorkPart
Dim selectionMask_array(0) As Selection.MaskTriple
Dim selObj() 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, _
selObj)
If resp = Selection.Response.Ok Then
For Each temp As Body In selObj
tempBodies.Add(temp)
Next
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If

End Function

End Module

Thanks

will

I don't quite follow. Are you saying that it works in one assembly but not in the main assembly?

Are you picking bodies in a piece part or bodies in an assembly? If you are picking bodies in an assembly, the color should change, but only for that assembly. The layer may or may not change depending on the component layer settings.

selecting

What is line #49 in your journal? And what error message is it reporting?

In the journal above, line 49 is:

Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific

This is simply assigning a value to a variable. I can't imagine why this line would be causing a problem.

combine

Didn't we already do this in the post above?
http://nxjournaling.com/comment/2374#comment-2374

If you are having issues with the resulting code, please repost the exact code that you ran along with the reported error message and line number where the error occurs.

ok i will post the error from the journal....

error

Please download the code from the comment above and try it again
http://nxjournaling.com/comment/2374#comment-2374

I made a small edit; it was trying to regenerate the work part, now it will regenerate the display part. This change should eliminate the error you are experiencing.