Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Find tool name for each operation - NXOPEN

Status
Not open for further replies.

KS1971

Aerospace
Feb 10, 2014
13
Hi,

I am looking for the easiset method to find the tool name for each operation in a cam program group.

I have to bare bones of what I need, I have put some pseudo code in bold where I think I may be able to get the tool name.

Any help would be very much appreciated.


Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.UF.UFoper
Imports NXOpen.CAM
Imports NXOpenUI


Module NXJournal
Dim m_OperationList() As String
Sub Main
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display

Dim MainProg As CAM.NCGroup = CType(WorkPart.CAMSetup.CAMGroupCollection.FindObject("CAM_PROGRAM_GROUP"), CAM.NCGroup)

'List all the ops in the program
Dim Opnames() As String = OperationList(MainProg.Tag)

For Each Op As String In Opnames

Dim operation As CAM.Operation

operation = CType(WorkPart.CAMSetup.CAMOperationCollection.FindObject(Op), CAM.Operation)
Dim Toolbuilder as CAM.ToolBuilder
Toolbuilder = WorkPart.CAMSetup.CAMOperationCollection.ToolBuilder(operation)
messagebox ("Tool used=" & Toolbuilder.Name)
ToolBuilder.Destroy()

Next
End Sub

Public Function OperationList(ByVal sTag As NXOpen.Tag) As String()
Dim theUfSession As UFSession = UFSession.GetUFSession()
m_OperationList = Nothing
Dim ptr As IntPtr = New System.IntPtr
Dim cycle_cb_fn As NXOpen.UF.UFNcgroup.CycleCbFT = New NXOpen.UF.UFNcgroup.CycleCbFT(AddressOf cycle_OperationList)
'Cycle throught this view and find every object
theUfSession.Ncgroup.CycleMembers(sTag, cycle_cb_fn, ptr)
Return m_OperationList
End Function

Private Function cycle_OperationList(ByVal camObjectTag As Tag, ByVal ptr As IntPtr) As Boolean
Dim camObject As CAM.CAMObject = NXOpen.Utilities.NXObjectManager.Get(camObjectTag)
'Check if the object is an Operation
If TypeOf camObject Is CAM.Operation Then
If m_OperationList Is Nothing Then
ReDim m_OperationList(0)
Else
ReDim Preserve m_OperationList(m_OperationList.Length)
End If
m_OperationList(UBound(m_OperationList)) = camObject.Name
End If
Return True
End Function
End Module
 
Replies continue below

Recommended for you

For info, after a lot of head scratching and plenty of googling I have found the missing line:

dim strResult as string
theUfSession.Param.AskStrValue(operation.tag, 1043, strResult)
theSession.ListingWindow.WriteLine("OP=" & op & " TOOL=" & strResult)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor