Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Show a list of which colors a part is using.

Status
Not open for further replies.

JurgenKreisel

Automotive
Feb 3, 2010
102
Good morning.

Does anyone know of a way to get a list of what colors a part is using.
We have a color map that the designers use. They are only supposed to use the 60 favorite colors but sometimes the rules are not followed.
Is there a way to interrogate a part and get a list of what colors that part uses. This way it is easy to see if the rules were not followed.
I know that I can select every surface and do an information query but if a part has several thousand surfaces the list is extremely long and almost impossible to use.

Ideally just a summary of colors used and nothing else.

Currently using NX11 and NX12 on windows 7 and 10.

Regards
Jurgen
 
Replies continue below

Recommended for you

I don't think there is any built-in function to do this. But it would be about a dozen lines of code using the SNAP or NX/Open APIs. Ask again if that's an option that interests you.
 
Try this code:

Code:
Option Strict Off
 
Imports System
Imports System.Collections.Generic
Imports NXOpen
 
Module Colorface

    Sub Main()
 
        Dim theSession As Session = Session.GetSession()
        Dim workPart As Part = theSession.Parts.Work
 
        Dim lw As ListingWindow = theSession.ListingWindow

        lw.Open()
 
	Dim List1 As New List(Of String)
	 
        For Each theBody As Body In workPart.Bodies
 
            Dim bodyFaces() As Face
            bodyFaces = theBody.GetFaces
 
		For Each tempFace As Face In bodyFaces	

			if not List1.contains(tempface.color) then 
				List1.Add(tempFace.color)
			end if

            	Next
 
        Next

	if Not IsNothing(List1) AndAlso List1.Count > 0 Then

		List1.sort()
	
		lw.writeline(" ")
		lw.writeline("********************")
		lw.writeline("COLORS USED IN PART:")
		lw.writeline("********************")
		lw.writeline(" ")
		
		for each facecolor as string in List1

			lw.writeline(facecolor)
			
		next

	end if

   End Sub
 
End Module

With best regards
Michael
 
Thank you for the program.
Actually we created a program within excel to give a report.
Select all faces and do an info report. Copy the entire report into excel and run the program.
Just comes back with a list of colors used within the entire part, it actually shows the little color box that info gives you from within NX.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor