So the goal of the project is basically to select given operations and do a tool replay and take a picture and send to excel or what ever, and cycle thru each operation, wait to orient screen, and take picture , etc
I have
Dim setupTag As Tag
Dim selectedTags() As NXOpen.Tag
Dim selectedCount As Integer
'If there is a work part only then we can go further
If WorkPart IsNot Nothing Then
ufs.Cam.InitSession()
ufs.Setup.AskSetup(setupTag)
' If there is a setup only then we go further
If setupTag <> 0 Then
' Get the selected nodes from the Operation Navigator
ufs.UiOnt.AskSelectedNodes(selectedCount, selectedTags)
If selectedCount = 0 Then
MsgBox("No operations selected.", MsgBoxStyle.Exclamation, "PLEASE SELECT OPERATION TOOL PATHS BEFORE TRYING AGAIN")
Exit Sub
End If
End If
End If
to count the number of selected operations and to have a for statement cycle thru that many times. Now i need a way to put each object CAM OPERATION into an array so i can cycle thru that for statement and use the
'####### Add pictures to excel structure ################
Dim strFileName As String
Dim i As Integer = 0
For i = 1 To selectedCount
'reposition for next shot
theUISession.NXMessageBox.Show("SELECT NEW PICTURE", NXMessageBox.DialogType.Information, "PLEASE ARRANGE PICTURE AND PRESS OK FOR PICTURE NUMBER #"&i)
Dim objects1(selectedCount) As CAM.CAMObject
Dim setup As CAM.CAMSetup = workPart.CAMSetup()
setup.ReplayToolPath(objects1)
'Create the image
Dim prtJpg As String = parentFolder & "\" & i & ".jpg"
ufs.Disp.CreateImage(prtJpg, UFDisp.ImageFormat.Jpeg, UFDisp.BackgroundColor.White)
'End Create a JPG screenshot
Is there a command to add
Is there a command to add selected objects to an array/list? then i guess you might need to parse each operation into its subtype to use the ReplayToolPath ?
JP
Aerospace
CNC Programmer
re: ReplayToolPath
I'm not that familiar with the CAM application/CAM objects. It appears that you want to replay each selected operation and generate a screenshot after each step. Is this correct?
re: get selected nodes
Like I said, I'm not too familiar with CAM, nor do I currently have access to a license to test this code, but here is what I would try:
Dim setupTag As Tag
Dim selectedTags() As NXOpen.Tag
Dim selectedCount As Integer
'If there is a work part only then we can go further
If Workpart Is Nothing Then
'add code to warn user...
Return
End If
ufs.Cam.InitSession()
ufs.Setup.AskSetup(setupTag)
' If there is a setup only then we go further
If setupTag = 0 Then
'add code to warn user...
Return
End If
' Get the selected nodes from the Operation Navigator
ufs.UiOnt.AskSelectedNodes(selectedCount, selectedTags)
If selectedCount = 0 Then
MsgBox("No operations selected.", MsgBoxStyle.Exclamation, "PLEASE SELECT OPERATION TOOL PATHS BEFORE TRYING AGAIN")
Exit Sub
End If
'####### Add pictures to excel structure ################
Dim strFileName As String
For i As Integer = 0 To selectedCount - 1
'reposition for next shot
theUISession.NXMessageBox.Show("SELECT NEW PICTURE", NXMessageBox.DialogType.Information, "PLEASE ARRANGE PICTURE AND PRESS OK FOR PICTURE NUMBER #" & i)
Dim objects1(0) As CAM.CAMObject
objects1(0) = Utilities.NXObjectManager.Get(selectedTags(i))
Dim setup As CAM.CAMSetup = Workpart.CAMSetup()
setup.ReplayToolPath(objects1)
'Create the image
Dim prtJpg As String = parentFolder & "\" & i & ".jpg"
ufs.Disp.CreateImage(prtJpg, UFDisp.ImageFormat.Jpeg, UFDisp.BackgroundColor.White)
'End Create a JPG screenshot
Next