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!

Predefine the color of a face with journal. 4

Status
Not open for further replies.

Jonatasrf

Mechanical
Aug 7, 2017
13
Hello All,

I hope you can help me with some advice for NX1926 Journal.
I need to create a journal or macro to edit the color of a face, but the color that will be the face must already be predefined in the journal, example:

Edit object with the face filter and the blue color (211) already predefined.

I used macro in nx 12 to do this, but in nx 1926 it doesn't work, even recreating the macro.

in my projects I use this resource a lot, and doing it manually I waste a lot of time.

Thanks. :)
 
Replies continue below

Recommended for you

You may want to check how your selection filter is set before you run the macro.

Jerry J.
UGV5-NX1884
 
Code:
NX 1859
Macro File: D:\Acoes_NX\MACRO\11_Cores\Blue_ID211.macro
Macro Version 7.50
Macro List Language and Codeset: english 17
Created by fuckner on Tue Jun 23 17:24:52 2020
Part Name Display Style: $FILENAME
Selection Parameters 1 2 0.229167 1
Display Parameters 0.900000 19.614583 8.708333 -1.000000 -0.443972 1.000000 0.443972
*****************
RESET
MENU, 0, UG_EDIT_OBJECT_DISPLAY UG_GATEWAY_MAIN_MENUBAR <Ctrl J> ## ! 
ASK_ITEM 2293760 (1 BOOL 0) = 1  !  
ASK_ITEM 2293760 (1 BOOL 0) = 0  !  
EVENT FOCUS_IN 0 0, 1835009, 0, 0, 0! Select by Name
ASK_ITEM 1835009 (1 STRN 0) = ""  ! Select by Name
DIALOG_BEGIN "Class Selection" 0 ! DA2
BEG_ITEM 327680 (1 BOOL 0) = 0  ! Select Objects
BEG_ITEM 1835009 (1 STRN 0) = ""  ! Select by Name
BEG_ITEM 2293760 (0 BOOL 0) = 0  !  
BEG_ITEM 3670016 (1 CTOL 0) = 1  !  
BEG_ITEM 4718594 (1 BOOL 0) = 1  ! Preview
ASK_ITEM 327680 (1 BOOL 0) = 0  ! Select Objects
ASK_ITEM 327680 (1 BOOL 0) = 1  ! Select Objects
EVENT FOCUS_IN 0 0, 3145728, 0, 0, 0! Type Filter
ASK_ITEM 1835009 (1 STRN 0) = ""  ! Select by Name
EVENT ACTIVATE 0 0, 3145728, 0, 0, 0! <DLC> Type Filter
DIALOG_BEGIN "Select by Type" 0 ! DA2
 BEG_ITEM  0 (1 MULT 0) = 40  ! List (Items selected)
      POSITION = 0 "2D Component" ! Index/contents of selected item
      POSITION = 1 "Analysis" ! Index/contents of selected item
      POSITION = 2 "Boundary" ! Index/contents of selected item
      POSITION = 3 "Component" ! Index/contents of selected item
      POSITION = 4 "Component Pattern" ! Index/contents of selected item
      POSITION = 5 "CSYS" ! Index/contents of selected item
      POSITION = 6 "Curve" ! Index/contents of selected item
      POSITION = 7 "Cutting Plane Symbol" ! Index/contents of selected item
      POSITION = 8 "Datum Plane Grid" ! Index/contents of selected item
      POSITION = 9 "Datums" ! Index/contents of selected item
      POSITION = 10 "Dimension" ! Index/contents of selected item
      POSITION = 11 "Drawing Image" ! Index/contents of selected item
      POSITION = 12 "Drawing Template Region" ! Index/contents of selected item
      POSITION = 14 "Facet Body" ! Index/contents of selected item
      POSITION = 15 "Frame Bar" ! Index/contents of selected item
      POSITION = 16 "Group" ! Index/contents of selected item
      POSITION = 17 "Image" ! Index/contents of selected item
      POSITION = 18 "Label" ! Index/contents of selected item
      POSITION = 19 "Label on Parent" ! Index/contents of selected item
      POSITION = 20 "Note" ! Index/contents of selected item
      POSITION = 21 "Pattern" ! Index/contents of selected item
      POSITION = 22 "Pattern Point" ! Index/contents of selected item
      POSITION = 23 "Planar Ship Grid" ! Index/contents of selected item
      POSITION = 24 "Plane" ! Index/contents of selected item
      POSITION = 25 "Point" ! Index/contents of selected item
      POSITION = 26 "Point Cloud" ! Index/contents of selected item
      POSITION = 27 "Product Definition" ! Index/contents of selected item
      POSITION = 28 "Routing Objects" ! Index/contents of selected item
      POSITION = 29 "Section Line" ! Index/contents of selected item
      POSITION = 30 "Sheet Body" ! Index/contents of selected item
      POSITION = 31 "Sketch" ! Index/contents of selected item
      POSITION = 32 "Solid Body" ! Index/contents of selected item
      POSITION = 33 "Supplemental Geometry" ! Index/contents of selected item
      POSITION = 34 "Symbol" ! Index/contents of selected item
      POSITION = 35 "Tabular Note/Parts List" ! Index/contents of selected item
      POSITION = 36 "Title Block" ! Index/contents of selected item
      POSITION = 37 "Tolerance Feature" ! Index/contents of selected item
      POSITION = 38 "Tool Path" ! Index/contents of selected item
      POSITION = 39 "Traceline" ! Index/contents of selected item
      POSITION = 40 "Wall Thickness Analysis" ! Index/contents of selected item
  EVENT VALUE_CHANGED 1 0, 0, 0, 0, 0!  
  ASK_ITEM  0 (1 MULT 0) = 1  ! List
       POSITION = 13 "Face" ! Index/contents of selected item
  OK 1 0 ! OK Callback  
 END_ITEM  0 (1 MULT 0) = 1  ! List (Items selected)
      POSITION = 13 "Face" ! Index/contents of selected item
DIALOG_END -2, 0 ! Select by Type: OK
EVENT FOCUS_IN 0 0, 3145728, 0, 0, 0! Type Filter
MENU, 0, UG_MACRO_USER_ENTRY UG_GATEWAY_MAIN_MENUBAR <TopBorderBar->MenuBar->UG_TOOLBOX->UG_MACRO> ## ! 
USER_ENTRY_PROMPT -2 0
USE_ITEM 327680 (1 BOOL 0) = 1  ! Select Objects
USE_ITEM 1835009 (1 STRN 0) = ""  ! Select by Name
USE_ITEM 2293760 (0 BOOL 0) = 0  !  
USE_ITEM 3670016 (1 CTOL 0) = 1  !  
USE_ITEM 4718594 (1 BOOL 0) = 1  ! Preview
USER_ENTRY_BEGIN
FOCUS CHANGE IN 1
WINDOW RESIZE 0.900000 19.614583 8.708333 -1.000000 -0.443972 1.000000 0.443972
CURSOR_EVENT 1001 3,1,100,0 ! single_pt, mb1/0+0, , nn
CPOS 6.56805058190821,88.482203934106,25.4621854415378
EVENT FOCUS_IN 0 0, 3145728, 0, 0, 0! Type Filter
CURSOR_EVENT 1001 14,8226,110,0 ! cor_timeout, mb2/2+20, , nn
CPOS -7.10027456298027,63.4236078351438,25.4621854415378
CURSOR_EVENT 1001 13,2,110,0 ! mb2_hold_rel, mb2/0+0, , nn
CPOS -7.10027456298027,63.4236078351438,25.4621854415378
CURSOR_EVENT 1001 106,0,201,0 ! motion_pb, mb0/0+0, , nn
CPOS -7.10027456298027,63.4236078351438,25.4621854415378
CURSOR_EVENT 1001 3,8226,110,0 ! single_pt, mb2/2+20, , nn
CPOS -7.10027456298027,63.4236078351438,25.4621854415378
OK 0 0 ! OK Callback  
ASK_ITEM 327680 (1 BOOL 0) = 1  ! Select Objects
ASK_ITEM 327680 (1 BOOL 0) = 0  ! Select Objects
END_ITEM 327680 (1 BOOL 0) = 0  ! Select Objects
END_ITEM 1835009 (1 STRN 0) = ""  ! Select by Name
END_ITEM 2293760 (0 BOOL 0) = 0  !  
END_ITEM 3670016 (1 CTOL 0) = 1  !  
END_ITEM 4718594 (1 BOOL 0) = 1  ! Preview
DIALOG_END -2, 0 ! Class Selection: OK
USER_ENTRY_END
DIALOG_BEGIN "Edit Object Display" 5021 ! DA2
  BEG_ITEM  0 (1 BTAB 5021) = 1  !  
  BEG_ITEM  3 (1 INTE 5021) = 1  ! Layer
  BEG_ITEM  5 (1 CTOL 5021) = 1  !  
  BEG_ITEM  6 (1 OPTM 5021) = 1  ! Solid
  BEG_ITEM  7 (1 OPTM 5021) = 1  ! 0.13 mm
  BEG_ITEM 11 (1 SCAL 5021) = 0  !  
  BEG_ITEM 12 (1 BOOL 5021) = 0  ! Partially Shaded
  BEG_ITEM 13 (1 BOOL 5021) = 0  ! Face Analysis
  BEG_ITEM 16 (0 BOOL 5021) = 2  ! Show Poles
  BEG_ITEM 17 (0 BOOL 5021) = 2  ! Show Knots
  BEG_ITEM 18 (1 INTE 5021) = 0  ! U
  BEG_ITEM 19 (1 INTE 5021) = 0  ! V
  BEG_ITEM 22 (1 OPTM 5021) = 0  ! ##15No Change
  BEG_ITEM 23 (0 INTE 5021) = 0  ! Display Sample
  BEG_ITEM 26 (0 BOOL 5021) = 1  ! Apply to All Faces of Selected Body
  BEG_ITEM 27 (0 BOOL 5021) = 0  ! Apply Changes to Owning Part
  BEG_ITEM 34 (1 BOOL 5021) = 1  ! Needle
  BEG_ITEM 35 (1 CTOL 5021) = 131  !  
  BEG_ITEM 37 (1 BOOL 5021) = 1  ! Cap
  BEG_ITEM 38 (1 CTOL 5021) = 131  !  
  BEG_ITEM 40 (1 BOOL 5021) = 1  ! Needle
  BEG_ITEM 41 (1 CTOL 5021) = 84  !  
  BEG_ITEM 43 (1 BOOL 5021) = 1  ! Cap
  BEG_ITEM 44 (1 CTOL 5021) = 84  !  
  BEG_ITEM 46 (1 BOOL 5021) = 1  ! Needle
  BEG_ITEM 47 (1 CTOL 5021) = 184  !  
  BEG_ITEM 49 (1 BOOL 5021) = 1  ! Cap
  BEG_ITEM 50 (1 CTOL 5021) = 184  !  
  BEG_ITEM 52 (1 BOOL 5021) = 1  ! Needle
  BEG_ITEM 53 (1 CTOL 5021) = 117  !  
  BEG_ITEM 55 (1 BOOL 5021) = 1  ! Cap
  BEG_ITEM 56 (1 CTOL 5021) = 117  !  
  BEG_ITEM 61 (1 OPTM 5021) = 1  ! Solid
  BEG_ITEM 63 (1 OPTM 5021) = 1  ! Solid
  BEG_ITEM 69 (1 CTOL 5021) = 161  !  
  BEG_ITEM 70 (1 OPTM 5021) = 1  ! Solid
  BEG_ITEM 71 (1 BOOL 5021) = 1  ! Needle
  BEG_ITEM 72 (1 CTOL 5021) = 159  !  
  BEG_ITEM 73 (1 OPTM 5021) = 1  ! Solid
  BEG_ITEM 74 (1 BOOL 5021) = 1  ! Cap
  BEG_ITEM 75 (1 CTOL 5021) = 120  !  
  BEG_ITEM 76 (1 OPTM 5021) = 1  ! Solid
  BEG_ITEM 82 (1 CTOL 5021) = 99  !  
  BEG_ITEM 83 (1 OPTM 5021) = 1  ! Solid
  BEG_ITEM 84 (1 BOOL 5021) = 1  ! Cap
  BEG_ITEM 85 (1 CTOL 5021) = 160  !  
  BEG_ITEM 86 (1 OPTM 5021) = 1  ! Solid
  BEG_ITEM 92 (1 CTOL 5021) = 161  !  
  BEG_ITEM 93 (1 OPTM 5021) = 1  ! Solid
  BEG_ITEM 94 (1 BOOL 5021) = 1  ! Needle
  BEG_ITEM 95 (1 CTOL 5021) = 176  !  
  BEG_ITEM 96 (1 OPTM 5021) = 1  ! Solid
  BEG_ITEM 97 (1 BOOL 5021) = 1  ! Cap
  BEG_ITEM 98 (1 CTOL 5021) = 117  !  
  BEG_ITEM 99 (1 OPTM 5021) = 1  ! Solid
  BEG_ITEM 105 (1 CTOL 5021) = 159  !  
  BEG_ITEM 106 (1 OPTM 5021) = 1  ! Solid
  BEG_ITEM 108 (1 CTOL 5021) = 161  !  
  BEG_ITEM 114 (1 CTOL 5021) = 140  !  
  BEG_ITEM 115 (1 OPTM 5021) = 1  ! Solid
  END_ITEM  0 (1 BTAB 5021) = 1  !  
  END_ITEM  3 (1 INTE 5021) = 1  ! Layer
  END_ITEM  5 (1 CTOL 5021) = 6  !  
  END_ITEM  6 (1 OPTM 5021) = 1  ! Solid
  END_ITEM  7 (1 OPTM 5021) = 1  ! 0.13 mm
  END_ITEM 11 (1 SCAL 5021) = 0  !  
  END_ITEM 12 (1 BOOL 5021) = 0  ! Partially Shaded
  END_ITEM 13 (1 BOOL 5021) = 0  ! Face Analysis
  END_ITEM 16 (0 BOOL 5021) = 2  ! Show Poles
  END_ITEM 17 (0 BOOL 5021) = 2  ! Show Knots
  END_ITEM 18 (1 INTE 5021) = 0  ! U
  END_ITEM 19 (1 INTE 5021) = 0  ! V
  END_ITEM 22 (1 OPTM 5021) = 0  ! ##15No Change
  END_ITEM 23 (0 INTE 5021) = 0  ! Display Sample
  END_ITEM 26 (0 BOOL 5021) = 1  ! Apply to All Faces of Selected Body
  END_ITEM 27 (0 BOOL 5021) = 0  ! Apply Changes to Owning Part
  END_ITEM 34 (1 BOOL 5021) = 1  ! Needle
  END_ITEM 35 (1 CTOL 5021) = 131  !  
  END_ITEM 37 (1 BOOL 5021) = 1  ! Cap
  END_ITEM 38 (1 CTOL 5021) = 131  !  
  END_ITEM 40 (1 BOOL 5021) = 1  ! Needle
  END_ITEM 41 (1 CTOL 5021) = 84  !  
  END_ITEM 43 (1 BOOL 5021) = 1  ! Cap
  END_ITEM 44 (1 CTOL 5021) = 84  !  
  END_ITEM 46 (1 BOOL 5021) = 1  ! Needle
  END_ITEM 47 (1 CTOL 5021) = 184  !  
  END_ITEM 49 (1 BOOL 5021) = 1  ! Cap
  END_ITEM 50 (1 CTOL 5021) = 184  !  
  END_ITEM 52 (1 BOOL 5021) = 1  ! Needle
  END_ITEM 53 (1 CTOL 5021) = 117  !  
  END_ITEM 55 (1 BOOL 5021) = 1  ! Cap
  END_ITEM 56 (1 CTOL 5021) = 117  !  
  END_ITEM 61 (1 OPTM 5021) = 1  ! Solid
  END_ITEM 63 (1 OPTM 5021) = 1  ! Solid
  END_ITEM 69 (1 CTOL 5021) = 161  !  
  END_ITEM 70 (1 OPTM 5021) = 1  ! Solid
  END_ITEM 71 (1 BOOL 5021) = 1  ! Needle
  END_ITEM 72 (1 CTOL 5021) = 159  !  
  END_ITEM 73 (1 OPTM 5021) = 1  ! Solid
  END_ITEM 74 (1 BOOL 5021) = 1  ! Cap
  END_ITEM 75 (1 CTOL 5021) = 120  !  
  END_ITEM 76 (1 OPTM 5021) = 1  ! Solid
  END_ITEM 82 (1 CTOL 5021) = 99  !  
  END_ITEM 83 (1 OPTM 5021) = 1  ! Solid
  END_ITEM 84 (1 BOOL 5021) = 1  ! Cap
  END_ITEM 85 (1 CTOL 5021) = 160  !  
  END_ITEM 86 (1 OPTM 5021) = 1  ! Solid
  END_ITEM 92 (1 CTOL 5021) = 161  !  
  END_ITEM 93 (1 OPTM 5021) = 1  ! Solid
  END_ITEM 94 (1 BOOL 5021) = 1  ! Needle
  END_ITEM 95 (1 CTOL 5021) = 176  !  
  END_ITEM 96 (1 OPTM 5021) = 1  ! Solid
  END_ITEM 97 (1 BOOL 5021) = 1  ! Cap
  END_ITEM 98 (1 CTOL 5021) = 117  !  
  END_ITEM 99 (1 OPTM 5021) = 1  ! Solid
  END_ITEM 105 (1 CTOL 5021) = 159  !  
  END_ITEM 106 (1 OPTM 5021) = 1  ! Solid
  END_ITEM 108 (1 CTOL 5021) = 161  !  
  END_ITEM 114 (1 CTOL 5021) = 140  !  
  END_ITEM 115 (1 OPTM 5021) = 1  ! Solid
DIALOG_END -2, 0 ! Edit Object Display: OK
 
 https://files.engineering.com/getfile.aspx?folder=c6b718c0-a311-418c-8b0a-b5092c652f3d&file=2020-09-09_11-34-59.png
It looks like you want a journal that will allow you to select one or more faces and then color them blue. Is this correct?

www.nxjournaling.com
 
Exactly what i need, Cowski!

I also tried to do it with a journal, but, I can't make a user input while running.

 
Jonatasrf,
Attached are journal with user interface dialog box files.

Attachment is having 2 files( .cs and .dlx) . When this journal is run an ui block will ask to select the faces. After selecting faces ,press OK button, color of the faces will be changed to 211. To use these journals below steps are needed.

1) create 2 folders with names "application" , "startup" in the folder where "UGII_USER_DIR" environment variable is pointed.
2) unzip and place 2 files in application folder.
3) In NX Create a custom button and Edit action dialog select Type as journal file and browse to the application folder and select .cs file.
 
 https://files.engineering.com/getfile.aspx?folder=15118833-6a20-439d-903d-064e897cc36b&file=Custom.zip
That's great!

Thanks for your help @Ram K!
If you allow me, I will use this code to paint the surfaces with other colors.

Thank you very much!
best regards!
 
Jonatasrf
Sure, let me know if you need more help in this.
ramkan8@yahoo.com
 
The following thread might also be of interest:
thread561-359924

The target color isn't predefined in the journal (but could be), but it allows you to use various selection functions (such as tangent faces) that you can't normally use when changing colors.

www.nxjournaling.com
 
Here is simple journal to color faces:

Code:
Option Strict Off

Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI


Module changeColorOfPreSelectedFaces_v2

	Dim theSession As Session = Session.GetSession()
	Dim sel As Selection = NXOpen.UI.GetUI.SelectionManager

Sub Main()

	'' Integer variable to store color code in.
	Dim newColorCode As Integer = 114

	newColorCode = Convert.ToInt32(211)
 
	'' The selectFaces method takes an NXobject array by reference 
	Dim selectedObjectsArray() As NXObject
	SelectFaces(selectedObjectsArray)

	'' Need to recast the face NXObjects to Displayable objects
	Dim faceArray(selectedObjectsArray.Length - 1) As DisplayableObject
	
	For i As Integer = 0 To selectedObjectsArray.Length - 1
	
		faceArray(i) = CType(selectedObjectsArray(i), DisplayableObject)
			
	Next

	'' A display modification object is used to change to color of the faces.
	Dim changeFaceColor As DisplayModification = theSession.DisplayManager.NewDisplayModification()
	
	With changeFaceColor
		.ApplyToAllFaces = False
		.NewColor = newColorCode
		.Apply(faceArray)
		.Dispose()	
	End With

End Sub


Sub SelectFaces(ByRef selectedObjects As NXObject())

	Dim ui As UI = NXOpen.UI.GetUI
	Dim message As String = "Select faces"
	Dim title As String = "Select faces"
	Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
	Dim keepHighlighted As Boolean = False
	Dim includeFeatures As Boolean = False
	Dim response As Selection.Response
	Dim selectionAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
	Dim selectionMask_array(0) As Selection.MaskTriple
	
	With selectionMask_array(0)
		.Type = UFConstants.UF_solid_type
		.Subtype = 0
		.SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_ANY_FACE
	End With

	Response = ui.SelectionManager.SelectObjects(message, title, scope, selectionAction, includeFeatures, _
			keepHighlighted, selectionMask_array, selectedObjects)

	If response = Selection.Response.Cancel Or response = Selection.Response.Back Then
	
		Return
		
	End If

End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer

	GetUnloadOption = NXOpen.UF.UFConstants.UF_UNLOAD_IMMEDIATELY

End Function

End Module

With best regards
Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor