Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

how to get tool list with the help of NX open code ?

Hi ALL,

Need a help in getting the tool list from nx open code (preffreably c#). I want the name of all the tools available as used/unused in machine tool navigator . The tool name should get output in listing window or a separate txt file.

Thanks

2 REPLIES
Solution
Solution
Accepted by topic author IMGatWORK
‎08-20-2016 03:27 AM

Re: how to get tool list with the help of NX open code ?

 

There is an example program on the Solution Center that might be a good start, called

 

Sample CAM Visual Basic program : report all cam tools

 

This link may work:

 

https://solutions.industrysoftware.automation.siemens.com/view.php?sort=desc&p=1&q=nx_api4709&file_t...

 

If the link does not work, just search for "nx_api4709", and it should find it.  (It is VB, not C#.)

 

 

Solution
Solution
Accepted by topic author IMGatWORK
‎08-20-2016 03:28 AM

Re: how to get tool list with the help of NX open code ?

I am not sure how to cycle the machine tool navigator.

In the operation navigator, you can either cycle tools, or cycle operations and ask for their tool parents. If you want both used and unused tools, you need to cycle the tools.

Here is another sample api program - it cycles the operations, and reports with parent and reference tools are used:

' GetToolCycleAllOps.vb
'=============================================================================
'
'   Copyright 2015 Siemens Product Lifecycle Management Software Inc. All Rights Reserved.
'
'=============================================================================
'
'  REVISIONS
'     03-Aug-2015  Mark Rief   Original
'
' ===========================================================================
'   DESCRIPTION
    ' This program will cycle through all the operations in the tool view and 
	' report their tools used.
' ============================================================================

Imports System 
Imports System.Collections 
Imports NXOpen 
Imports NXOpen.CAM 
Imports NXOpen.UF 
Imports NXOpen.Utilities 

Public Class report_all_oper_ref_cutters 
    Public Shared Sub Main(ByVal args As String()) 
        Try 
            Dim theSession As Session = Session.GetSession() 
            Dim theUI As UI = UI.GetUI() 
            Dim theUfSession As UFSession = UFSession.GetUFSession() 
            Dim dispPart As Part = theSession.Parts.Display 
            Dim lw As ListingWindow = theSession.ListingWindow 
            lw.Open() 
            
            Dim opers As OperationCollection = dispPart.CAMSetup.CAMOperationCollection 
            Dim en As IEnumerator = opers.GetEnumerator() 
            en.Reset() 
            
            While en.MoveNext() 
                Dim oper As Operation = DirectCast(en.Current, Operation) 
                lw.WriteLine(oper.Name) 
				'Get the parent in the tool view
                Dim toolGroup As CAM.NCGroup = oper.GetParent(CAM.CAMSetup.View.MachineTool) 
				'Only tools (not pockets, Unused items, turrets, heads)
                If TypeOf toolGroup Is CAM.Tool Then					
					Dim cutter As Tool = DirectCast(toolGroup, Tool) 
					lw.WriteLine(" Tool Parent: " & cutter.Name) 
				Else 
					lw.WriteLine(" No Tool") 
				End If

				'Also look for reference tool
				Dim ref_cutter_tag As Tag = Tag.Null 
				theUfSession.Oper.AskRefCutter(oper.Tag, ref_cutter_tag) 
				If ref_cutter_tag <> Tag.Null Then 
					Dim ref_cutter As Tool = DirectCast(NXObjectManager.[Get](ref_cutter_tag), Tool) 
					lw.WriteLine(" Reference Tool: " & ref_cutter.Name) 
				Else 
					lw.WriteLine(" No Reference Tool") 
				End If
				
            End While 
            
        Catch ex As NXOpen.NXException 
            ' end try 
            UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.[Error], ex.Message) 
        Catch ex As Exception 
            UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.[Error], ex.Message) 
        End Try 
        
    End Sub 
End Class 
Mark Rief
Retired Siemens