Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.CAM
Imports NXOpen.UF
Imports NXOpen.Utilities
Module GetFeedTraversal
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
Sub Main()
lw.Open()
Dim setupTag As Tag
Dim selectedTags() As NXOpen.Tag
Dim selectedCount As Integer
Dim theUI As UI = UI.GetUI()
theUfSession.Setup.AskSetup(setupTag)
If setupTag <> 0 Then
theUfSession.UiOnt.AskSelectedNodes(selectedCount, selectedTags)
If selectedCount = 0 Then
theUI.NXMessageBox.Show("Error : ", _
NXMessageBox.DialogType.Error, _
"No selected operation...")
Exit Sub
End If
Dim op As NXObject
Dim feedtraversal As Double = 0
For i As Integer = 0 To selectedCount - 1
Try
op = NXObjectManager.Get(selectedTags(i))
Dim operation As CAM.Operation = CType(op, CAM.Operation)
Dim FeedUnit As CAM.FeedRateUnit = operation.GetFeedRate("Feed Traversal", feedtraversal)
lw.WriteLine(operation.name())
lw.WriteLine("Traversal Feedrate : " & feedtraversal.ToString & "/" & FeedUnit.ToString)
Catch ex As NXOpen.NXException
lw.Writeline(ex.ToString())
End Try
Next
End If
End Sub
End Module
Option Strict Off
Imports NXOpen
Imports NXOpen.CAM
Imports NXOpen.UF
Imports NXOpen.UF.UFoper
Imports NXOpen.Utilities
Imports NXOpenUI
Imports System
Imports System.IO
Module IPMTraversalFeedRateEditor
Dim updatableMillingOperationSubTypes = New Collections.Generic.Dictionary(Of Integer, String) From {
{ 110, "Planar mill profile / pocket operation" },
{ 210, "Fixed axis surface contouring" },
{ 211, "Variable axis surface contouring" },
{ 220, "Unknown (UF_mach_point_to_point_subtype)" },
{ 260, "Cavity milling" },
{ 261, "Face milling" },
{ 262, "Volume milling" },
{ 263, "Z-Level milling" },
{ 265, "Plunge milling" },
{ 266, "Variable axis Z-Level" },
{ 1700, "Thread milling" },
{ 3100, "Groove milling" },
{ 3300, "Radial groove milling operation" },
{ 2700, "Cylinder milling" },
{ 3200, "Chamfer milling" }
}
Sub Main()
' Read selected item by the user. It should be a single program group.
Dim selectedTags() As NXOpen.Tag
Dim selectedCount As Integer
UFSession.GetUFSession().UiOnt.AskSelectedNodes(selectedCount, selectedTags)
If selectedCount <> 1 Then
UI.GetUI().NXMessageBox.Show("Error : ", NXMessageBox.DialogType.Error, "You must select exactly one program group.")
Exit Sub
End If
' Cast selected item to program group.
Dim programGroup As CAM.NCGroup
Try
programGroup = CType(NXObjectManager.Get(selectedTags(0)), CAM.NCGroup)
Catch ex As InvalidCastException
UI.GetUI().NXMessageBox.Show("Error : ", NXMessageBox.DialogType.Error, "You must select a program group.")
Exit Sub
Catch ex As OverflowException
UI.GetUI().NXMessageBox.Show("Error : ", NXMessageBox.DialogType.Error, "You must select a program group.")
Exit Sub
End Try
' Prompt for the new feed traversal feed rate and convert to a number.
Dim newFeedRateValue As Double = Convert.ToDouble(NXInputBox.GetInputString("Enter new traversal feed rate", "Feed Traversal Rate Editor", "475"))
' Get all operations that are part of the program group.
Dim operations As New System.Collections.Generic.List(Of CAM.Operation)
For Each member As CAM.CAMObject In programGroup.GetMembers()
If TypeOf member Is CAM.Operation
operations.Add(CType(member, CAM.Operation))
End If
Next
Dim listingWindow As ListingWindow = Session.GetSession().ListingWindow
listingWindow.SelectDevice(ListingWindow.DeviceType.Window, "")
listingWindow.open()
' Iterate over operations. Update milling operations with IPM traversal feed rates.
For Each operation As CAM.Operation In operations
'Get the type and subtype of the operation.
Dim operationType As Integer
Dim operationSubtype As Integer
UFSession.GetUFSession().Obj.AskTypeAndSubtype(operation.tag, operationType, operationSubtype)
' Update milling operations with IPM traversal feed rates. Skip others.
If updatableMillingOperationSubTypes.ContainsKey(operationSubtype) Then
Dim objectsFeedsBuilder As CAM.ObjectsFeedsBuilder = Session.GetSession().Parts.Work.CAMSetup.CreateFeedsBuilder(New CAM.CAMObject() { operation })
Dim feedTraversal As CAM.InheritableFeedBuilder = objectsFeedsBuilder.FeedsBuilder.FeedTraversalBuilder
Dim oldFeedRateValue As Double = feedTraversal.Value
If feedTraversal.Unit = CAM.FeedRateUnit.PerMinute Then
feedTraversal.Value = newFeedRateValue
objectsFeedsBuilder.Commit()
ListingWindow.WriteLine(operation.Name & " - Traversal feed rate updated from " & oldFeedRateValue & " to " & newFeedRateValue)
End If
objectsFeedsBuilder.Destroy()
End If
Next
listingWindow.Close()
End Sub
End Module