Select a Program Group and iterate operations

I have found a lot of examples for selecting objects and I've tried a number of them out, but I am having trouble figuring out how to select an operation group in the operation navigator. I would then like to iterate through all of the operations in that group.
Ideally I would like to be able to read and set various attributes in the operations. From my last topic it would be apparent that I want to be able to read the information found in non-cutting moves.

Thank you. Your help is getting me closer to putting together the different things I've learned.

To date, I've done very little with CAM, though I hope to do more in the near future. I'm not in a good position to help with this request as I don't currently have access to a CAM license to work with. However, I would suggest you look at the samples shipped with NX found in the [NX install folder]\UGOPEN\SampleNXOpenApplications\.NET\CAM. The sample: OntSelectionBoilerPlate.vb has some code relating to selection and near the end of the file there is a function called: NonCutParameters. It appears that with some editing, you can query and/or set the non-cutting parameters as desired.

You may also want to search the GTAC solution center for "nxopen sample CAM" and search or ask questions in the NX languages forum, also on the GTAC support site (links to both can be found on the Resources page in the main menu on the left).

Good recommendations, thank you. I have searched the GTAC some, but I will spend more time with that. For some reason that site is difficult for me to navigate and filter the searches. I will check out that sample folder also. If I can pull together a solution, I will post my code here. Thanks.

RVogel

Here is a starting point for you. Enter the name of the Operation Group in the 1st input box and then it will loop through the ops inside it editing the feeds and speeds. It assumes ops are variable contours with drive surface geometry. If you have other types of ops then a bit more code will have to go in to handle the different types. It should be enough to have a play with.

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

Module NXJournal
Dim OPERATIONGROUP As String
Dim FEED As Double
Dim SPEED As Double

Dim m_OperationList() As String

Sub Main()
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
Dim theUISession As UI = UI.GetUI

Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display

Dim lw As ListingWindow = thesession.ListingWindow

Dim feedstr, speedstr As String

OPERATIONGROUP = NXInputBox.GetInputString("Enter Group Name to edit", "CAM OPERATION EDITOR", "OP_NAME")
feedstr = NXInputBox.GetInputString("Enter Required Feed Rate", "CAM OPERATION EDITOR", "350")
FEED = Convert.ToDouble(feedstr)
speedstr = NXInputBox.GetInputString("Enter Required Spindle Speed", "CAM OPERATION EDITOR", "6000")
SPEED = Convert.ToDouble(speedstr)

Dim MainProg As CAM.NCGroup = CType(WorkPart.CAMSetup.CAMGroupCollection.FindObject(OPERATIONGROUP), 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
Dim surfaceContourBuilder As CAM.SurfaceContourBuilder
Dim feedsBuilder As CAM.FeedsBuilder
Dim SpindleSpeedBuilder As CAM.InheritableDoubleBuilder
Dim FeedCut As CAM.InheritableFeedBuilder

Dim nXObject As NXObject

operation = CType(WorkPart.CAMSetup.CAMOperationCollection.FindObject(Op), CAM.Operation)
surfaceContourBuilder = WorkPart.CAMSetup.CAMOperationCollection.CreateSurfaceContourBuilder(operation)
feedsbuilder = surfaceContourBuilder.FeedsBuilder

FeedCut = feedsBuilder.FeedCutBuilder
FeedCut.Value = FEED

SpindleSpeedBuilder = feedsBuilder.SpindleRpmBuilder
SpindleSpeedBuilder.Value = SPEED

nXObject = surfaceContourBuilder.Commit()
surfaceContourBuilder.Destroy()

Next

'WRITE RESULT DATA TO FILE & SCREEEN
lw.SelectDevice(ListingWindow.DeviceType.Window, "")
lw.open()
lw.WriteLine(Opnames.length & " operations have been modified.")

lw.WriteLine("")

lw.Close()
lw.SelectDevice(ListingWindow.DeviceType.Window, "")

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

That is just what I was hoping for. That gives me an excellent start. I really appreciate this!

RVogel